Class: Gitenv::Runner
- Inherits:
-
Object
- Object
- Gitenv::Runner
- Defined in:
- lib/gitenv.rb
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 |
# File 'lib/gitenv.rb', line 9 def initialize @home = File. '~' @config_file = File.join @home, '.gitenv.rb' end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/gitenv.rb', line 14 def run @dsl = DSL.new @dsl.instance_eval File.open(@config_file, 'r').read, @config_file action = ARGV.shift || 'info' puts puts "gitenv v#{VERSION}" puts "configuration #{@config_file}" puts case action when 'info' puts Paint["Listing current state", :bright, :bold] when 'update' puts Paint["Creating missing links", :blue, :bold] end @dsl.symlinks.each do |link| link_file_path = File.join @home, link[:file] real_file = link[:source] || link[:file] real_file_path = File.join File.(@dsl.repository), real_file msg = %/#{Paint[link_file_path, :cyan]} -> #{real_file_path}/ data = analyze link_file_path, real_file_path case action when 'info' puts %/#{info_mark data}#{msg} #{info_msg data}/ when 'update' unless File.exists? link_file_path File.symlink real_file_path, link_file_path end puts %/#{update_mark data}#{msg} #{update_msg data}/ else raise "No such action #{action}" end end puts end |