revisioneer_rails 0.0.1

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: fac99ac31b96b6ccac487a1c32768500af227a82
4
+ data.tar.gz: 958358efb4c86a982da55acfbeddcfd34a5040e6
5
+ SHA512:
6
+ metadata.gz: b5dd10290725cc2c3515e00673578ab8007eb6f09d8c21d2d3e9837605fa60f650f1a78994c776bee60324c2955ba2840c91429a4c214bdbdd21df26e9e9950e
7
+ data.tar.gz: 0eb07bc5d46f6e89184dbbc0654db89ea75e1ad5af9450bca226bd3a9a5bed75c49876f45e593601de75f81948de3afd850b5af071cb4fca6b6b88ffdd685d2c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in revisioneer_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Raphael Randschau
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,64 @@
1
+ # RevisioneerRails
2
+
3
+ A Rails engine to easily display deployment informations gathered by [revisioneer][1].
4
+ In order to use it you first need to have an account for it.
5
+
6
+ To add deployments to revisioneer you need to integrate it into your deployment process.
7
+
8
+ If you are using mina to power your deployments you might want to take a look at [mina-revisioneer][2] to automatically push informations to revisioneer.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ``` ruby
15
+ # Gemfile
16
+ gem "revisioneer_rails"
17
+ ```
18
+
19
+ Next mount the engine to wherever you want the revisions to be displayed:
20
+
21
+ ``` ruby
22
+ # routes.rb
23
+ mount RevisioneerRails::Engine => "/revisions"
24
+ ```
25
+
26
+ You need to add your revisioneer credentials to to a configuration file not under version control:
27
+
28
+ ``` yaml
29
+ development: &dev
30
+ endpoint: "https://revisioneer.io"
31
+ api_token: "your api token"
32
+
33
+ production:
34
+ <<: *dev
35
+ ```
36
+
37
+ and write an initializer which loads the configuration:
38
+
39
+ ``` ruby
40
+ # config/initializers/revisioneer.rb
41
+ obj = YAML.load_file(Rails.root.join("config", "revisioneer.yml"))[Rails.env]
42
+
43
+ RevisioneerRails.configure do |config|
44
+ config.url = obj["endpoint"]
45
+ config.api_token = obj["api_token"]
46
+ end unless obj.empty?
47
+ ```
48
+
49
+ Lastly, restart your application server
50
+
51
+ ## TODO
52
+
53
+ - add tests for the revisioneer client
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+ [1]:https://github.com/nicolai86/revisioneer
64
+ [2]:https://github.com/nicolai86/mina-revisioneer
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,13 @@
1
+ module RevisioneerRails
2
+ class RevisionsController < ApplicationController
3
+ def index
4
+
5
+ end
6
+
7
+ protected
8
+ def deployments
9
+ @deployments ||= ::RevisioneerRails::Deployment.load
10
+ end
11
+ helper_method :deployments
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ <style>
2
+ .deployment li:first-line {
3
+ font-weight: bold;
4
+ }
5
+ </style>
6
+
7
+ <h2>Revisions</h2>
8
+ <% if deployments.empty? %>
9
+ <p>Bis jetzt wurden noch keine Deployments erfasst.</p>
10
+ <% else %>
11
+ <ul>
12
+ <%- deployments.each do |deployment| %>
13
+ <li>
14
+ <h3><%= deployment.deployed_at.strftime("%Y-%m-%d %H:%M") %></h3>
15
+ <ul class="deployment">
16
+ <% deployment.messages.each do |message| %>
17
+ <li style="padding-bottom: 10px">
18
+ <%=raw message.gsub(/\n/,"<br>") %>
19
+ </li>
20
+ <% end %>
21
+ </ul>
22
+ </li>
23
+ <% end %>
24
+ </ul>
25
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ RevisioneerRails::Engine.routes.draw do
2
+ get '/', to: 'revisioneer_rails/revisions#index', as: :revisions
3
+ end
@@ -0,0 +1,21 @@
1
+ require "json"
2
+ require "typhoeus"
3
+
4
+ module RevisioneerRails
5
+ class Deployment < Struct.new(:sha, :deployed_at, :messages)
6
+ def self.load page = 1, limit = 20
7
+ url = ::RevisioneerRails.config.url + "/deployments"
8
+ request = Typhoeus::Request.new(
9
+ url,
10
+ method: :get,
11
+ headers: { "API-TOKEN" => ::RevisioneerRails.config.api_token }
12
+ )
13
+ response = request.run
14
+ json = ::JSON.parse response.body
15
+
16
+ json.map { |deploy_data|
17
+ self.new(deploy_data["sha"], Time.parse(deploy_data["deployed_at"]), deploy_data["messages"])
18
+ }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module RevisioneerRails
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RevisioneerRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ require "revisioneer_rails/deployment"
2
+ require "revisioneer_rails/engine"
3
+ require "revisioneer_rails/version"
4
+
5
+ module RevisioneerRails
6
+ Config = Struct.new(:url, :api_token)
7
+
8
+ def self.config
9
+ @@config
10
+ end
11
+
12
+ def self.configure
13
+ @@config = Config.new
14
+ yield @@config if block_given?
15
+ @@config
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'revisioneer_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "revisioneer_rails"
8
+ spec.version = RevisioneerRails::VERSION
9
+ spec.authors = ["Raphael Randschau"]
10
+ spec.email = ["nicolai86@me.com"]
11
+ spec.description = %q{Rails engine to consume and present revisioneer service}
12
+ spec.summary = %q{Rails engine to consume and present 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 "rails", ">= 3.2", "< 5.0"
24
+ spec.add_dependency "typhoeus", "~> 0.6.6"
25
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: revisioneer_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ - - <
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '3.2'
58
+ - - <
59
+ - !ruby/object:Gem::Version
60
+ version: '5.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: typhoeus
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.6.6
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.6.6
75
+ description: Rails engine to consume and present revisioneer service
76
+ email:
77
+ - nicolai86@me.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - .gitignore
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - app/controllers/revisioneer_rails/revisions_controller.rb
88
+ - app/views/revisioneer_rails/revisions/index.html.erb
89
+ - config/routes.rb
90
+ - lib/revisioneer_rails.rb
91
+ - lib/revisioneer_rails/deployment.rb
92
+ - lib/revisioneer_rails/engine.rb
93
+ - lib/revisioneer_rails/version.rb
94
+ - revisioneer_rails.gemspec
95
+ homepage: http://blog.nicolai86.eu
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.1.11
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Rails engine to consume and present revisioneer
119
+ test_files: []