rinfo 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97bc7f55b1f7bd7e21f51a51bffaef76a9de9d5c
4
- data.tar.gz: f51bd8fc84e2f0af9439b0505b367312e1e5301e
3
+ metadata.gz: 2ef45bcac62d24bde6ca081f30cb07c2378ebabc
4
+ data.tar.gz: 4ae40805b18e2935917768eb86e49a108bfdfcdc
5
5
  SHA512:
6
- metadata.gz: e893b5cfdff8948f6d60de43bae38f4f1cb2b5af042a09a08543d59569c92579f70d62f412d8138ec52654d3255818abc814771314afd8479464f0de517666fd
7
- data.tar.gz: 2e0a05faa47f7762f2f2298997a27d6c70e04b80164a227c824d23bb066daa6b919cc5662480b5b02a59759f2ec12feb00251c72b3ec66f559dc3243ed1c1294
6
+ metadata.gz: 54b50f87424e960cf2da52729b6b40acd217a64d0919ed6281f35439eafda2e02ea2aefa0e5bbe71aeac9a17c43a8e8ee2e24828090577ce578a2167acaaa313
7
+ data.tar.gz: 89a72994604b35ef3c86af49174480da4a0123ce30c54ec00ab92905f37831d12ea481ca23a275baa9f989c14f7b9b8636b3c163bed50058627577eea7520884
data/README.md CHANGED
@@ -28,6 +28,9 @@ Accessing your `rinfo.json` page will product something like this:
28
28
 
29
29
  It's as easy as that!
30
30
 
31
+ **NOTE:** For now, the `Deployed At` value is being estimated as the
32
+ timestamp on the most latest commit.
33
+
31
34
  ## Installation
32
35
 
33
36
  To add `rinfo` to your Rails application, add the `rinfo` gem to your `Gemfile`:
@@ -52,9 +55,13 @@ something like this:
52
55
 
53
56
  ```ruby
54
57
  # config/initializers/rinfo.rb
55
- Rinfo.env_blacklist = :staging, :production
58
+ Rinfo.env_blacklist = :prod, :production
59
+
60
+ Rinfo.filename = 'rinfo.json'
56
61
  ```
57
62
 
63
+ ### `env_blacklist`
64
+
58
65
  The `env_blacklist` attribute is a list of environments such that if it
59
66
  includes your `RAILS_ENV`, the `/rinfo.json` route will return a `404`
60
67
  response insetad of a `JSON` blob. The arguments provided can be a
@@ -65,3 +72,9 @@ either a string or a symbol. The default blacklist is `[:prod,
65
72
  **NOTE:** There is one special value `:all`, which, if included in your
66
73
  list, will prevent `rinfo.json` from showing up entirely, regardless of
67
74
  your `RAILS_ENV`
75
+
76
+ ### `filename`
77
+
78
+ The `filename` attribute allows you to set the filename at which your
79
+ release information is available. The default value of `rinfo.json` will
80
+ mean your file is available at `/rinfo.json`.
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  Rails.application.routes.draw do
4
- get '/rinfo.json', to: 'rinfo#info'
4
+ get "/#{Rinfo.filename}", to: 'rinfo#info'
5
5
  end
data/lib/rinfo.rb CHANGED
@@ -8,17 +8,14 @@ class Rinfo
8
8
  autoload :VERSION, 'rinfo/version'
9
9
 
10
10
  class << self
11
+ attr_writer :filename
12
+
11
13
  def inform!
12
- fail ActionController::RoutingError 'Not Found' unless should_inform?
13
- <<-RINFO.gsub(/^ {6}/, '')
14
- {
15
- "Deployed By": "#{author}",
16
- "Deployed At": "#{date}",
17
- "Rails Env": "#{env}",
18
- "Branch": "#{branch}",
19
- "Rev": "#{rev}"
20
- }
21
- RINFO
14
+ if should_inform?
15
+ JSON.pretty_generate(rinfo)
16
+ else
17
+ fail ActionController::RoutingError 'Not Found'
18
+ end
22
19
  end
23
20
 
24
21
  def should_inform?
@@ -33,8 +30,22 @@ class Rinfo
33
30
  @env_blacklist = [*args].map(&:to_sym)
34
31
  end
35
32
 
33
+ def filename
34
+ @filename ||= 'rinfo.json'
35
+ end
36
+
36
37
  private
37
38
 
39
+ def rinfo
40
+ {
41
+ deployed_by: author,
42
+ deployed_at: date,
43
+ rails_env: env,
44
+ branch: branch,
45
+ rev: rev
46
+ }
47
+ end
48
+
38
49
  def git
39
50
  @git ||= Git.open(root)
40
51
  end
data/lib/rinfo/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  unless defined?(Rinfo::VERSION)
4
4
  class Rinfo
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'tmpdir'
4
4
  require 'git'
5
+ require 'time'
5
6
 
6
7
  describe RinfoController, type: :controller do
7
8
  before(:all) do
@@ -37,7 +38,7 @@ describe RinfoController, type: :controller do
37
38
  end
38
39
 
39
40
  let(:author) { @name }
40
- let(:deploy_time) { "#{@date}" }
41
+ let(:deploy_time) { "#{@date.iso8601}" }
41
42
  let(:rails_env) { 'test' }
42
43
  let(:branch) { @branch_name }
43
44
  let(:rev) { @rev }
@@ -46,15 +47,13 @@ describe RinfoController, type: :controller do
46
47
  end
47
48
 
48
49
  def rinfo
49
- <<-RINFO.gsub(/^ {4}/, '')
50
- {
51
- "Deployed By": "#{author}",
52
- "Deployed At": "#{deploy_time}",
53
- "Rails Env": "#{Rinfo.send(:env)}",
54
- "Branch": "#{branch}",
55
- "Rev": "#{rev}"
56
- }
57
- RINFO
50
+ JSON.pretty_generate(
51
+ deployed_by: author,
52
+ deployed_at: deploy_time,
53
+ rails_env: "#{Rinfo.send(:env)}",
54
+ branch: branch,
55
+ rev: rev
56
+ )
58
57
  end
59
58
 
60
59
  describe 'GET #info' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafe Colton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake