my-simon 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/simon +9 -1
- data/lib/simon.rb +78 -2
- data/my-simon.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/bin/simon
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
1
|
+
#!/usr/bin/env ruby -v=false -W0
|
2
2
|
# encoding: utf-8
|
3
|
+
## $VERBOSE
|
4
|
+
## -W0 NO Warnings nil
|
5
|
+
## -W1 Quiet false
|
6
|
+
## -W2 Verbose true
|
7
|
+
BEGIN { $VERBOSE = nil }
|
3
8
|
|
4
9
|
# resolve bin path, ignoring symlinks
|
5
10
|
require "pathname"
|
6
11
|
bin_file = Pathname.new(__FILE__).realpath
|
7
12
|
$:.unshift File.expand_path("../../lib", bin_file)
|
8
13
|
|
14
|
+
|
9
15
|
require 'simon'
|
10
16
|
require 'rubygems'
|
11
17
|
require 'commander/import'
|
@@ -52,6 +58,8 @@ command :add do |c|
|
|
52
58
|
simon_controller.msg "installing heroku files"
|
53
59
|
when 'section'
|
54
60
|
simon_controller.add_section
|
61
|
+
when 'repo'
|
62
|
+
simon_controller.setup_beanstalk
|
55
63
|
end
|
56
64
|
end
|
57
65
|
end
|
data/lib/simon.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
require 'commander/import'
|
4
|
+
require 'beanstalkapp'
|
5
|
+
|
3
6
|
class Simon
|
4
7
|
|
5
8
|
def rename
|
@@ -47,13 +50,25 @@ class Simon
|
|
47
50
|
cmd = "find . -type f -name '*.tpl' -exec sed -i '' s/CHANGE_ME/#{@nms}/g {} +"
|
48
51
|
Kernel::system(cmd)
|
49
52
|
|
50
|
-
|
53
|
+
# database setup
|
51
54
|
choice = choose("Setup Local DB?", :yes, :no)
|
52
55
|
|
53
56
|
if choice === :yes
|
54
|
-
|
57
|
+
|
58
|
+
self.setup_db
|
59
|
+
|
55
60
|
end
|
56
61
|
|
62
|
+
# google analytics id
|
63
|
+
choice = choose("Do you want to set the Google Analytics tracking id?", :yes, :no)
|
64
|
+
|
65
|
+
if choice === :yes
|
66
|
+
|
67
|
+
self.setup_analytics
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
|
57
72
|
self.msg 'Setup complete!'
|
58
73
|
self.make_hidden
|
59
74
|
self.complete
|
@@ -114,10 +129,71 @@ class Simon
|
|
114
129
|
|
115
130
|
end
|
116
131
|
|
132
|
+
|
133
|
+
def setup_db
|
134
|
+
|
135
|
+
# self.check_hidden
|
136
|
+
|
137
|
+
host = ask("What is the DB host? : ") { |q| q.echo = true }
|
138
|
+
username = ask("What is the DB Username? : ") { |q| q.echo = true }
|
139
|
+
password = ask("What is the DB password? : ") { |q| q.echo = true }
|
140
|
+
dbname = ask("What is the DB name? : ") { |q| q.echo = true }
|
141
|
+
|
142
|
+
config = "./app/www/lib/php/system/Config.php"
|
143
|
+
self.replace_once(config, "%l_host%", host)
|
144
|
+
self.replace_once(config, "%l_user%", username)
|
145
|
+
self.replace_once(config, "%l_pass%", password)
|
146
|
+
self.replace_once(config, "%l_dbname%", dbname)
|
147
|
+
|
148
|
+
self.msg "#{config} modified"
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
def setup_analytics
|
153
|
+
tracking_id = ask("What is the GA tracking ID? : ") { |q| q.echo = true }
|
154
|
+
config = "./app/www/lib/php/system/Config.php"
|
155
|
+
self.replace_once(config, "%google_id%", tracking_id);
|
156
|
+
self.msg "#{config} modified"
|
157
|
+
end
|
158
|
+
|
117
159
|
def replace_once(file_name, search_string, replace_string)
|
118
160
|
text = File.read(file_name)
|
119
161
|
new_text = text.gsub(search_string, replace_string)
|
120
162
|
File.open(file_name, "w") {|file| file.puts new_text}
|
121
163
|
end
|
122
164
|
|
165
|
+
def setup_beanstalk
|
166
|
+
subdomain = ask("What is the Beanstalk subdomain? : ") { |q| q.echo = true }
|
167
|
+
username = ask("What is your Beanstalk Username? : ") { |q| q.echo = true }
|
168
|
+
password = ask("What is your Beanstalk password? : ") { |q| q.echo = true }
|
169
|
+
repo_name = ask("What do you want to call this repo? : ") { |q| q.echo = true }
|
170
|
+
|
171
|
+
@repo_name = repo_name.gsub(/[^0-9A-Za-z-]/, '')
|
172
|
+
|
173
|
+
choice = choose("What kind of repo?", :git, :subversion,:mercurial);
|
174
|
+
|
175
|
+
if choice == :git
|
176
|
+
choice = "git"
|
177
|
+
elsif choice == :subversion
|
178
|
+
choice = "subversion"
|
179
|
+
elsif choice == :mercurial
|
180
|
+
choice = "mercurial"
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
Beanstalk::API::Base.setup(
|
185
|
+
:domain => subdomain,
|
186
|
+
:login => username,
|
187
|
+
:password => password
|
188
|
+
)
|
189
|
+
query = {'name' => @repo_name, 'type_id' => choice, 'title' => @repo_name, 'color_label' => 'label-blue'}
|
190
|
+
|
191
|
+
response = Beanstalk::API::Repository::create(query)
|
192
|
+
|
193
|
+
self.msg "git clone #{response.repository_url}"
|
194
|
+
|
195
|
+
self.complete
|
196
|
+
|
197
|
+
end
|
198
|
+
|
123
199
|
end
|
data/my-simon.gemspec
CHANGED