releasenotes 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87c671f7fcd27805aeccd68e85242db2a65c506c
4
+ data.tar.gz: afbd0e9652516f91737891f63da87f9572235ee2
5
+ SHA512:
6
+ metadata.gz: 5fd5196d5f56f1befd4e5ee8b35e180c30ca0febd439c3f296c71cdaa2ee2a2d5ed2d49d015142b13c00ad1712e31eb4483288893af44c7ae7fae1422ad27259
7
+ data.tar.gz: b9a85e6fbce76f2a24d3dcb187f5c70efe0be9454b0350e10928af250fb647c99bc16e4fbf50e821e9e6659a603f9aa22edd69f272dba932a1ce01f47e25aa83
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.sublime-project
19
+ *.sublime-workspace
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in releasenotes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ted Bradley
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,33 @@
1
+ # Releasenotes
2
+
3
+ Compiles together release notes from the current git repository, optionally fetching the most recent commit number from Hockey.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'releasenotes'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install releasenotes
18
+
19
+ ## Usage
20
+
21
+ ### Without Hockey:
22
+ - releasenotes -c [git commit SHA1]
23
+
24
+ ### With Hockey:
25
+ - releasenotes -a [hockey_app_token] -u [hockey_user_token]
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/releasenotes ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'releasenotes'
3
+
4
+ runner = Releasenotes::Runner.new(ARGV)
5
+ runner.run
@@ -0,0 +1,3 @@
1
+ module Releasenotes
2
+ COMMIT_REGEX = /\b[a-f0-9]{40}\b/
3
+ end
@@ -0,0 +1,50 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+ require 'json'
4
+ require_relative 'helpers'
5
+
6
+ module Releasenotes
7
+ class Hockey
8
+ attr_reader :app_versions
9
+
10
+ def initialize(app_public_id: nil, user_api_key: nil)
11
+ @app_public_id = app_public_id
12
+ @user_api_key = user_api_key
13
+
14
+ fetch_app_versions()
15
+ end
16
+
17
+ def last_commit
18
+ if @app_versions.nil?
19
+ return nil
20
+ end
21
+
22
+ @app_versions.each do |version|
23
+ notes = version['notes']
24
+ match = COMMIT_REGEX.match(notes)
25
+ if match.nil?
26
+ next
27
+ end
28
+ return match[0]
29
+ end
30
+ end
31
+
32
+ protected
33
+
34
+ def fetch_app_versions
35
+ uri = URI("https://rink.hockeyapp.net/api/2/apps/#{@app_public_id}/app_versions")
36
+ https = Net::HTTP.new(uri.host, uri.port)
37
+ https.use_ssl = true
38
+ request = Net::HTTP::Get.new(uri.path)
39
+ request['X-HockeyAppToken'] = @user_api_key
40
+ result = https.request(request)
41
+
42
+ json = JSON.parse(result.body)
43
+ if not json['errors'].nil?
44
+ puts "Hockey error: " + json['errors'].to_s
45
+ else
46
+ @app_versions = json['app_versions']
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ require 'optparse'
2
+
3
+ module Releasenotes
4
+ class Options
5
+ attr_reader :user_token, :app_token, :last_commit
6
+
7
+ def initialize(argv)
8
+ parse(argv)
9
+ end
10
+
11
+ private
12
+
13
+ def parse(argv)
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: #{$0} [options]"
16
+
17
+ opts.on('-u', '--usertoken [TOKEN]', 'the hockey user token') do |token|
18
+ @user_token = token
19
+ end
20
+
21
+ opts.on('-a', '--apptoken [TOKEN]', 'the app token to use') do |token|
22
+ @app_token = token
23
+ end
24
+
25
+ opts.on('-c', '--commit [COMMIT]', 'the commit to find logs from') do |commit|
26
+ @last_commit = commit
27
+ end
28
+
29
+ opts.on_tail('-h', '--help', 'display this help and exit') do
30
+ puts opts
31
+ exit
32
+ end
33
+
34
+ begin
35
+ argv = ['-h'] if argv.empty?
36
+ opts.parse!(argv)
37
+
38
+ if @last_commit.nil? and (@app_token.nil? or @user_token.nil?)
39
+ STDERR.puts "You must specify both an app token and a user token for hockey"
40
+ exit(-1)
41
+ end
42
+
43
+ rescue OptionParser::ParseError => e
44
+ STDERR.puts e.message, "\n", opts
45
+ exit(-1)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module Releasenotes
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require_relative "releasenotes/version"
2
+ require_relative "releasenotes/options"
3
+ require_relative "releasenotes/hockey"
4
+
5
+ module Releasenotes
6
+ class Runner
7
+ def initialize(argv)
8
+ @options = Options.new(argv)
9
+ end
10
+
11
+ def run
12
+ commit = @options.last_commit
13
+ if commit.nil?
14
+ hockey = Hockey.new(app_public_id: @options.app_token, user_api_key: @options.user_token)
15
+ commit = hockey.last_commit
16
+ end
17
+
18
+ if commit.nil?
19
+ return
20
+ end
21
+
22
+ entries = `git log #{commit}..HEAD | grep -E -v "(^commit|^Author|^Date|^Merge|\[#.*\])" | cut -c 5-`.split("\n").delete_if { |entry| entry.length == 0 }
23
+ puts entries.join("\n")
24
+
25
+ last_commit = COMMIT_REGEX.match(`git log | head -n1`)[0]
26
+ puts "\n#{last_commit}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'releasenotes/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "releasenotes"
8
+ spec.version = Releasenotes::VERSION
9
+ spec.authors = ["Ted Bradley"]
10
+ spec.email = ["earltedly@gmail.com"]
11
+ spec.description = %q{Compiles together release notes from the current git repository, optionally fetching the most recent commit number from Hockey.}
12
+ spec.summary = %q{Compiles together release notes from the current git repository, optionally fetching the most recent commit number from Hockey.}
13
+ spec.homepage = "https://github.com/earltedly/releasenotes"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: releasenotes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ted Bradley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-13 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Compiles together release notes from the current git repository, optionally
42
+ fetching the most recent commit number from Hockey.
43
+ email:
44
+ - earltedly@gmail.com
45
+ executables:
46
+ - releasenotes
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/releasenotes
56
+ - lib/releasenotes.rb
57
+ - lib/releasenotes/helpers.rb
58
+ - lib/releasenotes/hockey.rb
59
+ - lib/releasenotes/options.rb
60
+ - lib/releasenotes/version.rb
61
+ - releasenotes.gemspec
62
+ homepage: https://github.com/earltedly/releasenotes
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.3
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Compiles together release notes from the current git repository, optionally
86
+ fetching the most recent commit number from Hockey.
87
+ test_files: []