herodotus 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/CHANGES +12 -1
- data/README.md +20 -7
- data/lib/herodotus.rb +1 -0
- data/lib/herodotus/collector.rb +2 -2
- data/lib/herodotus/configuration.rb +22 -0
- data/lib/herodotus/git.rb +4 -4
- data/lib/herodotus/reporter.rb +1 -1
- data/lib/herodotus/tasks.rb +12 -8
- data/lib/herodotus/version.rb +1 -1
- data/spec/collector_spec.rb +27 -23
- data/spec/configuration_spec.rb +22 -0
- data/spec/git_spec.rb +33 -24
- data/spec/reporter_spec.rb +10 -5
- data/tmp/.keep +0 -0
- metadata +9 -4
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGES
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
-
v0.0.
|
1
|
+
v0.0.2 [2011-07-29]
|
2
|
+
-------------------
|
3
|
+
2011-07-29 Harold Giménez <hgimenez@thoughtbot.com>
|
4
|
+
Introduces ability to configure Herodotus. Here's an example on how to
|
5
|
+
configure it:
|
2
6
|
|
7
|
+
Herodotus::Configuration.run do |config|
|
8
|
+
config.base_path = '/path/to/project/root'
|
9
|
+
config.changelog_filename = 'CHANGELOG.md'
|
10
|
+
end
|
11
|
+
|
12
|
+
v0.0.1 [2011-07-28]
|
13
|
+
-------------------
|
3
14
|
2011-07-23 Harold Giménez <hgimenez@thoughtbot.com>
|
4
15
|
Including "Changelog:" in the commit message will mark
|
5
16
|
that commit as available for the changelog, and will use all text
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
Herodotus
|
2
2
|
---------
|
3
3
|
|
4
|
+
[![Build Status](http://travis-ci.org/hgimenez/herodotus.png)](http://travis-ci.org/hgimenez/herodotus)
|
5
|
+
|
4
6
|
Herodotus, an ancient greek historian and story teller will
|
5
7
|
help you keep a changelog updated.
|
6
8
|
|
@@ -16,7 +18,7 @@ communicate what should go in the changelog. Here are the rules:
|
|
16
18
|
|
17
19
|
* Tag every release, so that it is easy to tell Herodotus how far back to start
|
18
20
|
looking for changes.
|
19
|
-
* To start writing notes for use in the changelog, use the following format on
|
21
|
+
* To start writing notes for use in the changelog, use the following format on
|
20
22
|
your git commit message:
|
21
23
|
|
22
24
|
|
@@ -30,11 +32,11 @@ Anything below this line will go on the changelog. Tell your users how to
|
|
30
32
|
upgrade the app, what has been depracated, what will break, etc.
|
31
33
|
```
|
32
34
|
|
33
|
-
It doesn't need to be exact either. Herodotus will simply extract these
|
34
|
-
comments, format them by adding the author and date, and either append them to
|
35
|
-
your CHANGES file, or print them out to standard out. Once it's there you can
|
36
|
-
tweak it at will before pushing. But the important pieces have been thought out
|
37
|
-
at the time when you wrote the software changes - and was written right on the
|
35
|
+
It doesn't need to be exact either. Herodotus will simply extract these
|
36
|
+
comments, format them by adding the author and date, and either append them to
|
37
|
+
your CHANGES file, or print them out to standard out. Once it's there you can
|
38
|
+
tweak it at will before pushing. But the important pieces have been thought out
|
39
|
+
at the time when you wrote the software changes - and was written right on the
|
38
40
|
commit message, and so maintaining the changelog could be easier.
|
39
41
|
|
40
42
|
## Installation
|
@@ -47,7 +49,7 @@ Then add `require 'herodotus/tasks'` to your `Rakefile`. This will provide the r
|
|
47
49
|
|
48
50
|
## Usage
|
49
51
|
|
50
|
-
Herodotus provides a couple of rake tasks:
|
52
|
+
Herodotus provides a couple of rake tasks:
|
51
53
|
|
52
54
|
```
|
53
55
|
rake -T
|
@@ -57,3 +59,14 @@ rake herodotus:print[since_ref] # Prints out the change log from git
|
|
57
59
|
|
58
60
|
You can optionally pass the reference (usually a tag) from which herodotus will start to look for changelog messages in your commits.
|
59
61
|
Note that some shells require you to wrap the rake task in double quotes when passing arguments. For example: `rake "herodotus:print[v1]"`
|
62
|
+
|
63
|
+
## Configuring
|
64
|
+
|
65
|
+
You can configure Herodotus. Drop this somewhere sensible like an initializer or anywhere where it loads prior to running the rake tasks:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Herodotus::Configuration.run do |config|
|
69
|
+
config.base_path = '/path/to/project/root'
|
70
|
+
config.changelog_filename = 'CHANGELOG.md'
|
71
|
+
end
|
72
|
+
```
|
data/lib/herodotus.rb
CHANGED
data/lib/herodotus/collector.rb
CHANGED
@@ -3,8 +3,8 @@ module Herodotus
|
|
3
3
|
attr_accessor :git, :since_ref, :changes, :changelog_filename
|
4
4
|
CHANGES_REGEX = /changelog.*?\n(.*)/mi.freeze
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@git = Git.new(
|
6
|
+
def initialize(base_path, since_ref = nil)
|
7
|
+
@git = Git.new(base_path)
|
8
8
|
@since_ref = since_ref
|
9
9
|
@changes = []
|
10
10
|
find_changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Herodotus
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :base_path, :changelog_filename
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@changelog_filename = 'CHANGES'
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :config
|
11
|
+
end
|
12
|
+
@config = Configuration.new
|
13
|
+
|
14
|
+
def self.run
|
15
|
+
yield config
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.reset!
|
19
|
+
self.config = Configuration.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/herodotus/git.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Herodotus
|
2
2
|
class Git
|
3
|
-
attr_accessor :repo
|
4
|
-
def initialize(
|
5
|
-
@
|
3
|
+
attr_accessor :repo, :base_path
|
4
|
+
def initialize(base_path = nil)
|
5
|
+
@base_path = base_path || Configuration.config.base_path
|
6
6
|
@repo = Grit::Repo.new(guess_repo)
|
7
7
|
end
|
8
8
|
|
@@ -17,7 +17,7 @@ module Herodotus
|
|
17
17
|
|
18
18
|
private
|
19
19
|
def guess_repo
|
20
|
-
current_dir = File.expand_path(@
|
20
|
+
current_dir = File.expand_path(@base_path)
|
21
21
|
until current_dir == '/' do
|
22
22
|
maybe_repo = File.expand_path(".git", current_dir)
|
23
23
|
if File.directory?(maybe_repo)
|
data/lib/herodotus/reporter.rb
CHANGED
data/lib/herodotus/tasks.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'herodotus'
|
3
3
|
|
4
|
-
def default_base_dir
|
5
|
-
File.expand_path(File.dirname(__FILE__))
|
6
|
-
end
|
7
|
-
|
8
4
|
namespace :herodotus do
|
5
|
+
def default_base_path
|
6
|
+
File.expand_path(File.dirname(__FILE__))
|
7
|
+
end
|
8
|
+
|
9
|
+
def configured_base_path
|
10
|
+
Herodotus::Configuration.config.base_path
|
11
|
+
end
|
12
|
+
|
9
13
|
desc 'Prints out the change log from git'
|
10
14
|
task :print, :since_ref do |t, args|
|
11
|
-
|
12
|
-
Herodotus::Collector.new(
|
15
|
+
base_path = ENV['base_path'] || configured_base_path || default_base_path
|
16
|
+
Herodotus::Collector.new(base_path, args['since_ref']).
|
13
17
|
print
|
14
18
|
end
|
15
19
|
|
16
20
|
desc 'Appends changes to your changelog'
|
17
21
|
task :append, :since_ref do |t, args|
|
18
|
-
|
19
|
-
Herodotus::Collector.new(
|
22
|
+
base_path = ENV['base_path'] || configured_base_path || default_base_path
|
23
|
+
Herodotus::Collector.new(base_path, args['since_ref']).
|
20
24
|
append_to_changelog
|
21
25
|
end
|
22
26
|
end
|
data/lib/herodotus/version.rb
CHANGED
data/spec/collector_spec.rb
CHANGED
@@ -4,23 +4,6 @@ describe Herodotus::Collector do
|
|
4
4
|
def collector
|
5
5
|
@collector ||= Herodotus::Collector.new('/tmp/herodotus')
|
6
6
|
end
|
7
|
-
before do
|
8
|
-
FileUtils.mkdir_p '/tmp/herodotus'
|
9
|
-
FileUtils.cd '/tmp/herodotus' do
|
10
|
-
`git init`
|
11
|
-
`touch file1`
|
12
|
-
`git add file1`
|
13
|
-
`git commit -m "this is a change"`
|
14
|
-
`touch file2`
|
15
|
-
`git add file2`
|
16
|
-
`git commit -m "Another\nChAnGeLOg:\nBroke everything again. Don't update to this version."`
|
17
|
-
`touch file3`
|
18
|
-
`git add file3`
|
19
|
-
`git commit -m "Another\nchangelog:\nNevermind, everything is fixed now."`
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
after { FileUtils.rm_rf '/tmp/herodotus' }
|
24
7
|
|
25
8
|
it 'starts off with a default git, changes and a since_ref of nil' do
|
26
9
|
collector.git.wont_be_nil
|
@@ -28,12 +11,6 @@ describe Herodotus::Collector do
|
|
28
11
|
collector.changes.wont_be_nil
|
29
12
|
end
|
30
13
|
|
31
|
-
it 'finds commits containing the changelog keyword on the message' do
|
32
|
-
collector.changes.length.must_equal 2
|
33
|
-
collector.changes.first.message.must_equal "Broke everything again. Don't update to this version."
|
34
|
-
collector.changes.last.message.must_equal "Nevermind, everything is fixed now."
|
35
|
-
end
|
36
|
-
|
37
14
|
it 'tells the reporter to print' do
|
38
15
|
reporter = mock('reporter')
|
39
16
|
collector.stubs(:reporter).returns(reporter)
|
@@ -47,4 +24,31 @@ describe Herodotus::Collector do
|
|
47
24
|
reporter.expects(:append_to_changelog).once
|
48
25
|
collector.append_to_changelog
|
49
26
|
end
|
27
|
+
|
28
|
+
describe 'with some commits' do
|
29
|
+
before do
|
30
|
+
FileUtils.mkdir_p '/tmp/herodotus'
|
31
|
+
FileUtils.cd '/tmp/herodotus' do
|
32
|
+
`git init`
|
33
|
+
`touch file1`
|
34
|
+
`git add file1`
|
35
|
+
`git commit -m "this is a change"`
|
36
|
+
`touch file2`
|
37
|
+
`git add file2`
|
38
|
+
`git commit -m "Another\nChAnGeLOg:\nBroke everything again. Don't update to this version."`
|
39
|
+
`touch file3`
|
40
|
+
`git add file3`
|
41
|
+
`git commit -m "Another\nchangelog:\nNevermind, everything is fixed now."`
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
after { FileUtils.rm_rf '/tmp/herodotus' }
|
46
|
+
|
47
|
+
it 'finds commits containing the changelog keyword on the message' do
|
48
|
+
collector.changes.length.must_equal 2
|
49
|
+
collector.changes.first.message.must_equal "Broke everything again. Don't update to this version."
|
50
|
+
collector.changes.last.message.must_equal "Nevermind, everything is fixed now."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
50
54
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Herodotus::Configuration do
|
4
|
+
|
5
|
+
before { Herodotus::Configuration.reset! }
|
6
|
+
|
7
|
+
%w(base_path changelog_filename).each do |configurable|
|
8
|
+
it "allows you to configure a #{configurable}" do
|
9
|
+
Herodotus::Configuration.run do |config|
|
10
|
+
config.must_be_kind_of Herodotus::Configuration
|
11
|
+
config.send("#{configurable}=", 'foo')
|
12
|
+
end
|
13
|
+
|
14
|
+
Herodotus::Configuration.config.send(configurable).must_equal 'foo'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has a default changelog filename of CHANGES' do
|
20
|
+
Herodotus::Configuration.config.changelog_filename.must_equal 'CHANGES'
|
21
|
+
end
|
22
|
+
end
|
data/spec/git_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
-
require 'ruby-debug'
|
3
2
|
|
4
3
|
describe Herodotus::Git do
|
5
4
|
|
@@ -7,34 +6,44 @@ describe Herodotus::Git do
|
|
7
6
|
@git ||= Herodotus::Git.new('/tmp/herodotus/bacon')
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
`git init`
|
14
|
-
`touch file`
|
15
|
-
`git add file`
|
16
|
-
`git commit -m "Added file"`
|
17
|
-
`git tag -a v1 -m "the MVP"`
|
18
|
-
`touch file2`
|
19
|
-
`git add file2`
|
20
|
-
`git commit -m "Added file2"`
|
21
|
-
FileUtils.mkdir_p 'bacon'
|
9
|
+
it 'uses the configured base_path if none is provided' do
|
10
|
+
Herodotus::Configuration.run do |config|
|
11
|
+
config.base_path = 'foo'
|
22
12
|
end
|
23
|
-
end
|
24
13
|
|
25
|
-
|
26
|
-
FileUtils.rm_rf '/tmp/herodotus'
|
14
|
+
Herodotus::Git.new.base_path.must_equal 'foo'
|
27
15
|
end
|
28
16
|
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
describe 'with some commits' do
|
18
|
+
before do
|
19
|
+
FileUtils.mkdir_p '/tmp/herodotus'
|
20
|
+
FileUtils.cd '/tmp/herodotus' do
|
21
|
+
`git init`
|
22
|
+
`touch file`
|
23
|
+
`git add file`
|
24
|
+
`git commit -m "Added file"`
|
25
|
+
`git tag -a v1 -m "the MVP"`
|
26
|
+
`touch file2`
|
27
|
+
`git add file2`
|
28
|
+
`git commit -m "Added file2"`
|
29
|
+
FileUtils.mkdir_p 'bacon'
|
30
|
+
end
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
after do
|
34
|
+
FileUtils.rm_rf '/tmp/herodotus'
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
it 'locates the closest git repo' do
|
38
|
+
git.repo.path.must_equal '/tmp/herodotus/.git'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'pulls out commits from the repo' do
|
42
|
+
git.commits.map(&:message).must_equal ['Added file2', 'Added file']
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'pulls out commits since a given ref' do
|
46
|
+
git.commits('v1').map(&:message).must_equal ['Added file2']
|
47
|
+
end
|
39
48
|
end
|
40
49
|
end
|
data/spec/reporter_spec.rb
CHANGED
@@ -28,11 +28,6 @@ describe Herodotus::Reporter do
|
|
28
28
|
reporter.collector.must_equal collector
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'has a default changelog filename of CHANGES' do
|
32
|
-
reporter = Herodotus::Reporter.new(collector)
|
33
|
-
reporter.changelog_filename.must_equal 'CHANGES'
|
34
|
-
end
|
35
|
-
|
36
31
|
it 'appends changelog entries to the changelog file' do
|
37
32
|
reporter = Herodotus::Reporter.new(collector)
|
38
33
|
reporter.changelog_filename = File.expand_path('tmp/test_changes')
|
@@ -40,5 +35,15 @@ describe Herodotus::Reporter do
|
|
40
35
|
changelog = IO.read(reporter.changelog_filename)
|
41
36
|
changelog.must_include "Broke everything again. Don't update to this version."
|
42
37
|
changelog.must_include "Nevermind, everything is fixed now."
|
38
|
+
FileUtils.rm_rf 'tmp/test_changes'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'uses the configured changelog_filename' do
|
42
|
+
Herodotus::Configuration.run do |config|
|
43
|
+
config.changelog_filename = 'los cambios van aqui!'
|
44
|
+
end
|
45
|
+
|
46
|
+
reporter = Herodotus::Reporter.new('base dir')
|
47
|
+
reporter.changelog_filename.must_equal 'los cambios van aqui!'
|
43
48
|
end
|
44
49
|
end
|
data/tmp/.keep
ADDED
File without changes
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: herodotus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Harold Gim\xC3\xA9nez"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-29 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -80,6 +80,7 @@ extra_rdoc_files: []
|
|
80
80
|
files:
|
81
81
|
- .gitignore
|
82
82
|
- .rvmrc
|
83
|
+
- .travis.yml
|
83
84
|
- CHANGES
|
84
85
|
- Gemfile
|
85
86
|
- README.md
|
@@ -87,14 +88,17 @@ files:
|
|
87
88
|
- herodotus.gemspec
|
88
89
|
- lib/herodotus.rb
|
89
90
|
- lib/herodotus/collector.rb
|
91
|
+
- lib/herodotus/configuration.rb
|
90
92
|
- lib/herodotus/git.rb
|
91
93
|
- lib/herodotus/reporter.rb
|
92
94
|
- lib/herodotus/tasks.rb
|
93
95
|
- lib/herodotus/version.rb
|
94
96
|
- spec/collector_spec.rb
|
97
|
+
- spec/configuration_spec.rb
|
95
98
|
- spec/git_spec.rb
|
96
99
|
- spec/reporter_spec.rb
|
97
100
|
- spec/spec_helper.rb
|
101
|
+
- tmp/.keep
|
98
102
|
has_rdoc: true
|
99
103
|
homepage: ""
|
100
104
|
licenses: []
|
@@ -109,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
113
|
requirements:
|
110
114
|
- - ">="
|
111
115
|
- !ruby/object:Gem::Version
|
112
|
-
hash:
|
116
|
+
hash: 4363217657516253176
|
113
117
|
segments:
|
114
118
|
- 0
|
115
119
|
version: "0"
|
@@ -118,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
122
|
requirements:
|
119
123
|
- - ">="
|
120
124
|
- !ruby/object:Gem::Version
|
121
|
-
hash:
|
125
|
+
hash: 4363217657516253176
|
122
126
|
segments:
|
123
127
|
- 0
|
124
128
|
version: "0"
|
@@ -131,6 +135,7 @@ specification_version: 3
|
|
131
135
|
summary: The father of your project's history
|
132
136
|
test_files:
|
133
137
|
- spec/collector_spec.rb
|
138
|
+
- spec/configuration_spec.rb
|
134
139
|
- spec/git_spec.rb
|
135
140
|
- spec/reporter_spec.rb
|
136
141
|
- spec/spec_helper.rb
|