Module: RoCommands::Generators::BaseGenerator::ClsMeths
- Defined in:
- lib/ro_commands/generators/base_generator.rb
Instance Method Summary collapse
- #bash(*cmds) ⇒ Object
- #created_file ⇒ Object
- #ctn ⇒ Object
- #file_write(path) ⇒ Object
- #lastest_file ⇒ Object
- #lib_path ⇒ Object
- #open ⇒ Object
- #path ⇒ Object
- #to ⇒ Object
- #tt(name) ⇒ Object
Instance Method Details
#bash(*cmds) ⇒ Object
14 15 16 |
# File 'lib/ro_commands/generators/base_generator.rb', line 14 def bash(*cmds) Kernel.system(cmds.flatten.join(" && ")) end |
#created_file ⇒ Object
43 44 45 |
# File 'lib/ro_commands/generators/base_generator.rb', line 43 def created_file @created_file ||= lastest_file end |
#ctn ⇒ Object
47 48 49 |
# File 'lib/ro_commands/generators/base_generator.rb', line 47 def ctn @ctn ||= "" end |
#file_write(path) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/ro_commands/generators/base_generator.rb', line 18 def file_write(path) dir = File.dirname(path) FileUtils.mkpath dir puts "writing #{path}" File.write(path, ctn) end |
#lastest_file ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ro_commands/generators/base_generator.rb', line 31 def lastest_file Find.find(Dir.pwd, dir).select do |f| test(?f, f) end.sort_by do |f| Time.at(File.ctime(f).to_f) end.last end |
#lib_path ⇒ Object
25 26 27 28 29 |
# File 'lib/ro_commands/generators/base_generator.rb', line 25 def lib_path name.split("::").map do |i| i.downcase end.join("/") end |
#open ⇒ Object
39 40 41 |
# File 'lib/ro_commands/generators/base_generator.rb', line 39 def open bash "rubymine #{created_file}" end |
#path ⇒ Object
51 52 53 |
# File 'lib/ro_commands/generators/base_generator.rb', line 51 def path File.join(dir, file) end |
#to ⇒ Object
55 56 57 |
# File 'lib/ro_commands/generators/base_generator.rb', line 55 def to puts "writing to #{path}" end |
#tt(name) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/ro_commands/generators/base_generator.rb', line 59 def tt(name) puts "creating #{path}" ctn = File.read File.("../templates/#{dir}.erb", __FILE__) @ctn = ERB.new(ctn).result(binding) to end |