blammo 0.1.1 → 0.2.0
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 +1 -1
- data/bin/{blammo → blam} +0 -0
- data/lib/blammo.rb +3 -0
- data/lib/blammo/changelog.rb +31 -0
- data/lib/blammo/cli.rb +10 -49
- data/spec/blammo/changelog_spec.rb +27 -0
- data/spec/blammo/cli_spec.rb +0 -24
- data/templates/changelog.markdown.erb +8 -1
- metadata +10 -7
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.2.0
|
data/bin/{blammo → blam}
RENAMED
|
File without changes
|
data/lib/blammo.rb
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module Blammo
|
|
4
|
+
class Changelog
|
|
5
|
+
attr_accessor :releases
|
|
6
|
+
|
|
7
|
+
def initialize(path)
|
|
8
|
+
@path = path.to_fancypath
|
|
9
|
+
@releases = @path.exists? ? YAML.load_file(@path) : []
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def update
|
|
13
|
+
commits = Git.commits(@path.dir, last_sha)
|
|
14
|
+
|
|
15
|
+
unless commits.empty?
|
|
16
|
+
release = Time.now.strftime("%Y%m%d%H%M%S")
|
|
17
|
+
releases.unshift(release => commits)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
@releases.to_yaml(open(@path, "w"))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def last_sha
|
|
24
|
+
return if @releases.empty?
|
|
25
|
+
release = @releases.first
|
|
26
|
+
commits = release.first.last
|
|
27
|
+
commit = commits.detect {|commit| commit.is_a?(Hash)}
|
|
28
|
+
commit ? commit.first.first : nil
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/blammo/cli.rb
CHANGED
|
@@ -1,60 +1,21 @@
|
|
|
1
|
-
require 'erb'
|
|
2
|
-
require 'fancypath'
|
|
3
1
|
require 'thor'
|
|
4
2
|
require 'tilt'
|
|
5
|
-
require 'yaml'
|
|
6
3
|
|
|
7
4
|
module Blammo
|
|
8
5
|
class CLI < Thor
|
|
9
|
-
CHANGELOG_FILE_NAME = "changelog.yml"
|
|
10
|
-
|
|
11
6
|
desc "generate [PATH]", "Generates a changelog.yml file"
|
|
12
|
-
def generate(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
last_sha = self.class.find_last_sha(releases)
|
|
17
|
-
commits = Git.commits(repo_path, last_sha)
|
|
18
|
-
|
|
19
|
-
unless commits.empty?
|
|
20
|
-
release = Time.now.strftime("%Y%m%d%H%M%S")
|
|
21
|
-
|
|
22
|
-
releases.unshift(release => commits)
|
|
23
|
-
releases.to_yaml(open(changelog_path, "w"))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
puts releases.to_yaml
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc "render PATH", "Renders the given changelog.yml file"
|
|
30
|
-
def render(path)
|
|
31
|
-
releases = YAML.load_file(path)
|
|
32
|
-
|
|
33
|
-
releases.each do |release_hash|
|
|
34
|
-
release, groups = release_hash.first
|
|
35
|
-
puts release
|
|
36
|
-
|
|
37
|
-
groups.each do |group_hash|
|
|
38
|
-
group, commits = group_hash
|
|
39
|
-
puts " " + group
|
|
40
|
-
|
|
41
|
-
commits.each do |commit_hash|
|
|
42
|
-
sha, message = commit_hash.first
|
|
43
|
-
puts " " + message
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
template = Tilt.new(File.expand_path("../../templates/changelog.markdown.erb", __FILE__))
|
|
49
|
-
puts template.render(nil, :date => Date.today)
|
|
7
|
+
def generate(path = "changelog.yml")
|
|
8
|
+
changelog = Changelog.new(path)
|
|
9
|
+
changelog.update
|
|
10
|
+
puts changelog.releases.to_yaml
|
|
50
11
|
end
|
|
51
12
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
13
|
+
desc "render [PATH]", "Renders the given changelog.yml file"
|
|
14
|
+
def render(path = "changelog.yml")
|
|
15
|
+
changelog = Changelog.new(path)
|
|
16
|
+
template_path = __FILE__.to_fancypath.dir / "../../templates/changelog.markdown.erb".to_fancypath
|
|
17
|
+
template = Tilt.new(template_path)
|
|
18
|
+
puts template.render(nil, :changelog => changelog)
|
|
58
19
|
end
|
|
59
20
|
end
|
|
60
21
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
CHANGELOG_PATH = __FILE__.to_fancypath.dir / "../fixtures/changelog.yml"
|
|
4
|
+
|
|
5
|
+
describe Blammo::Changelog do
|
|
6
|
+
describe ".last_sha" do
|
|
7
|
+
context "with no releases" do
|
|
8
|
+
before do
|
|
9
|
+
@changelog = Blammo::Changelog.new("foobar.yml")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should return nil" do
|
|
13
|
+
@changelog.last_sha.should be_nil
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "with a release" do
|
|
18
|
+
before do
|
|
19
|
+
@changelog = Blammo::Changelog.new(CHANGELOG_PATH)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should return the SHA of the last commit" do
|
|
23
|
+
@changelog.last_sha.should == "867b20e695e2b3770e150b0e844cdb6addd48ba4"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/spec/blammo/cli_spec.rb
CHANGED
|
@@ -12,28 +12,4 @@ describe Blammo::CLI do
|
|
|
12
12
|
pending
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
|
-
|
|
16
|
-
describe ".find_last_sha" do
|
|
17
|
-
context "with no releases" do
|
|
18
|
-
it "should return nil" do
|
|
19
|
-
Blammo::CLI.find_last_sha([]).should be_nil
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "with a release" do
|
|
24
|
-
before do
|
|
25
|
-
@sha = "3b183d9d1ec270fc63ef54695db1cd2df5d597cf"
|
|
26
|
-
@releases = [
|
|
27
|
-
{"20100424175354" => [
|
|
28
|
-
"foo bar",
|
|
29
|
-
{@sha => "lorem ipsum"}
|
|
30
|
-
]}
|
|
31
|
-
]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should return the SHA of the last commit" do
|
|
35
|
-
Blammo::CLI.find_last_sha(@releases).should == @sha
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
15
|
end
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<% changelog.releases.each do |release_hash| %>
|
|
4
|
+
<% release, commits = release_hash.first %>
|
|
5
|
+
## <%= release %>
|
|
6
|
+
<% commits.each do |commit_hash| %>
|
|
7
|
+
<% sha, message = commit_hash.first %>
|
|
8
|
+
* <%= message %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
metadata
CHANGED
|
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
version: 0.
|
|
7
|
+
- 2
|
|
8
|
+
- 0
|
|
9
|
+
version: 0.2.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Josh Bassett
|
|
@@ -14,8 +14,8 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-04-
|
|
18
|
-
default_executable:
|
|
17
|
+
date: 2010-04-30 00:00:00 +10:00
|
|
18
|
+
default_executable: blam
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
@@ -128,7 +128,7 @@ dependencies:
|
|
|
128
128
|
description: " Changelog generator.\n"
|
|
129
129
|
email: josh.bassett@gmail.com
|
|
130
130
|
executables:
|
|
131
|
-
-
|
|
131
|
+
- blam
|
|
132
132
|
extensions: []
|
|
133
133
|
|
|
134
134
|
extra_rdoc_files:
|
|
@@ -140,11 +140,13 @@ files:
|
|
|
140
140
|
- README.md
|
|
141
141
|
- Rakefile
|
|
142
142
|
- VERSION
|
|
143
|
-
- bin/
|
|
143
|
+
- bin/blam
|
|
144
144
|
- lib/blammo.rb
|
|
145
145
|
- lib/blammo/alone.rb
|
|
146
|
+
- lib/blammo/changelog.rb
|
|
146
147
|
- lib/blammo/cli.rb
|
|
147
148
|
- lib/blammo/git.rb
|
|
149
|
+
- spec/blammo/changelog_spec.rb
|
|
148
150
|
- spec/blammo/cli_spec.rb
|
|
149
151
|
- spec/blammo/git_spec.rb
|
|
150
152
|
- spec/spec.opts
|
|
@@ -181,6 +183,7 @@ signing_key:
|
|
|
181
183
|
specification_version: 3
|
|
182
184
|
summary: CHANGELOG from Blammo.
|
|
183
185
|
test_files:
|
|
186
|
+
- spec/blammo/changelog_spec.rb
|
|
184
187
|
- spec/blammo/cli_spec.rb
|
|
185
188
|
- spec/blammo/git_spec.rb
|
|
186
189
|
- spec/spec_helper.rb
|