mina-revisioneer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d8ec22774860a6dbdf62a6d39fbf6f7fc32ade30
4
+ data.tar.gz: 934418b672249f4229ac643fdfc91e5fc7fb7ec8
5
+ SHA512:
6
+ metadata.gz: b381d2163700f1cd15d10128ab1f9a319a56b4f49642b2e6b718552788592df796b7d27b83623d3f30403b53862d304d0cb433adcd9ad15d7ea4fa13fd41da69
7
+ data.tar.gz: 9c57e647cbf4299651d64a5a0c2e9e1d93d5d96636e950f8ab6247b61ec8e4e3a77a0a5b790b41a5a16d263ffb2e3fd781ce77e6ea0cc3d8a68edf9708b85240
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina_revisioneer.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,19 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mina-revisioneer (0.1.0)
5
+ rugged
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rake (10.1.0)
11
+ rugged (0.19.0)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.3)
18
+ mina-revisioneer!
19
+ rake
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Raphael Randschau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # MinaRevisioneer
2
+
3
+ Notify revisioneer of new deployments automatically. Integrates properly with [mina][1].
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ``` ruby
10
+ gem 'mina_revisioneer'
11
+ ```
12
+
13
+ Next update your deployment file:
14
+
15
+ ``` ruby
16
+ # config/deploy.rb
17
+ require 'mina-revisioneer'
18
+ # ...
19
+ set :revisioneer_host, "https://revisioneer.io"
20
+ set :revisioneer_api_token, ENV["REVISIONEER_TOKEN"]
21
+ # ...
22
+ task :deploy => :environment do
23
+ deploy do
24
+ # ...
25
+ invoke :'revisioneer:notify'
26
+ end
27
+ end
28
+ ```
29
+
30
+ Now deploy away while keeping revisioneer in sync.
31
+
32
+ ## Usage
33
+
34
+ MinaRevisioneer uses the oneline commit message summaries from git to populate your deployment informations.
35
+ Alongside with your current SHA these informations are passed to revisioneer.
36
+
37
+ Assuming you are on Ruby on Rails you can use [revisioneer-rails][2] to display the deployment informations somewhere in your application.
38
+
39
+ Note however that interfacing with revisioneer is really simple so you can always RYO.
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
48
+
49
+ [1]:https://github.com/nadarei/mina
50
+ [2]:https://github.com/nicolai86/revisioneer-rails
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ require 'mina_revisioneer'
@@ -0,0 +1,49 @@
1
+ require "mina_revisioneer/version"
2
+ require "mina_revisioneer/message_extractor"
3
+ require "mina_revisioneer/change_log"
4
+ require "mina_revisioneer/grouped_change_log"
5
+
6
+ # # Modules: Revisioneer
7
+ # Adds settings and tasks for interfacing with Revisioneer
8
+ #
9
+ # require 'mina-revisioneer'
10
+
11
+ # ## Settings
12
+ # Any and all of these settings can be overriden in your `deploy.rb`.
13
+
14
+ # ### revisioneer_host
15
+ # Sets the revisioneer host.
16
+
17
+ set_default :revisioneer_host, 'https://revisions.deployed.eu'
18
+
19
+ # ### revisioneer_api_token
20
+ # Sets the api_token required by revisioneer
21
+
22
+ set_default :revisioneer_api_token, ''
23
+
24
+ # ### revisioneer_message_generator
25
+ # Sets a class used to extra the current sha, as well as
26
+ # changeset messages. If you want to implement different message
27
+ # styles, this is the place to go
28
+ set_default :revisioneer_message_generator, -> { ::MinaRevisioneer::ChangeLog.new(revisioneer_host, revisioneer_api_token, binding) }
29
+
30
+ # ## Deploy tasks
31
+ # These tasks are meant to be invoked inside deploy scripts, not invoked on
32
+ # their own.
33
+
34
+ namespace :revisioneer do
35
+ # ### revisioneer:notify
36
+ # notifies revisioneer of a new deployment
37
+ desc "notifies revisioneer of a new deployment"
38
+ task :notify do
39
+ payload = {
40
+ "sha" => revisioneer_message_generator.sha,
41
+ "messages" => revisioneer_message_generator.messages,
42
+ "new_commit_counter" => revisioneer_message_generator.number_of_new_commits
43
+ }
44
+ queue %{
45
+ echo "-----> Notifying revisioneer"
46
+ #{echo_cmd %[curl -X POST "#{revisioneer_host}/deployments" -d '#{JSON.dump(payload)}' -H "API-TOKEN: #{revisioneer_api_token}" -H "Content-Type: application/json" -s]}
47
+ }
48
+ end
49
+ end
@@ -0,0 +1,30 @@
1
+ module MinaRevisioneer
2
+ # Uses the first line of each commit message as entries to the changelog
3
+ #
4
+ # can be configured by setting
5
+ # :revisioneer_inclusion
6
+ # for inclusiong (whitelisting) and
7
+ # :revisioneer_exclusion
8
+ # for exlusion (blacklisting)
9
+ class ChangeLog < MessageExtractor
10
+ def messages
11
+ walker = Rugged::Walker.new(repo)
12
+ walker.push sha
13
+ walker.hide last_deploy_sha if last_deploy_sha
14
+ messages = walker.each.to_a.map { |commit|
15
+ commit.message.lines.first.strip
16
+ }
17
+ messages.select! { |line| line =~ revisioneer_inclusion } if revisioneer_inclusion
18
+ messages.reject! { |line| line =~ revisioneer_exclusion } if revisioneer_exclusion
19
+ messages
20
+ end
21
+
22
+ def revisioneer_inclusion
23
+ eval "revisioneer_inclusion", binding
24
+ end
25
+
26
+ def revisioneer_exclusion
27
+ eval "revisioneer_exclusion", binding
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,35 @@
1
+ module MinaRevisioneer
2
+ # Uses the markers inside the commit message to generate change groups
3
+ #
4
+ # can be configured by setting
5
+ # :revisioneer_markers
6
+ # must be a hash of GroupName => Marker
7
+ class GroupedChangeLog < MessageExtractor
8
+ def messages
9
+ groups = Hash.new
10
+
11
+ walker = Rugged::Walker.new(repo)
12
+ walker.push sha
13
+ walker.hide last_deploy_sha if last_deploy_sha
14
+ walker.each do |commit|
15
+ revisioneer_markers.each do |marker, pattern|
16
+ commit.message.lines.each do |line|
17
+ if line =~ pattern
18
+ (groups[marker] ||= []) << line.strip
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ messages = []
25
+ groups.each do |key, ms|
26
+ messages << "#{key}:\n#{ms.join("\n")}"
27
+ end
28
+ messages
29
+ end
30
+
31
+ def revisioneer_markers
32
+ eval "revisioneer_markers", binding
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ require "json"
2
+ require "rugged"
3
+
4
+ module MinaRevisioneer
5
+ class MessageExtractor
6
+ attr_reader :host, :api_token, :binding
7
+ def initialize host, token, binding
8
+ @host = host
9
+ @api_token = token
10
+ @binding = binding
11
+ end
12
+
13
+ def last_deploy
14
+ @last_deploy ||= begin
15
+ curl = %Q{curl "#{host}/deployments?limit=1" -H "API-TOKEN: #{api_token}" -s}
16
+ response = %x[#{curl}].strip
17
+ JSON.parse(response).first || {}
18
+ end
19
+ rescue => err
20
+ {} # no JSON received - propably first deploy?
21
+ end
22
+
23
+ def number_of_new_commits
24
+ walker = Rugged::Walker.new(repo)
25
+ walker.push sha
26
+ walker.hide last_deploy_sha if last_deploy_sha
27
+ walker.each.to_a.count
28
+ end
29
+
30
+ def last_deploy_date
31
+ Time.parse(last_deploy.fetch("deployed_at"))
32
+ end
33
+
34
+ def last_deploy_sha
35
+ last_deploy.fetch("sha", nil)
36
+ end
37
+
38
+ def repo
39
+ @repo ||= Rugged::Repository.new(".")
40
+ end
41
+
42
+ def messages
43
+ [] # implemented in subclass
44
+ end
45
+
46
+ def sha
47
+ ref = repo.head
48
+ ref.target
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module MinaRevisioneer
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina_revisioneer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina-revisioneer"
8
+ spec.version = MinaRevisioneer::VERSION
9
+ spec.authors = ["Raphael Randschau"]
10
+ spec.email = ["nicolai86@me.com"]
11
+ spec.description = %q{push deployment informations to revisioneer}
12
+ spec.summary = %q{push deployment informations to revisioneer}
13
+ spec.homepage = "http://blog.nicolai86.eu"
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
+ spec.add_dependency "rugged", "~> 0.19"
24
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina-revisioneer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Raphael Randschau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-27 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
+ - !ruby/object:Gem::Dependency
42
+ name: rugged
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.19'
55
+ description: push deployment informations to revisioneer
56
+ email:
57
+ - nicolai86@me.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - lib/mina-revisioneer.rb
69
+ - lib/mina_revisioneer.rb
70
+ - lib/mina_revisioneer/change_log.rb
71
+ - lib/mina_revisioneer/grouped_change_log.rb
72
+ - lib/mina_revisioneer/message_extractor.rb
73
+ - lib/mina_revisioneer/version.rb
74
+ - mina_revisioneer.gemspec
75
+ homepage: http://blog.nicolai86.eu
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.1.11
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: push deployment informations to revisioneer
99
+ test_files: []