Module: Ninjs::Command
- Defined in:
- lib/ninjs/command.rb
Class Method Summary collapse
- .compile(options = nil) ⇒ Object
- .create(config = nil) ⇒ Object
- .generate(config) ⇒ Object
- .update(path = nil) ⇒ Object
- .watch(path = nil) ⇒ Object
Class Method Details
.compile(options = nil) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ninjs/command.rb', line 62 def compile( = nil) settings = { force_compress: false, path: File.(Dir.getwd) } settings.merge!() unless .nil? raise "ninjs.conf was not located in #{settings[:path]}" unless File.exists? "#{settings[:path]}/ninjs.conf" project = Ninjs::Project.new(root: settings[:path]) project.config.output = 'compressed' if settings[:force_compress] project.update end |
.create(config = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ninjs/command.rb', line 48 def create(config = nil) settings = { name: nil, root: File.(Dir.getwd) } settings.merge!(config) unless config.nil? raise 'you must specify a project name: ninjs create ProjectName' if settings[:name].nil? project = Ninjs::Project.new({ name: settings[:name], root: settings[:root] }) project.create end |
.generate(config) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/ninjs/command.rb', line 76 def generate(config) begin conf_path = "#{config[:project].root}/ninjs.conf" raise "ninjs.conf was not located in #{conf_path}" unless File.exists? conf_path generator = Ninjs::Generator.new(config) generator.generate end end |
.update(path = nil) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/ninjs/command.rb', line 85 def update(path = nil) path = File. Dir.getwd if path.nil? raise "ninjs.conf was not located in #{path}" unless File.exists? "#{path}/ninjs.conf" project = Ninjs::Project.new({ root: path }) project.create_ninjs_lib_file project.create_utility_lib_file end |
.watch(path = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ninjs/command.rb', line 3 def watch(path = nil) require "fssm" path ||= File.(Dir.getwd) raise "ninjs.conf was not located in #{path}" unless File.exists? "#{path}/ninjs.conf" puts Ninjs::Notification.log "Ninjs are watching for changes. Press Ctrl-C to stop." project = Ninjs::Project.new project.update watch_dirs = Ninjs::Manifest.directories.reject { |dir| dir.match(/application|tests|spec/) } watch_hash = Hash.new watch_dirs.each do |dir| watch_hash["#{path}/#{dir}"] = "**/*.js" end watch_hash[path] = "**/*.conf" watch_hash["#{Ninjs::BASE_DIR}/repository"] = "**/*.js" FSSM.monitor do watch_hash.each do |dir, g| path "#{dir}" do glob g update do |base, relative| puts Ninjs::Notification.event "change detected in #{relative}" project.config.read if relative.match(/conf$/) project.update end create do |base, relative| puts Ninjs::Notification.event "#{relative} created" project.update end end end end end |