changelog_parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWZiZTQ4MTA5YzNmZjJlMTIwNjU5MDI3MDQ1NjdhYjljMjFiNWZiNw==
5
+ data.tar.gz: !binary |-
6
+ Y2NjMDM0M2Y0MTdkMGQzOGFkOWE4NThlYmZkMzk5OTM2NDc2MzQ2Yw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NmI5NDgwOTA2Zjg5ZjU5YTQ1NjY4ZjZiODVlMDBiNjY4YmJkZGJlZTQ1OGI0
10
+ MDU1MWUxYWM4N2U5NDBhZjVmM2Y3OTViNGJjOTBjODkwNTViMGE3ZmZiZDU1
11
+ OWM3OTYzMTQ2NWZmYmZlZmQ4MmYwNzEzNmNlYzk4NDY0ZWQ0N2U=
12
+ data.tar.gz: !binary |-
13
+ MTMzZGNiNDgwYjE0MDk4NDVmNTY5OGNjNjk1OWI3MTVhZDdmMmNjNGE2NTM1
14
+ YzEzODQ4NDNjMDhmODkxNWY2MzUyNGUzZTU1ZTNhMTFmOWQyMzQ2NGQzM2U3
15
+ NDkyNjUyZDlmMWZhZDdiNGIyY2UwMjNjYTI5ZDE5ODA3OTRhNTQ=
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "minitest", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "> 1.0.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ end
@@ -0,0 +1,53 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ builder (3.2.2)
6
+ faraday (0.8.9)
7
+ multipart-post (~> 1.2.0)
8
+ git (1.2.6)
9
+ github_api (0.10.1)
10
+ addressable
11
+ faraday (~> 0.8.1)
12
+ hashie (>= 1.2)
13
+ multi_json (~> 1.4)
14
+ nokogiri (~> 1.5.2)
15
+ oauth2
16
+ hashie (2.1.1)
17
+ highline (1.6.21)
18
+ jeweler (1.8.8)
19
+ builder
20
+ bundler (~> 1.0)
21
+ git (>= 1.2.5)
22
+ github_api (= 0.10.1)
23
+ highline (>= 1.6.15)
24
+ nokogiri (= 1.5.10)
25
+ rake
26
+ rdoc
27
+ json (1.8.1)
28
+ jwt (0.1.11)
29
+ multi_json (>= 1.5)
30
+ minitest (5.3.3)
31
+ multi_json (1.9.3)
32
+ multi_xml (0.5.5)
33
+ multipart-post (1.2.0)
34
+ nokogiri (1.5.10)
35
+ oauth2 (0.9.3)
36
+ faraday (>= 0.8, < 0.10)
37
+ jwt (~> 0.1.8)
38
+ multi_json (~> 1.3)
39
+ multi_xml (~> 0.5)
40
+ rack (~> 1.2)
41
+ rack (1.5.2)
42
+ rake (10.3.1)
43
+ rdoc (3.12.2)
44
+ json (~> 1.4)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ bundler (> 1.0.0)
51
+ jeweler (~> 1.8.4)
52
+ minitest
53
+ rdoc (~> 3.12)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 David Elbe
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.
@@ -0,0 +1,27 @@
1
+ = changelog_parser
2
+
3
+ A ruby gem for creating nice changelogs based on your git commits.
4
+
5
+ == Installation
6
+
7
+ `gem install changelog_parser`
8
+
9
+ == Usage
10
+
11
+ Just run `changelog` or `changelog true` in your git directory to print
12
+ out a changelog for the last two versions in your gem.
13
+
14
+ == Contributing to changelog_parser
15
+
16
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
17
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
18
+ * Fork the project.
19
+ * Start a feature/bugfix branch.
20
+ * Commit and push until you are happy with your contribution.
21
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
22
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
23
+
24
+ == Copyright
25
+
26
+ Copyright (c) 2014 David Elbe. See LICENSE.txt for
27
+ further details.
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "changelog_parser"
17
+ gem.homepage = "http://github.com/davidelbe/changelogparser"
18
+ gem.license = "MIT"
19
+ gem.summary = "A changelog parser/generator based on your git commits"
20
+ gem.description = "Use your git commit messages to create a changelog for your project"
21
+ gem.email = "david@elbe.me"
22
+ gem.authors = ["David Elbe"]
23
+ end
24
+ Jeweler::RubygemsDotOrgTasks.new
25
+
26
+ require 'rake/testtask'
27
+ Rake::TestTask.new(:test) do |test|
28
+ test.libs << 'lib' << 'test'
29
+ test.pattern = 'test/**/test_*.rb'
30
+ test.verbose = true
31
+ end
32
+
33
+ task :default => :test
34
+
35
+ require 'rdoc/task'
36
+ Rake::RDocTask.new do |rdoc|
37
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
38
+
39
+ rdoc.rdoc_dir = 'rdoc'
40
+ rdoc.title = "changelog_parser #{version}"
41
+ rdoc.rdoc_files.include('README*')
42
+ rdoc.rdoc_files.include('lib/**/*.rb')
43
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'changelog_parser'
3
+ ChangelogParser.new(*ARGV)
4
+ exit 0
@@ -0,0 +1,61 @@
1
+ class ChangelogParser
2
+ def initialize(all = false)
3
+ @all = all
4
+ read_log
5
+ parse_lines
6
+ end
7
+
8
+ def commit_parts_divider
9
+ "__END_OF_PART__"
10
+ end
11
+
12
+ def commit_message_divider
13
+ "__END_OF_COMMIT__\n"
14
+ end
15
+
16
+ def read_log
17
+ format = %w(%s %B %an).join(commit_parts_divider)
18
+ format << commit_message_divider
19
+ @log = `git log -n 100 --no-merges --format='#{format}'`
20
+ end
21
+
22
+ def log_to_lines
23
+ @log.split(commit_message_divider).collect{ |l| l.gsub("\n", " ") }
24
+ end
25
+
26
+ def parse_lines
27
+ self.log_to_lines.each do |line|
28
+ next if is_merge?(line)
29
+ if is_version_bump?(line)
30
+ print_version_bump(line)
31
+ else
32
+ print_changelog(line)
33
+ end
34
+ end
35
+ end
36
+
37
+ def is_merge?(line)
38
+ line =~ /Merge/
39
+ end
40
+
41
+ def is_version_bump?(line)
42
+ line =~ /Version bump to/ ? true : false
43
+ end
44
+
45
+ def print_version_bump(line)
46
+ puts "=== #{line.split(commit_parts_divider)[0].gsub("Version bump to", "").gsub(" ", " ")}"
47
+ end
48
+
49
+ def print_changelog(line)
50
+ commit_parts = line.split(commit_parts_divider)
51
+ author = commit_parts[2]
52
+ commit_message = commit_parts[1].to_s
53
+ changelog_message = commit_message.scan(/changelog:\s(.*)/i).flatten.first
54
+
55
+ if changelog_message
56
+ puts " * #{changelog_message.strip} - #{author}"
57
+ else
58
+ puts " * #{commit_message.strip} - #{author}" if @all
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'minitest'
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'minitest/unit'
12
+ require 'minitest/spec'
13
+ require 'minitest/autorun'
14
+
15
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ require 'changelog_parser'
18
+
19
+ class MiniTest::Unit::TestCase
20
+ end
21
+
22
+ MiniTest.autorun
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ describe ChangelogParser do
4
+
5
+ # TODO: add tests
6
+ # Just ported a working Rake task to a gem
7
+
8
+ describe 'version bumps' do
9
+ it 'handles version bumps' do
10
+ text = 'Version bump to 1.2.3'
11
+ cp = ChangelogParser.new()
12
+ cp.is_version_bump?(text).must_equal(true)
13
+ end
14
+
15
+ it 'does not return version bump for all lines' do
16
+ text = 'something else'
17
+ cp = ChangelogParser.new()
18
+ cp.is_version_bump?(text).must_equal(false)
19
+ end
20
+ end
21
+
22
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: changelog_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Elbe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>'
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>'
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.4
69
+ description: Use your git commit messages to create a changelog for your project
70
+ email: david@elbe.me
71
+ executables:
72
+ - changelog
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - LICENSE.txt
76
+ - README.rdoc
77
+ files:
78
+ - .document
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.rdoc
83
+ - Rakefile
84
+ - VERSION
85
+ - bin/changelog
86
+ - lib/changelog_parser.rb
87
+ - test/helper.rb
88
+ - test/test_changelogparser.rb
89
+ homepage: http://github.com/davidelbe/changelogparser
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: A changelog parser/generator based on your git commits
113
+ test_files: []