git_pr_release_parser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d36a98eb091147770331bbf6dad64b42fa53bf987f01afa6edd24c555a2d34fa
4
+ data.tar.gz: 93dc835ad8e8adfd62d0ec39a3d1c9e0061ffd63162892e36d7ba94f066ea1ca
5
+ SHA512:
6
+ metadata.gz: 504c799b057f975dac58cc1eac0136a8035982c251f7b1c2a99e64413e263f0c7a385497e61d6da7a9df5935f83b7ecd14e281d86264fd5923692a5297967633
7
+ data.tar.gz: 57cb6e8e4daa7ccd919900feb68c069cc46b6baf4abd1918cff9fbc1634e7fe3e8defb59424dc509a2adddf7da474fd95ecbfe827f72e9b96c443b9eadff0790
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ before_install: gem install bundler -v 1.16.1
10
+ notifications:
11
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in git_pr_release_parser.gemspec
6
+ gemspec
@@ -0,0 +1,48 @@
1
+ # GitPrReleaseParser
2
+
3
+ [![Build Status](https://travis-ci.org/a2ikm/git_pr_release_parser.svg?branch=master)](https://travis-ci.org/a2ikm/git_pr_release_parser)
4
+
5
+ Parse [git-pr-release](https://github.com/motemen/git-pr-release)'s output in Ruby.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'git_pr_release_parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install git_pr_release_parser
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require "open3"
27
+ require "git_pr_release_parser"
28
+
29
+ output, status = Open3.capture2e("git-pr-release")
30
+ result = GitPrReleaseParser.parse(output)
31
+
32
+ if result
33
+ puts result.release_pull_request
34
+ result.merged_pull_requests.each do |merged|
35
+ puts merged
36
+ end
37
+ end
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/a2ikm/git_pr_release_parser.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "git_pr_release_parser"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "git_pr_release_parser/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git_pr_release_parser"
8
+ spec.version = GitPrReleaseParser::VERSION
9
+ spec.authors = ["Masato Ikeda"]
10
+ spec.email = ["masato.ikeda@gmail.com"]
11
+
12
+ spec.summary = %q{Parse git-pr-release output.}
13
+ spec.description = %q{Parse git-pr-release output.}
14
+ spec.homepage = "https://github.com/a2ikm/git_pr_release_parser"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.16"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
24
+ end
@@ -0,0 +1,33 @@
1
+ require "git_pr_release_parser/result"
2
+ require "git_pr_release_parser/version"
3
+
4
+ class GitPrReleaseParser
5
+ class <<self
6
+ def parse(source)
7
+ new.parse(source)
8
+ end
9
+ end
10
+
11
+ MERGE_REGEXP = /To be released: (.+)\n/
12
+ RELEASE_REGEXP = /(?:Created|Updated) pull request: (.+)\n/
13
+
14
+ def parse(source)
15
+ merged = []
16
+ release = nil
17
+
18
+ clean(source).each_line do |line|
19
+ case line
20
+ when MERGE_REGEXP
21
+ merged << $1
22
+ when RELEASE_REGEXP
23
+ release = $1
24
+ end
25
+ end
26
+
27
+ Result.new(release, merged).verify
28
+ end
29
+
30
+ def clean(source)
31
+ source.gsub(/\^\[\[[0-9;]+m/, "")
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ class GitPrReleaseParser
2
+ class Result
3
+ attr_reader :release_pull_request, :merged_pull_requests
4
+
5
+ def initialize(release_pull_request, merged_pull_requests)
6
+ @release_pull_request = release_pull_request.freeze
7
+ @merged_pull_requests = merged_pull_requests.freeze
8
+ end
9
+
10
+ def verify
11
+ if release_pull_request && merged_pull_requests.length > 0
12
+ self
13
+ else
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ class GitPrReleaseParser
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_pr_release_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masato Ikeda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Parse git-pr-release output.
56
+ email:
57
+ - masato.ikeda@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - git_pr_release_parser.gemspec
70
+ - lib/git_pr_release_parser.rb
71
+ - lib/git_pr_release_parser/result.rb
72
+ - lib/git_pr_release_parser/version.rb
73
+ homepage: https://github.com/a2ikm/git_pr_release_parser
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.7.3
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Parse git-pr-release output.
96
+ test_files: []