Module: RoCommands::Generators::BaseGenerator::ClsMeths

Defined in:
lib/ro_commands/generators/base_generator.rb

Instance Method Summary collapse

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_fileObject



43
44
45
# File 'lib/ro_commands/generators/base_generator.rb', line 43

def created_file
  @created_file ||= lastest_file
end

#ctnObject



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_fileObject



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_pathObject



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

#openObject



39
40
41
# File 'lib/ro_commands/generators/base_generator.rb', line 39

def open
  bash "rubymine #{created_file}"
end

#pathObject



51
52
53
# File 'lib/ro_commands/generators/base_generator.rb', line 51

def path
  File.join(dir, file)
end

#toObject



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.expand_path("../templates/#{dir}.erb", __FILE__)
  @ctn = ERB.new(ctn).result(binding)
  to
end