39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'bin/inline_forms', line 39
def create(app_name)
def self.dry_run?
options[:dry]
end
def self.install_example?
options[:example]
end
def self.database
DATABASE_OPTIONS.include?(options[:database]) ? options[:database] : 'sqlite'
end
def self.using_sqlite?
database == 'sqlite'
end
def self.email
options[:email]
end
def self.password
options[:password]
end
if install_example? && dry_run?
say "--example and --dry-run can not be used together", :red
exit 1
end
if install_example? && !using_sqlite?
say "--example can only be used with an sqlite development database", :red
exit 1
end
say "This is a dry run. I hope you know what you are doing...", :red if dry_run?
say "Creating #{app_name} with inline_forms v#{VERSION} and development database #{database}...", :green
regex = /\A[0-9a-zA-Z][0-9a-zA-Z_-]+[0-9a-zA-Z]\Z/
if ! regex.match(app_name)
say "Error: APP must match #{regex.source}", :red
exit 1
end
if File.exists?(app_name)
say "Error: APP exists", :red
exit 1
end
if dry_run?
empty_directory(app_name)
else
empty_directory(app_name)
ruby_version = (%x[rvm current]).gsub(/@.*/,'')
create_file "#{app_name}/.ruby-version", ruby_version
create_file "#{app_name}/.ruby-gemset", app_name
app_template_file = File.join(File.dirname(__FILE__), 'inline_forms_app_template.rb')
if ! run("rails _3.2.12_ new #{app_name} -m #{app_template_file} --skip-bundle --skip-gemfile --skip-test-unit")
say "Rails could not create the app '#{app_name}', maybe because it is a reserved word...", :red
exit 1
end
end
end
|