cory-rubyflashbake 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +4 -0
- data/lib/rubyflashbake/core.rb +12 -10
- data/lib/rubyflashbake/options.rb +8 -3
- data/lib/rubyflashbake/plugins/internet.rb +0 -1
- data/lib/rubyflashbake/plugins/location.rb +0 -1
- data/lib/rubyflashbake/plugins/time.rb +0 -1
- data/lib/rubyflashbake/plugins/twitter.rb +0 -1
- data/lib/rubyflashbake/plugins/weather.rb +0 -1
- data/spec/rspec_suite.rb +0 -1
- data/spec/rubyflashbake/core_spec.rb +47 -45
- data/spec/rubyflashbake/options_spec.rb +20 -1
- data/spec/rubyflashbake/testdata/testdir/.gitignore +0 -1
- metadata +3 -2
data/VERSION.yml
ADDED
data/lib/rubyflashbake/core.rb
CHANGED
@@ -46,11 +46,11 @@ class RubyFlashbake
|
|
46
46
|
else
|
47
47
|
if (@configuration[:GIT][:NAME] && @configuration[:GIT][:EMAIL])
|
48
48
|
Dir.chdir("#{dir}") do
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} init")
|
50
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} config user.name \"#{@configuration[:GIT][:NAME]}\"")
|
51
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} config user.email \"#{@configuration[:GIT][:EMAIL]}\"")
|
52
52
|
File.open(".gitignore", "w") do |file|
|
53
|
-
file.puts ".DS_Store\
|
53
|
+
file.puts ".DS_Store\n.message.tmp\n"
|
54
54
|
end
|
55
55
|
puts "Initialized git in #{dir}"
|
56
56
|
@configuration[:GIT_SETUP] = true
|
@@ -71,13 +71,15 @@ class RubyFlashbake
|
|
71
71
|
exit 1
|
72
72
|
end
|
73
73
|
unless @configuration[:GITHUB_SETUP] == true
|
74
|
-
|
74
|
+
if File.exists?("#{dir}/.git/config")
|
75
|
+
contents = File.read("#{dir}/.git/config")
|
76
|
+
end
|
75
77
|
if contents =~ /\[remote \"origin\"\]/
|
76
78
|
@configuration[:GITHUB_SETUP] = true
|
77
79
|
else
|
78
80
|
Dir.chdir("#{dir}") do
|
79
81
|
if !@configuration[:GITHUB_SETUP] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY]
|
80
|
-
|
82
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} remote add origin #{configuration[:GIT][:GITHUB_DATA][:GITHUB_URI]}:#{@configuration[:GIT][:GITHUB_DATA][:GITHUB_ID]}/#{@configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY]}.git")
|
81
83
|
puts "Initialized github in #{dir}"
|
82
84
|
@configuration[:GITHUB_SETUP] = true
|
83
85
|
else
|
@@ -88,7 +90,7 @@ class RubyFlashbake
|
|
88
90
|
end
|
89
91
|
end
|
90
92
|
Dir.chdir("#{dir}") do
|
91
|
-
|
93
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} pull origin master")
|
92
94
|
end
|
93
95
|
return true
|
94
96
|
end
|
@@ -97,11 +99,11 @@ class RubyFlashbake
|
|
97
99
|
if @configuration[:GIT_SETUP] == true
|
98
100
|
Dir.chdir("#{dir}") do
|
99
101
|
File.open(".message.tmp", "w") {|file| file.puts message}
|
100
|
-
|
101
|
-
|
102
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} add .")
|
103
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} commit -a --file=.message.tmp")
|
102
104
|
File.delete(".message.tmp")
|
103
105
|
if @configuration[:INTERNET_ALIVE] && @configuration[:GIT][:USE_GITHUB] && @configuration[:GITHUB_SETUP]
|
104
|
-
|
106
|
+
system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} push origin master")
|
105
107
|
end
|
106
108
|
end
|
107
109
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# options
|
4
3
|
# Copyright (c) 2009 Cory Ondrejka. All rights reserved.
|
5
4
|
# See License.txt for licensing details.
|
6
5
|
|
@@ -34,11 +33,17 @@ class RubyFlashbakeOptions
|
|
34
33
|
exit
|
35
34
|
end
|
36
35
|
|
37
|
-
opts.on("-
|
38
|
-
|
36
|
+
opts.on("-v", "--version", "Dump version number") do
|
37
|
+
yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. .. VERSION.yml])))
|
38
|
+
puts "rubyflashbake #{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
|
39
39
|
exit
|
40
40
|
end
|
41
41
|
|
42
|
+
opts.on("-h", "--help", "You're looking at it. Use --example to dump the config file.") do
|
43
|
+
puts opts
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
42
47
|
begin
|
43
48
|
opts.parse!(argv)
|
44
49
|
rescue OptionParser::ParseError => e
|
data/spec/rspec_suite.rb
CHANGED
@@ -6,17 +6,19 @@
|
|
6
6
|
require "#{File.dirname(__FILE__)}/../../lib/rubyflashbake/core"
|
7
7
|
|
8
8
|
describe RubyFlashbake do
|
9
|
+
before :all do
|
10
|
+
@testdirectory = "#{File.dirname(__FILE__)}/testdata/testdir"
|
11
|
+
end
|
12
|
+
|
9
13
|
before :each do
|
10
14
|
@stdout_orig = $stdout
|
11
15
|
$stdout = StringIO.new
|
12
|
-
FileUtils.rm_rf("#{
|
13
|
-
FileUtils.rm_rf("#{File.dirname(__FILE__)}/testdata/testdir/.git")
|
16
|
+
FileUtils.rm_rf("#{@testdirectory}/.git")
|
14
17
|
end
|
15
18
|
|
16
19
|
after :each do
|
17
20
|
$stdout = @stdout_orig
|
18
|
-
FileUtils.rm_rf("#{
|
19
|
-
FileUtils.rm_rf("#{File.dirname(__FILE__)}/testdata/testdir/.git")
|
21
|
+
FileUtils.rm_rf("#{@testdirectory}/.git")
|
20
22
|
end
|
21
23
|
|
22
24
|
it "should print error message and exit if config file isn't found" do
|
@@ -47,7 +49,7 @@ describe RubyFlashbake do
|
|
47
49
|
it "should exit if you try to examine git config without loading config file" do
|
48
50
|
begin
|
49
51
|
rfb = RubyFlashbake.new
|
50
|
-
rfb.configure_git("#{
|
52
|
+
rfb.configure_git("#{@testdirectory}")
|
51
53
|
rescue SystemExit => e
|
52
54
|
$stdout.string.should == "Configuration not loaded before trying to work with it\nPlease make sure code path loads configuration before trying to load plugins.\n"
|
53
55
|
e.status.should == 1
|
@@ -58,7 +60,7 @@ describe RubyFlashbake do
|
|
58
60
|
begin
|
59
61
|
rfb = RubyFlashbake.new
|
60
62
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
61
|
-
rfb.configure_git("#{
|
63
|
+
rfb.configure_git("#{@testdirectory}").should == false
|
62
64
|
rescue SystemExit => e
|
63
65
|
$stdout.string.should == "Can't configure git without git :NAME and :EMAIL configured in config file.\n"
|
64
66
|
e.status.should == 1
|
@@ -70,8 +72,8 @@ describe RubyFlashbake do
|
|
70
72
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
71
73
|
rfb.configuration[:GIT][:NAME] = "Test Monkey"
|
72
74
|
rfb.configuration[:GIT][:EMAIL] = "mokey@fake.fake"
|
73
|
-
rfb.configure_git("#{
|
74
|
-
$stdout.string.scan("Initialized
|
75
|
+
rfb.configure_git("#{@testdirectory}").should == true
|
76
|
+
$stdout.string.scan("Initialized git").should_not == []
|
75
77
|
end
|
76
78
|
|
77
79
|
it "should be able to call configure_git multiple times once git is setup" do
|
@@ -80,8 +82,8 @@ describe RubyFlashbake do
|
|
80
82
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
81
83
|
rfb.configuration[:GIT][:NAME] = "Test Monkey"
|
82
84
|
rfb.configuration[:GIT][:EMAIL] = "mokey@fake.fake"
|
83
|
-
rfb.configure_git("#{
|
84
|
-
rfb.configure_git("#{
|
85
|
+
rfb.configure_git("#{@testdirectory}").should == true
|
86
|
+
rfb.configure_git("#{@testdirectory}").should == true
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
@@ -91,9 +93,9 @@ describe RubyFlashbake do
|
|
91
93
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
92
94
|
rfb.configuration[:GIT][:NAME] = "Test Monkey"
|
93
95
|
rfb.configuration[:GIT][:EMAIL] = "mokey@fake.fake"
|
94
|
-
Dir.mkdir("#{
|
95
|
-
File.open("#{
|
96
|
-
rfb.configure_git("#{
|
96
|
+
Dir.mkdir("#{@testdirectory}/.git")
|
97
|
+
File.open("#{@testdirectory}/.git/config", "w") {|file| file.puts "foo!"}
|
98
|
+
rfb.configure_git("#{@testdirectory}").should == true
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
@@ -103,10 +105,10 @@ describe RubyFlashbake do
|
|
103
105
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
104
106
|
rfb.configuration[:GIT][:NAME] = "Test Monkey"
|
105
107
|
rfb.configuration[:GIT][:EMAIL] = "mokey@fake.fake"
|
106
|
-
rfb.configure_git("#{
|
107
|
-
rfb.configure_github("#{
|
108
|
+
rfb.configure_git("#{@testdirectory}")
|
109
|
+
rfb.configure_github("#{@testdirectory}")
|
108
110
|
rescue SystemExit => e
|
109
|
-
$stdout.string.should == "Initialized
|
111
|
+
$stdout.string.should == "Initialized git in ./spec/rubyflashbake/testdata/testdir\nCan't configure github without :GITHUB_URI, :GITHUB_ID, and :GITHUB_REPOSITORY configured in config file.\n"
|
110
112
|
e.status.should == 1
|
111
113
|
end
|
112
114
|
end
|
@@ -121,8 +123,8 @@ describe RubyFlashbake do
|
|
121
123
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] = "fake"
|
122
124
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY] = "fake"
|
123
125
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] = "git@github.com"
|
124
|
-
rfb.configure_git("#{
|
125
|
-
rfb.configure_github("#{
|
126
|
+
rfb.configure_git("#{@testdirectory}")
|
127
|
+
rfb.configure_github("#{@testdirectory}").should == true
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
@@ -136,7 +138,7 @@ describe RubyFlashbake do
|
|
136
138
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] = "fake"
|
137
139
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY] = "fake"
|
138
140
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] = "git@github.com"
|
139
|
-
rfb.configure_github("#{
|
141
|
+
rfb.configure_github("#{@testdirectory}")
|
140
142
|
rescue SystemExit => e
|
141
143
|
$stdout.string.should == "Trying to configure github without previous call to config_git.\n"
|
142
144
|
end
|
@@ -148,9 +150,9 @@ describe RubyFlashbake do
|
|
148
150
|
rfb.load_file("#{File.dirname(__FILE__)}/../../lib/data/.rubyflashbake_example")
|
149
151
|
rfb.configuration[:GIT][:NAME] = "Test Monkey"
|
150
152
|
rfb.configuration[:GIT][:EMAIL] = "mokey@fake.fake"
|
151
|
-
Dir.mkdir("#{
|
152
|
-
File.open("#{
|
153
|
-
rfb.configure_git("#{
|
153
|
+
Dir.mkdir("#{@testdirectory}/.git")
|
154
|
+
File.open("#{@testdirectory}/.git/config", "w") {|file| file.puts "[remote origin]"}
|
155
|
+
rfb.configure_git("#{@testdirectory}").should == true
|
154
156
|
end
|
155
157
|
end
|
156
158
|
|
@@ -164,9 +166,9 @@ describe RubyFlashbake do
|
|
164
166
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] = "fake"
|
165
167
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY] = "fake"
|
166
168
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] = "git@github.com"
|
167
|
-
rfb.configure_git("#{
|
168
|
-
rfb.configure_github("#{
|
169
|
-
rfb.configure_github("#{
|
169
|
+
rfb.configure_git("#{@testdirectory}")
|
170
|
+
rfb.configure_github("#{@testdirectory}").should == true
|
171
|
+
rfb.configure_github("#{@testdirectory}").should == true
|
170
172
|
end
|
171
173
|
end
|
172
174
|
|
@@ -208,11 +210,11 @@ describe RubyFlashbake do
|
|
208
210
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] = "git@github.com"
|
209
211
|
rfb.configuration[:DIRECTORY_MONITOR_INTERVAL] = 1
|
210
212
|
rfb.configuration[:STABLE_INTERVALS] = 1
|
211
|
-
rfb.configure_git("#{
|
212
|
-
rfb.configure_github("#{
|
213
|
+
rfb.configure_git("#{@testdirectory}")
|
214
|
+
rfb.configure_github("#{@testdirectory}")
|
213
215
|
rfb.load_plugins
|
214
216
|
output = ""
|
215
|
-
rfb.setup_directory_watchers("#{
|
217
|
+
rfb.setup_directory_watchers("#{@testdirectory}") do |events, basedir, func|
|
216
218
|
events.each do |event|
|
217
219
|
if event.type == :stable
|
218
220
|
output += "#{basedir} #{event}\n#{func}"
|
@@ -220,13 +222,13 @@ describe RubyFlashbake do
|
|
220
222
|
end
|
221
223
|
end
|
222
224
|
rfb.start_directory_watchers
|
223
|
-
File.open("#{
|
224
|
-
File.open("#{
|
225
|
+
File.open("#{@testdirectory}/temp.txt", "w") {|file| file.puts "foo!"}
|
226
|
+
File.open("#{@testdirectory}/temp2.txt", "w") {|file| file.puts "foo!"}
|
225
227
|
sleep(10)
|
226
|
-
File.open("#{
|
227
|
-
File.delete("#{
|
228
|
-
File.delete("#{
|
229
|
-
File.delete("#{
|
228
|
+
File.open("#{@testdirectory}/temp3.txt", "w") {|file| file.puts "foo!"}
|
229
|
+
File.delete("#{@testdirectory}/temp3.txt")
|
230
|
+
File.delete("#{@testdirectory}/temp2.txt")
|
231
|
+
File.delete("#{@testdirectory}/temp.txt")
|
230
232
|
|
231
233
|
output.scan(/temp\.txt/).should_not == []
|
232
234
|
output.scan(/temp2\.txt/).should_not == []
|
@@ -246,19 +248,19 @@ describe RubyFlashbake do
|
|
246
248
|
rfb.configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] = "git@github.com"
|
247
249
|
rfb.configuration[:DIRECTORY_MONITOR_INTERVAL] = 1
|
248
250
|
rfb.configuration[:STABLE_INTERVALS] = 1
|
249
|
-
rfb.configure_git("#{
|
250
|
-
rfb.configure_github("#{
|
251
|
+
rfb.configure_git("#{@testdirectory}")
|
252
|
+
rfb.configure_github("#{@testdirectory}")
|
251
253
|
rfb.load_plugins
|
252
254
|
|
253
|
-
rfb.setup_watch_commits("#{
|
255
|
+
rfb.setup_watch_commits("#{@testdirectory}")
|
254
256
|
|
255
257
|
rfb.start_directory_watchers
|
256
|
-
File.open("#{
|
257
|
-
File.open("#{
|
258
|
+
File.open("#{@testdirectory}/temp.txt", "w") {|file| file.puts "foo!"}
|
259
|
+
File.open("#{@testdirectory}/temp2.txt", "w") {|file| file.puts "foo!"}
|
258
260
|
sleep(10)
|
259
|
-
File.open("#{
|
260
|
-
File.open("#{
|
261
|
-
File.delete("#{
|
261
|
+
File.open("#{@testdirectory}/temp3.txt", "w") {|file| file.puts "foo!"}
|
262
|
+
File.open("#{@testdirectory}/temp3.txt", "a") {|file| file.puts "bar!"}
|
263
|
+
File.delete("#{@testdirectory}/temp2.txt")
|
262
264
|
sleep(10)
|
263
265
|
|
264
266
|
rfb.stop_directory_watchers
|
@@ -266,13 +268,13 @@ describe RubyFlashbake do
|
|
266
268
|
status = ""
|
267
269
|
log = ""
|
268
270
|
|
269
|
-
Dir.chdir("#{
|
271
|
+
Dir.chdir("#{@testdirectory}") do
|
270
272
|
status = `git status`
|
271
273
|
log = `git log`
|
272
274
|
end
|
273
275
|
|
274
|
-
File.delete("#{
|
275
|
-
File.delete("#{
|
276
|
+
File.delete("#{@testdirectory}/temp3.txt")
|
277
|
+
File.delete("#{@testdirectory}/temp.txt")
|
276
278
|
|
277
279
|
status.should == "# On branch master\nnothing to commit (working directory clean)\n"
|
278
280
|
log.scan(/commit/).length.should == 2
|
@@ -10,7 +10,8 @@ RubyFlashbakeOptionHelp = <<-EOF
|
|
10
10
|
Usage: rubyflashbake [ options ]
|
11
11
|
-c, --config [file] Use config file [file]
|
12
12
|
-e, --example Dump an example, annotated config file to stdout and exit
|
13
|
-
-
|
13
|
+
-v, --version Dump version number
|
14
|
+
-h, --help You're looking at it. Use --example to dump the config file.
|
14
15
|
EOF
|
15
16
|
|
16
17
|
describe RubyFlashbakeOptions do
|
@@ -43,6 +44,24 @@ describe RubyFlashbakeOptions do
|
|
43
44
|
RubyFlashbakeOptions.new(["--config", "foo"]).test([:config_file => "foo"]).should == true
|
44
45
|
end
|
45
46
|
|
47
|
+
it "should dump version and exit if -v option given" do
|
48
|
+
begin
|
49
|
+
RubyFlashbakeOptions.new(["-v"])
|
50
|
+
rescue SystemExit => e
|
51
|
+
$stdout.string.scan(/\d+\.\d+\.\d+/).should_not == []
|
52
|
+
e.status.should == 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should dump version and exit if -v option given" do
|
57
|
+
begin
|
58
|
+
RubyFlashbakeOptions.new(["--version"])
|
59
|
+
rescue SystemExit => e
|
60
|
+
$stdout.string.scan(/\d+\.\d+\.\d+/).should_not == []
|
61
|
+
e.status.should == 0
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
46
65
|
it "should print out help when -h is requested or not input" do
|
47
66
|
begin
|
48
67
|
RubyFlashbakeOptions.new(["-h"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cory-rubyflashbake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cory Ondrejka
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
13
|
default_executable: rubyflashbake
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- License.txt
|
35
35
|
- README.rdoc
|
36
36
|
- README.textile
|
37
|
+
- VERSION.yml
|
37
38
|
- spec/rspec_suite.rb
|
38
39
|
- spec/rubyflashbake/core_spec.rb
|
39
40
|
- spec/rubyflashbake/options_spec.rb
|