Class: LoquatCli

Inherits:
Thor
  • Object
show all
Defined in:
lib/loquat/cli.rb

Instance Method Summary collapse

Instance Method Details

#build(src) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/loquat/cli.rb', line 14

def build(src)
  # *.rb と同名の * ファイルを作成し、そこから起動する。

  # example.rb => example, example.exy

  # 同名の * ファイルの中身は起動に必要な処理

  exy = src.sub(/\..*/, ".exy")
  boot = src.sub(/\..*/, "")
  
  boot_src = File.expand_path( File.join(__FILE__, "..", "boot.erb") )
  open(boot, "w"){ |f| f.print ERB.new(IO.read(boot_src)).result(binding)  }

  Bat.exec "    call mkexy \#{boot} \#{src}\n    call loquat execlude_rubygems \#{exy}\n    call exerb \#{exy}\n    del \#{boot}\n  EOS\nend\n"

#execlude_rubygems(exy) ⇒ Object



33
34
35
36
37
# File 'lib/loquat/cli.rb', line 33

def execlude_rubygems(exy)
  h = YAML.load_file exy
  h["file"].reject!{|k,v| k.match(/^rubygems/) }
  open(exy,"w"){|f| f.print YAML.dump(h) }
end