Class: Temp::Runner
- Inherits:
-
Object
- Object
- Temp::Runner
- Defined in:
- lib/temp/runner.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#conf ⇒ Object
readonly
Returns the value of attribute conf.
-
#conf_file ⇒ Object
readonly
Returns the value of attribute conf_file.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #start! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/temp/runner.rb', line 10 def initialize( = {}) @conf_file = File.([:conf_file]) @conf = { :template_dir => '~/.temp' } @args = [:args] || {} if @conf_file && File.file?(@conf_file) @conf = YAML::load_file(@conf_file) else File.open(@conf_file, 'w') { |f| f.write(@conf.to_yaml) } end end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/temp/runner.rb', line 8 def args @args end |
#conf ⇒ Object (readonly)
Returns the value of attribute conf.
8 9 10 |
# File 'lib/temp/runner.rb', line 8 def conf @conf end |
#conf_file ⇒ Object (readonly)
Returns the value of attribute conf_file.
8 9 10 |
# File 'lib/temp/runner.rb', line 8 def conf_file @conf_file end |
Instance Method Details
#start! ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/temp/runner.rb', line 22 def start! OptionParser.new do |o| o. = 'Usage: temp [options] [project] [template]' o.on('-v', '--version', 'Show version information') do puts "Temp #{Temp::VERSION}" end end.parse!(@args) c = Temp::Copier.new(:template_dir => @conf[:template_dir]) if ARGV.size == 0 raise 'no project directory or template name specified' elsif ARGV.size == 1 c.create_project(ARGV[0]) else c.create_project(ARGV[0], ARGV[1]) end rescue => e puts e. end |