Module: Judojs::Command

Defined in:
lib/judojs/command.rb

Class Method Summary collapse

Class Method Details

.compileObject



93
94
95
96
97
98
# File 'lib/judojs/command.rb', line 93

def compile
  project_path = Dir.getwd << '/'
  raise "judojs.conf was not located in #{project_path}" unless File.exists? "#{project_path}/judojs.conf"
  project = Judojs::Project.init_with_config(project_path)
  project.update
end

.create(name, directory = false) ⇒ Object



87
88
89
90
91
# File 'lib/judojs/command.rb', line 87

def create(name, directory = false)
  raise 'you must specify a project name: judojs create -n "ProjectName"' if name.nil?
  project = directory ? Judojs::Project.new(name, directory) : Judojs::Project.new(name)
  project.create
end

.helpObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/judojs/command.rb', line 104

def help
  puts <<-DOC
  
Description: 
The judojs command line tool will compile your judojs application into modules.
To compile your judojs application into module files:

Usage: judojs [action] [options]
  
Actions:
  compile  Compiles the judojs project in the current working directory
  watch    Watches the current working directory for 
       file changes and compiles when files change
  create   Generates judojs application architecture and files
  
Options:
  -n, --name       Name of the judojs application to create
  -d, --directory  Optional install directory for a new judojs project
               (creates the folder if it does not exist)
  
Example:
  // Generate a new judojs application in the js folder
  // (creates folder if it doesn't exist)
  judojs create -n "MyApplication" -d "js"
  
  // cd to the judojs root folder (ie. js)
  judojs watch -or- judojs compile
  DOC
end

.import(package) ⇒ Object



100
101
102
# File 'lib/judojs/command.rb', line 100

def import(package)
  Judojs::PackageManager.import(package)
end

.watchObject



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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/judojs/command.rb', line 3

def watch
  require "fssm"
  project_path = Dir.getwd << '/'
  raise "judojs.conf was not located in #{project_path}" unless File.exists? "#{project_path}judojs.conf"
  color_start = "\e[33m"
  color_end = "\e[0m"
  puts "\e[32m>>>#{color_end} Judojs is watching for changes. Press Ctrl-C to stop."
  project = Judojs::Project.init_with_config(project_path)
  project.update
	  
  FSSM.monitor do
    path "#{project_path}elements" do
      glob "**/*.js"

      update do |base, relative|
        puts "#{color_start}<<<#{color_end} change detected in #{relative}"
        project.update
      end

      create do |base, relative|
        puts "#{relative} created"
        project.update
      end
    end
    
    path "#{project_path}models" do
      glob "**/*.js"

      update do |base, relative|
        puts "#{@color_start}<<<#{@color_end} change detected in #{relative}"
        project.update
      end

      create do |base, relative|
        puts "#{relative} created"
        project.update
      end
    end
    
    path "#{project_path}modules" do
      glob "**/*.js"

      update do |base, relative|
        puts "#{color_start}<<<#{color_end} change detected in #{relative}"
        project.update
      end

      create do |base, relative|
        puts "#{relative} created"
        project.update
      end
    end

    path "#{project_path}lib" do
      glob "**/*.js"

      update do |base, relative|
        puts "#{color_start}<<<#{color_end} change detected in #{relative}"
        project.config.read
        project.update_application_file
        project.update
      end

      create do |base, relative|
        puts "+++ created #{relative}"
        project.update
      end
    end
    
    path "#{project_path}" do
      glob "**/*.conf"
      
      update do |base, relative|
        puts "#{color_start}<<<#{color_end} change detected in #{relative}"
        project.config.read
        project.update_application_file
        project.update
      end
    end
    
  end
  
end