pig 0.0.2
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/.document +5 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/.rvmrc +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +72 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/lib/generators/pig/pig_generator.rb +14 -0
- data/lib/pig.rb +40 -0
- data/pig.gemspec +65 -0
- data/spec/pig_spec.rb +61 -0
- data/spec/spec_helper.rb +8 -0
- metadata +128 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
dependencies:
|
3
|
+
rspec-core:
|
4
|
+
group:
|
5
|
+
- :test
|
6
|
+
version: = 2.0.0.beta.17
|
7
|
+
ruby-debug:
|
8
|
+
group:
|
9
|
+
- :development
|
10
|
+
- :test
|
11
|
+
version: = 0.10.3
|
12
|
+
shoulda:
|
13
|
+
group:
|
14
|
+
- :test
|
15
|
+
version: = 2.11.1
|
16
|
+
rspec:
|
17
|
+
group:
|
18
|
+
- :test
|
19
|
+
version: = 2.0.0.beta.17
|
20
|
+
rspec-expectations:
|
21
|
+
group:
|
22
|
+
- :test
|
23
|
+
version: = 2.0.0.beta.17
|
24
|
+
rspec-rails:
|
25
|
+
group:
|
26
|
+
- :test
|
27
|
+
version: = 2.0.0.beta.17
|
28
|
+
git:
|
29
|
+
group:
|
30
|
+
- :default
|
31
|
+
version: = 1.2.5
|
32
|
+
rspec-mocks:
|
33
|
+
group:
|
34
|
+
- :test
|
35
|
+
version: = 2.0.0.beta.17
|
36
|
+
specs:
|
37
|
+
- columnize:
|
38
|
+
version: 0.3.1
|
39
|
+
- diff-lcs:
|
40
|
+
version: 1.1.2
|
41
|
+
- git:
|
42
|
+
version: 1.2.5
|
43
|
+
- linecache:
|
44
|
+
version: "0.43"
|
45
|
+
- nokogiri:
|
46
|
+
version: 1.4.3.1
|
47
|
+
- rack:
|
48
|
+
version: 1.2.1
|
49
|
+
- rack-test:
|
50
|
+
version: 0.5.4
|
51
|
+
- rspec-core:
|
52
|
+
version: 2.0.0.beta.17
|
53
|
+
- rspec-expectations:
|
54
|
+
version: 2.0.0.beta.17
|
55
|
+
- rspec-mocks:
|
56
|
+
version: 2.0.0.beta.17
|
57
|
+
- rspec:
|
58
|
+
version: 2.0.0.beta.17
|
59
|
+
- webrat:
|
60
|
+
version: 0.7.1
|
61
|
+
- rspec-rails:
|
62
|
+
version: 2.0.0.beta.17
|
63
|
+
- ruby-debug-base:
|
64
|
+
version: 0.10.3
|
65
|
+
- ruby-debug:
|
66
|
+
version: 0.10.3
|
67
|
+
- shoulda:
|
68
|
+
version: 2.11.1
|
69
|
+
hash: 4084f90b2306051a10d4282e7577b7acc97a8284
|
70
|
+
sources:
|
71
|
+
- Rubygems:
|
72
|
+
uri: http://rubygems.org
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jim Remsik
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= pig
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Jim Remsik. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "pig"
|
8
|
+
gem.summary = %Q{A rack endpoint to view the latest commits in the running version.}
|
9
|
+
gem.description = %Q{A rack endpoint to dynamically view the latest N formatted commits. Pig takes its name from the classic story of the chicken and the pig. Many versions of this idea exist as jokes or anecdotes wherein the two decide to start a restaurant named Ham-n-Eggs. Ultimately, the pig chooses not to participate because he would be committed and the chicken merely involved.}
|
10
|
+
gem.email = "bigtiger@hashrocket.com"
|
11
|
+
gem.homepage = "http://github.com/bigtiger/pig"
|
12
|
+
gem.authors = ["Jim Remsik"]
|
13
|
+
gem.add_dependency "git", "= 1.2.5"
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
gem.add_development_dependency "yard", ">= 0"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/lib/pig.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
class Pig
|
4
|
+
|
5
|
+
WORKING_DIR = File.join(File.dirname(File.expand_path(__FILE__)), "..")
|
6
|
+
NUMBER_OF_COMMITS = 10
|
7
|
+
|
8
|
+
def root_dir
|
9
|
+
if defined? Rails
|
10
|
+
Rails.root
|
11
|
+
else
|
12
|
+
WORKING_DIR
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def repository
|
17
|
+
Git.open(root_dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def history
|
21
|
+
results = ""
|
22
|
+
commits = repository.log(NUMBER_OF_COMMITS) || []
|
23
|
+
commits.each do |commit|
|
24
|
+
results << format(commit)
|
25
|
+
end
|
26
|
+
results
|
27
|
+
end
|
28
|
+
|
29
|
+
def format(commit)
|
30
|
+
"#{commit.to_s} #{commit.author.date.strftime("%Y-%m-%d")} #{commit.author.name}\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(env)
|
34
|
+
rack_response_template << [history]
|
35
|
+
end
|
36
|
+
|
37
|
+
def rack_response_template
|
38
|
+
[200, {"Content-Type" => "text/plain"}]
|
39
|
+
end
|
40
|
+
end
|
data/pig.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{pig}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jim Remsik"]
|
12
|
+
s.date = %q{2010-08-03}
|
13
|
+
s.description = %q{A rack endpoint to dynamically view the latest N formatted commits. Pig takes its name from the classic story of the chicken and the pig. Many versions of this idea exist as jokes or anecdotes wherein the two decide to start a restaurant named Ham-n-Eggs. Ultimately, the pig chooses not to participate because he would be committed and the chicken merely involved.}
|
14
|
+
s.email = %q{bigtiger@hashrocket.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
".rspec",
|
23
|
+
".rvmrc",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"lib/generators/pig/pig_generator.rb",
|
31
|
+
"lib/pig.rb",
|
32
|
+
"pig.gemspec",
|
33
|
+
"spec/pig_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = %q{http://github.com/bigtiger/pig}
|
37
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = %q{1.3.7}
|
40
|
+
s.summary = %q{A rack endpoint to view the latest commits in the running version.}
|
41
|
+
s.test_files = [
|
42
|
+
"spec/pig_spec.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<git>, ["= 1.2.5"])
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
53
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<git>, ["= 1.2.5"])
|
56
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
57
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
58
|
+
end
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<git>, ["= 1.2.5"])
|
61
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/spec/pig_spec.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pig do
|
4
|
+
|
5
|
+
let(:pig) { Pig.new }
|
6
|
+
|
7
|
+
describe "#call" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
pig.stub(:history).and_return('some text')
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns a valid rack response" do
|
14
|
+
pig.call(:any_environment).should == [200, {"Content-Type" => "text/plain"}, ['some text']]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#format" do
|
20
|
+
|
21
|
+
let(:commit) { stub(:author => author, :to_s => "393932") }
|
22
|
+
let(:author) { stub(:date => date, :name => "Dev Author") }
|
23
|
+
let(:date) { stub(:strftime => "12-31-01") }
|
24
|
+
|
25
|
+
it "returns the sha1, date, and author by default" do
|
26
|
+
pig.format(commit).should == "393932 12-31-01 Dev Author\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#repository" do
|
32
|
+
|
33
|
+
it "calls Git.open on the specified working directory" do
|
34
|
+
Git.should_receive(:open, Pig::WORKING_DIR)
|
35
|
+
pig.repository
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#history" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
repo = stub(:log)
|
44
|
+
pig.stub(:repository).and_return(repo)
|
45
|
+
repo.stub(:log, 10).and_return([])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "retrieves a log of the last 10 commits by default" do
|
49
|
+
repo = stub(:log)
|
50
|
+
pig.should_receive(:repository).and_return(repo)
|
51
|
+
repo.should_receive(:log, 10).and_return([])
|
52
|
+
pig.history
|
53
|
+
end
|
54
|
+
|
55
|
+
it "returns an empty string if no commits are found" do
|
56
|
+
pig.history.should == ""
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jim Remsik
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-03 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: git
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 2
|
33
|
+
- 5
|
34
|
+
version: 1.2.5
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 13
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 2
|
49
|
+
- 9
|
50
|
+
version: 1.2.9
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: yard
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: A rack endpoint to dynamically view the latest N formatted commits. Pig takes its name from the classic story of the chicken and the pig. Many versions of this idea exist as jokes or anecdotes wherein the two decide to start a restaurant named Ham-n-Eggs. Ultimately, the pig chooses not to participate because he would be committed and the chicken merely involved.
|
68
|
+
email: bigtiger@hashrocket.com
|
69
|
+
executables: []
|
70
|
+
|
71
|
+
extensions: []
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE
|
75
|
+
- README.rdoc
|
76
|
+
files:
|
77
|
+
- .document
|
78
|
+
- .gitignore
|
79
|
+
- .rspec
|
80
|
+
- .rvmrc
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE
|
84
|
+
- README.rdoc
|
85
|
+
- Rakefile
|
86
|
+
- VERSION
|
87
|
+
- lib/generators/pig/pig_generator.rb
|
88
|
+
- lib/pig.rb
|
89
|
+
- pig.gemspec
|
90
|
+
- spec/pig_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/bigtiger/pig
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --charset=UTF-8
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
109
|
+
version: "0"
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: A rack endpoint to view the latest commits in the running version.
|
126
|
+
test_files:
|
127
|
+
- spec/pig_spec.rb
|
128
|
+
- spec/spec_helper.rb
|