cory-rubyflashbake 0.1.5 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,42 @@
1
- = rubyflashbake
1
+ = RubyFlashbake
2
2
 
3
- A Ruby project inspired by Thomas Gideon's python Flashbake project.
3
+ A Ruby project inspired by Thomas Gideon's python "Flashbake":http://wiki.github.com/commandline/flashbake project.
4
4
 
5
- == Copyright
5
+ == What it is
6
6
 
7
- Copyright (c) 2009 Cory Ondrejka. See LICENSE for details.
7
+ Automatically checks in files from watched directories to git and github with time, location, weather, and recent twitter comments in the commit comments.
8
+
9
+ == "But, why?" you ask
10
+
11
+ I thought that Flashbake was a very cool project, but since I spend time in the Ruby world - and do more blogging than writing - converting it to Ruby seemed like a fun weekend project. Plus, I wanted to experiment with monitoring directories, building an app that works well with small Ruby plugins, and do some web scraping.
12
+
13
+ As always, it's all about writing snippets of fun code.
14
+
15
+ == Use
16
+
17
+ Run "rubyflashbake --example" in the directory you want to watch to dump the configuration file. Fill in as needed and then launch rubyflashbake and enjoy automatic git and github commits with lots of fun location and web aware commit comments. Bask in joy.
18
+
19
+ == License
20
+
21
+ Copyright (c) 2009 Cory Ondrejka
22
+
23
+ Permission is hereby granted, free of charge, to any person
24
+ obtaining a copy of this software and associated documentation
25
+ files (the "Software"), to deal in the Software without
26
+ restriction, including without limitation the rights to use,
27
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
28
+ copies of the Software, and to permit persons to whom the
29
+ Software is furnished to do so, subject to the following
30
+ conditions:
31
+
32
+ The above copyright notice and this permission notice shall be
33
+ included in all copies or substantial portions of the Software.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
37
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
39
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
40
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
41
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -4,7 +4,7 @@ A Ruby project inspired by Thomas Gideon's python "Flashbake":http://wiki.github
4
4
 
5
5
  h2. What it is
6
6
 
7
- A set of routines to help with writing and blogging.
7
+ Automatically checks in files from watched directories to git and github with time, location, weather, and recent twitter comments in the commit comments.
8
8
 
9
9
  h2. "But, why?" you ask
10
10
 
@@ -12,6 +12,10 @@ I thought that Flashbake was a very cool project, but since I spend time in the
12
12
 
13
13
  As always, it's all about writing snippets of fun code.
14
14
 
15
+ h2. Use
16
+
17
+ Run "rubyflashbake --example" in the directory you want to watch to dump the configuration file. Fill in as needed and then launch rubyflashbake and enjoy automatic git and github commits with lots of fun location and web aware commit comments. Bask in joy.
18
+
15
19
  h2. License
16
20
 
17
21
  Copyright (c) 2009 Cory Ondrejka
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 5
4
+ :patch: 8
@@ -45,16 +45,14 @@ class RubyFlashbake
45
45
  @configuration[:GIT_SETUP] = true
46
46
  else
47
47
  if (@configuration[:GIT][:NAME] && @configuration[:GIT][:EMAIL])
48
- Dir.chdir("#{dir}") do
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
- File.open(".gitignore", "w") do |file|
53
- file.puts ".DS_Store\n.message.tmp\n"
54
- end
55
- puts "Initialized git in #{dir}"
56
- @configuration[:GIT_SETUP] = true
48
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} init`
49
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} config user.name \"#{@configuration[:GIT][:NAME]}\"`
50
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} config user.email \"#{@configuration[:GIT][:EMAIL]}\"`
51
+ File.open("#{dir}/.gitignore", "w") do |file|
52
+ file.puts ".DS_Store\n.message.tmp\n"
57
53
  end
54
+ puts "Initialized git in #{dir}"
55
+ @configuration[:GIT_SETUP] = true
58
56
  else
59
57
  puts "Can't configure git without git :NAME and :EMAIL configured in config file."
60
58
  exit 1
@@ -77,34 +75,28 @@ class RubyFlashbake
77
75
  if contents =~ /\[remote \"origin\"\]/
78
76
  @configuration[:GITHUB_SETUP] = true
79
77
  else
80
- Dir.chdir("#{dir}") do
81
- if !@configuration[:GITHUB_SETUP] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY]
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")
83
- puts "Initialized github in #{dir}"
84
- @configuration[:GITHUB_SETUP] = true
85
- else
86
- puts "Can't configure github without :GITHUB_URI, :GITHUB_ID, and :GITHUB_REPOSITORY configured in config file."
87
- exit 1
88
- end
78
+ if !@configuration[:GITHUB_SETUP] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_URI] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_ID] && @configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY]
79
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} remote add origin #{configuration[:GIT][:GITHUB_DATA][:GITHUB_URI]}:#{@configuration[:GIT][:GITHUB_DATA][:GITHUB_ID]}/#{@configuration[:GIT][:GITHUB_DATA][:GITHUB_REPOSITORY]}.git`
80
+ puts "Initialized github in #{dir}"
81
+ @configuration[:GITHUB_SETUP] = true
82
+ else
83
+ puts "Can't configure github without :GITHUB_URI, :GITHUB_ID, and :GITHUB_REPOSITORY configured in config file."
84
+ exit 1
89
85
  end
90
86
  end
91
87
  end
92
- Dir.chdir("#{dir}") do
93
- system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} pull origin master")
94
- end
88
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} pull origin master`
95
89
  return true
96
90
  end
97
91
 
98
92
  def git_commit(dir, message)
99
93
  if @configuration[:GIT_SETUP] == true
100
- Dir.chdir("#{dir}") do
101
- File.open(".message.tmp", "w") {|file| file.puts message}
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")
104
- File.delete(".message.tmp")
105
- if @configuration[:INTERNET_ALIVE] && @configuration[:GIT][:USE_GITHUB] && @configuration[:GITHUB_SETUP]
106
- system("git --git-dir=#{Dir.pwd}/.git --work-tree=#{Dir.pwd} push origin master")
107
- end
94
+ File.open("#{dir}/.message.tmp", "w") {|file| file.puts message}
95
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} add .`
96
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} commit -a --file=.message.tmp`
97
+ File.delete("#{dir}/.message.tmp")
98
+ if @configuration[:INTERNET_ALIVE] && @configuration[:GIT][:USE_GITHUB] && @configuration[:GITHUB_SETUP]
99
+ $stderr.puts `git --git-dir=#{dir}/.git --work-tree=#{dir} push origin master`
108
100
  end
109
101
  end
110
102
  end
@@ -7,18 +7,22 @@ require "#{File.dirname(__FILE__)}/../../lib/rubyflashbake/core"
7
7
 
8
8
  describe RubyFlashbake do
9
9
  before :all do
10
- @testdirectory = "#{File.dirname(__FILE__)}/testdata/testdir"
10
+ @testdirectory = "#{File.dirname(__FILE__)}/../../../rubyflashbake_testing"
11
+ ENV["GIT_DIR"] = nil
12
+ ENV["GIT_WORK_TREE"] = nil
13
+ ENV["GIT_INDEX_FILE"] = nil
11
14
  end
12
15
 
13
16
  before :each do
14
17
  @stdout_orig = $stdout
15
18
  $stdout = StringIO.new
16
- FileUtils.rm_rf("#{@testdirectory}/.git")
19
+ FileUtils.rm_rf("#{@testdirectory}")
20
+ FileUtils.mkdir("#{@testdirectory}")
17
21
  end
18
22
 
19
23
  after :each do
20
24
  $stdout = @stdout_orig
21
- FileUtils.rm_rf("#{@testdirectory}/.git")
25
+ FileUtils.rm_rf("#{@testdirectory}")
22
26
  end
23
27
 
24
28
  it "should print error message and exit if config file isn't found" do
@@ -108,7 +112,7 @@ describe RubyFlashbake do
108
112
  rfb.configure_git("#{@testdirectory}")
109
113
  rfb.configure_github("#{@testdirectory}")
110
114
  rescue SystemExit => e
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"
115
+ $stdout.string.should == "Initialized git in ./spec/rubyflashbake/../../../rubyflashbake_testing\nCan't configure github without :GITHUB_URI, :GITHUB_ID, and :GITHUB_REPOSITORY configured in config file.\n"
112
116
  e.status.should == 1
113
117
  end
114
118
  end
@@ -268,15 +272,12 @@ describe RubyFlashbake do
268
272
  status = ""
269
273
  log = ""
270
274
 
271
- Dir.chdir("#{@testdirectory}") do
272
- status = `git status`
273
- log = `git log`
274
- end
275
-
276
- File.delete("#{@testdirectory}/temp3.txt")
277
- File.delete("#{@testdirectory}/temp.txt")
275
+ status = `git --git-dir=#{@testdirectory}/.git --work-tree=#{@testdirectory} status`
276
+ $stderr.puts "status: #{status}"
277
+ log = `git --git-dir=#{@testdirectory}/.git --work-tree=#{@testdirectory} log`
278
+ $stderr.puts "log: #{log}"
278
279
 
279
- status.should == "# On branch master\nnothing to commit (working directory clean)\n"
280
+ status.scan(/nothing to commit/).should_not == []
280
281
  log.scan(/commit/).length.should == 2
281
282
  end
282
283
  end
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.5
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Ondrejka
@@ -43,7 +43,6 @@ files:
43
43
  - spec/rubyflashbake/plugins/time_spec.rb
44
44
  - spec/rubyflashbake/plugins/twitter_spec.rb
45
45
  - spec/rubyflashbake/plugins/weather_spec.rb
46
- - spec/rubyflashbake/testdata/testdir/.gitignore
47
46
  has_rdoc: false
48
47
  homepage: http://cory.github.com
49
48
  post_install_message:
@@ -1,2 +0,0 @@
1
- .DS_Store
2
- .message.tmp