Class: Creng::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/creng.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



96
97
98
99
100
101
102
# File 'lib/creng.rb', line 96

def build
  
	FileProcessor.inProjectDir do |curdir|
     FileProcessor.process curdir, @options, FileGenerator.getAccessibleResources()
   end

end

#debugObject



54
55
56
# File 'lib/creng.rb', line 54

def debug
	puts @projectname
end

#feature(*args) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/creng.rb', line 105

def feature(*args)
  action = args.first
  value = args[1]

  if Feature.respond_to? action

    FileProcessor.inProjectDir do |curdir|      

      Feature.send(action, curdir, value)        
    end

    
  else
    puts "feature action not supported"
  end


end

#help(command = nil) ⇒ Object



125
126
127
128
129
130
131
132
133
134
# File 'lib/creng.rb', line 125

def help(command = nil)
	puts @optparser
	#puts @options
	puts
   	puts "Commands:"
   	puts "    help        Shows this help."
   	puts "    init <project_name>       Initialize new project"
   	puts "	  build <project_name>	building project with given options"
     puts "    feature <add|remove>  adding or removing feature to/from project"
end

#init(*args) ⇒ Object



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
86
87
88
89
90
91
92
# File 'lib/creng.rb', line 59

def init(*args)
  projectname = args.first
	if File.directory? projectname
		puts "		project directory already exists"
	else

 	puts "		initialized project with name #{projectname}"

 	puts "		create #{projectname}/dev/js/vendor/content"
 	FileUtils.mkdir_p "#{projectname}/dev/js/vendor/content"

    	puts "        create #{projectname}/dev/js/vendor/utils"
    	FileUtils.mkdir_p "#{projectname}/dev/js/vendor/utils"

    	puts "        create #{projectname}/dev/js/vendor/background"
    	FileUtils.mkdir_p "#{projectname}/dev/js/vendor/background"

 	puts "		create #{projectname}/dev/images"
 	FileUtils.mkdir_p "#{projectname}/dev/images"

 	puts "		create #{projectname}/dev/html"
 	FileUtils.mkdir_p "#{projectname}/dev/html"

 	puts "		create #{projectname}/dev/js"
 	FileUtils.mkdir_p "#{projectname}/dev/js/"

 	puts "		create #{projectname}/build"
 	FileUtils.mkdir_p "#{projectname}/build"

FileGenerator.new projectname

    	
    end
end

#run(args) ⇒ Object



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
# File 'lib/creng.rb', line 23

def run(args)

  options = {}
  @optparser = RDF::CLI.options do
   self.on('-n', '--nodefine',   'Init or build without define statements') do
       options[:nodefine] = true
    end

    self.on('-c', '--noconsole',   'Build without debug messages(console.* calls)') do
       options[:noconsole] = true
    end

     self.on('-b', '--withdevblock', 'Build and extension with blocks of code for development purposes') do
        options[:withdevblock] = true
     end

	  end
	  args = ARGV
	  @options = options

  if !public_methods(false).map(&:to_s).include?(args[0])
  	puts "unknown command #{args.first}"
  else
  	run_command(args) unless args.empty?
  end
end

#run_command(args) ⇒ Object



50
51
52
# File 'lib/creng.rb', line 50

def run_command(args)
	self.send(*args)
end