vandamme 0.0.1
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/.gitignore +17 -0
- data/Changelog.md +3 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +6 -0
- data/lib/vandamme.rb +6 -0
- data/lib/vandamme/parser.rb +45 -0
- data/lib/vandamme/version.rb +3 -0
- data/spec/fixtures/json.md +8 -0
- data/spec/fixtures/postmark-gem.rdoc +27 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/vandamme/parser_spec.rb +71 -0
- data/vandamme.gemspec +19 -0
- metadata +64 -0
data/.gitignore
ADDED
data/Changelog.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Philippe Lafoucrière
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Vandamme
|
2
|
+
|
3
|
+
[](https://gemnasium.com/tech-angels/vandamme)
|
4
|
+
|
5
|
+
Vandamme is a changelog parser gem, used in the [Gemnasium project](https://gemnasium.com)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'vandamme'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install vandamme
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
The Parser initializer will use 3 options:
|
24
|
+
|
25
|
+
* **:changelog**: full raw content of the changelog file
|
26
|
+
* **:version_header_exp**: regexp to match the versions lines in changelog
|
27
|
+
* **:format** (*optional*): if you want to use the html converter, you must provide the original format of the changelog
|
28
|
+
|
29
|
+
## Examples
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'rubygems'
|
33
|
+
require 'vandamme'
|
34
|
+
require 'open-uri'
|
35
|
+
changelog = open('https://raw.github.com/flori/json/master/CHANGES').read
|
36
|
+
parser = Vandamme::Parser.new(changelog: changelog, version_header_exp: '\d{4}-\d{2}-\d{2} \((\d\.\d+\.\d+)\)', format: 'markdown')
|
37
|
+
parser.parse
|
38
|
+
```
|
39
|
+
will return a hash with each version as keys, and version content as value.
|
40
|
+
The hash can be converted to html (using the [github-markup](https://github.com/github/markup) gem):
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
parser.to_html
|
44
|
+
```
|
45
|
+
|
46
|
+
Vandamme is bundled with Redcarpet by default (for markdown), you must add the necessary gems to your bundle if you want to handle more formats.
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/vandamme.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'github/markup'
|
3
|
+
|
4
|
+
module Vandamme
|
5
|
+
class Parser
|
6
|
+
|
7
|
+
# Create a new changelog parser
|
8
|
+
#
|
9
|
+
# Options:
|
10
|
+
# * +changelog+: uri of file to be parsed
|
11
|
+
# * +version_header_exp+: regexp to match the starting line of version
|
12
|
+
# * +format+: (optional). One of "raw", "markdown", "rdoc"
|
13
|
+
#
|
14
|
+
def initialize(options={})
|
15
|
+
@changelog = options.fetch :changelog
|
16
|
+
@version_header_exp = Regexp.new(/#{options.fetch :version_header_exp}/)
|
17
|
+
@format = options[:format] || :raw
|
18
|
+
@changelog_hash = {}
|
19
|
+
end
|
20
|
+
|
21
|
+
# Parse changelog file, filling +@changelog_hash+ with
|
22
|
+
# versions as keys, and version changelog as content.
|
23
|
+
#
|
24
|
+
def parse
|
25
|
+
@changelog.scan(@version_header_exp) do
|
26
|
+
version_content = $~.post_match
|
27
|
+
changelog_scanner = StringScanner.new(version_content)
|
28
|
+
changelog_scanner.scan_until(@version_header_exp)
|
29
|
+
@changelog_hash[$1]= (changelog_scanner.pre_match || version_content).gsub(/^\n+/, '')
|
30
|
+
end
|
31
|
+
@changelog_hash
|
32
|
+
end
|
33
|
+
|
34
|
+
# Convert @changelog_hash content to html using GitHub::Markup.
|
35
|
+
# The +@format+ is used to determine the input format (should be one of:
|
36
|
+
# "rdoc", "md", 'markdown", "raw", etc.)
|
37
|
+
# See https://github.com/github/markup/blob/master/lib/github/markups.rb
|
38
|
+
# for more formats. The corresponding gem must be bundled.
|
39
|
+
def to_html
|
40
|
+
self.parse if @changelog_hash.empty?
|
41
|
+
# GitHub Markup API is really weird, we MUST pass a file name for format detection:
|
42
|
+
@changelog_hash.inject({}) { |h,(k,v)| h[k] = GitHub::Markup.render(".#{@format}", v); h }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
2012-11-29 (1.7.6)
|
2
|
+
* Add GeneratorState#merge alias for JRuby, fix state accessor methods. Thx to
|
3
|
+
jvshahid@github.
|
4
|
+
* Increase hash likeness of state objects.
|
5
|
+
2012-08-17 (1.7.5)
|
6
|
+
* Fix compilation of extension on older rubies.
|
7
|
+
2012-07-26 (1.7.4)
|
8
|
+
* Fix compilation problem on AIX, see https://github.com/flori/json/issues/142
|
@@ -0,0 +1,27 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
== 0.9.15
|
4
|
+
|
5
|
+
* Save a received MessageID in message headers.
|
6
|
+
|
7
|
+
== 0.9.14
|
8
|
+
|
9
|
+
* Parse Subject and MessageID from the Bounce API response.
|
10
|
+
|
11
|
+
== 0.9.13
|
12
|
+
|
13
|
+
* Added error_code to DeliveryError
|
14
|
+
* Added retries for Timeout::Error
|
15
|
+
|
16
|
+
== 0.9.12
|
17
|
+
|
18
|
+
* Fixed a problem of attachments processing when using deliver! method on Mail object.
|
19
|
+
* Removed activesupport dependency for Postmark::AttachmentsFixForMail.
|
20
|
+
* Added specs for AttachmentFixForMail.
|
21
|
+
|
22
|
+
== 0.9.11
|
23
|
+
|
24
|
+
* Replaced Jeweler by Bundler.
|
25
|
+
* Updated RSpec to 2.8.
|
26
|
+
* Fixed specs.
|
27
|
+
* Refactored the codebase.
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vandamme::Parser do
|
4
|
+
context "with json gem changelog" do
|
5
|
+
let(:changelog_file) { File.read("spec/fixtures/json.md") }
|
6
|
+
let(:changelog_as_hash) {
|
7
|
+
{
|
8
|
+
"1.7.6"=> " * Add GeneratorState#merge alias for JRuby, fix state accessor methods. Thx to\n jvshahid@github.\n * Increase hash likeness of state objects.\n",
|
9
|
+
"1.7.5"=> " * Fix compilation of extension on older rubies.\n",
|
10
|
+
"1.7.4"=> " * Fix compilation problem on AIX, see https://github.com/flori/json/issues/142\n"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
let(:changelog_as_html_hash) {
|
15
|
+
{
|
16
|
+
"1.7.6"=> "<ul>\n<li>Add GeneratorState#merge alias for JRuby, fix state accessor methods. Thx to\njvshahid@github.</li>\n<li>Increase hash likeness of state objects.</li>\n</ul>\n",
|
17
|
+
"1.7.5"=> "<ul>\n<li>Fix compilation of extension on older rubies.</li>\n</ul>\n",
|
18
|
+
"1.7.4"=> "<ul>\n<li>Fix compilation problem on AIX, see https://github.com/flori/json/issues/142</li>\n</ul>\n"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
before do
|
23
|
+
@parser = Vandamme::Parser.new(changelog: changelog_file, version_header_exp: '\d{4}-\d{2}-\d{2} \((\d\.\d+\.\d+)\)', format: 'markdown')
|
24
|
+
@changelog_parsed = @parser.parse
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should parse file and fill changelog hash" do
|
28
|
+
expect(@changelog_parsed).to eq(changelog_as_hash)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should provide html content" do
|
32
|
+
expect(@parser.to_html).to eq(changelog_as_html_hash)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with postmark-gem changelog (rdoc)" do
|
37
|
+
let(:changelog_file) { File.read("spec/fixtures/postmark-gem.rdoc") }
|
38
|
+
let(:changelog_as_hash) {
|
39
|
+
{
|
40
|
+
"0.9.15" => "* Save a received MessageID in message headers.\n",
|
41
|
+
"0.9.14" => "* Parse Subject and MessageID from the Bounce API response.\n",
|
42
|
+
"0.9.13" => "* Added error_code to DeliveryError\n* Added retries for Timeout::Error\n",
|
43
|
+
"0.9.12" => "* Fixed a problem of attachments processing when using deliver! method on Mail object.\n* Removed activesupport dependency for Postmark::AttachmentsFixForMail.\n* Added specs for AttachmentFixForMail.\n",
|
44
|
+
"0.9.11" => "* Replaced Jeweler by Bundler.\n* Updated RSpec to 2.8.\n* Fixed specs.\n* Refactored the codebase.\n"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
let(:changelog_as_html_hash) {
|
49
|
+
{
|
50
|
+
"0.9.15" => "<ul><li>\n<p>Save a received MessageID in message headers.</p>\n</li></ul>\n",
|
51
|
+
"0.9.14" => "<ul><li>\n<p>Parse Subject and MessageID from the Bounce API response.</p>\n</li></ul>\n",
|
52
|
+
"0.9.13" => "<ul><li>\n<p>Added error_code to DeliveryError</p>\n</li><li>\n<p>Added retries for Timeout::Error</p>\n</li></ul>\n",
|
53
|
+
"0.9.12" => "<ul><li>\n<p>Fixed a problem of attachments processing when using deliver! method on\nMail object.</p>\n</li><li>\n<p>Removed activesupport dependency for Postmark::AttachmentsFixForMail.</p>\n</li><li>\n<p>Added specs for AttachmentFixForMail.</p>\n</li></ul>\n",
|
54
|
+
"0.9.11" => "<ul><li>\n<p>Replaced Jeweler by Bundler.</p>\n</li><li>\n<p>Updated RSpec to 2.8.</p>\n</li><li>\n<p>Fixed specs.</p>\n</li><li>\n<p>Refactored the codebase.</p>\n</li></ul>\n"
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
before do
|
59
|
+
@parser = Vandamme::Parser.new(changelog: changelog_file, version_header_exp: '== (\d.\d+\.\d+)', format: 'rdoc')
|
60
|
+
@changelog_parsed = @parser.parse
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should parse file and fill changelog hash" do
|
64
|
+
expect(@changelog_parsed).to eq(changelog_as_hash)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should provide html content" do
|
68
|
+
expect(@parser.to_html).to eq(changelog_as_html_hash)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/vandamme.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vandamme/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vandamme"
|
8
|
+
gem.version = Vandamme::VERSION
|
9
|
+
gem.authors = ["Philippe Lafoucrière"]
|
10
|
+
gem.email = ["philippe.lafoucriere@tech-angels.com"]
|
11
|
+
gem.description = %q{Vandamme is aware of files content, and will be mostly used to parse changelog files and extract relevant content.}
|
12
|
+
gem.summary = %q{Be aware of changelogs content}
|
13
|
+
gem.homepage = "https://github.com/tech-angels/vandamme"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vandamme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Philippe Lafoucrière
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Vandamme is aware of files content, and will be mostly used to parse
|
15
|
+
changelog files and extract relevant content.
|
16
|
+
email:
|
17
|
+
- philippe.lafoucriere@tech-angels.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Changelog.md
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/vandamme.rb
|
29
|
+
- lib/vandamme/parser.rb
|
30
|
+
- lib/vandamme/version.rb
|
31
|
+
- spec/fixtures/json.md
|
32
|
+
- spec/fixtures/postmark-gem.rdoc
|
33
|
+
- spec/spec_helper.rb
|
34
|
+
- spec/vandamme/parser_spec.rb
|
35
|
+
- vandamme.gemspec
|
36
|
+
homepage: https://github.com/tech-angels/vandamme
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.8.24
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Be aware of changelogs content
|
60
|
+
test_files:
|
61
|
+
- spec/fixtures/json.md
|
62
|
+
- spec/fixtures/postmark-gem.rdoc
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
- spec/vandamme/parser_spec.rb
|