Class: InternetHakai::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/internethakai/generator.rb

Constant Summary collapse

@@readline =
require 'readline'

Instance Method Summary collapse

Instance Method Details

#buildObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/internethakai/generator.rb', line 5

def build
    s = open(File::join(File::dirname(__FILE__), 'scenario.tmpl')){|io|io.read} 
    template = ERB::new(s)
    puts "your site\n    ex. http://example.com"
    if @@readline
        domain = Readline.readline("> ", true)
    else
        domain = gets
    end
    if(domain)
        domain.chomp!
        domain = 'http://' + domain unless /^https?:\/\// =~ domain
    else
        domain = 'http://example.com'
    end
    social = false
    data = template.result(binding)
    fname = 'scenario'
    idx = 0
    while(File::exists?(fname+"-#{idx}.yml"))
        idx += 1
    end
    fname = fname + "-#{idx}.yml"
    open(fname, 'w'){|io|io.write(data)}
    puts "save to #{fname}"
end