rack-dev-mark 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61304d64aa895f3dc8dfdd853b25d0c41d83f4cb
4
- data.tar.gz: 2faeecc55d213772cbc6b57f305d8e97cd654829
3
+ metadata.gz: 29e79da8e2e497e598c546a19d5fdbd559d08122
4
+ data.tar.gz: 9c48bd678f7a011150b951ad15846ba5a655d52b
5
5
  SHA512:
6
- metadata.gz: 47351a58d46067c45244210eb3bd42edf5ea91d1a5132b46f15dd4d2b8ee343164d99b7aaf85da4dd790954298339b6ca03e2ad11acb3bfc40873d3dcd8f89dc
7
- data.tar.gz: 04f870f4b5c4284edfa2aceb6daf6cd6873d43d132dfc03bf1f4592839633dcedb122250cbe753989553e6b14c055789627b63ab62ffdd839c2da073ae5e902c
6
+ metadata.gz: a1b8813d5f99f420f4408878cfa5dbefc316b0fcd28e53fb0b44198f35c8a68f7fa3045573e963748ceb8e24a928598cd996500ca8c08f4b5177ae3f4cf0e9e8
7
+ data.tar.gz: a5e49e6bccc0cf1e0530acfef251f4b1db3ebce2979ce0075a27e69be85a13d1b7a9fbdd2c777be9f1b63918cde3b47f4a0922f159ec12be643dbf00f3f252ed
data/README.md CHANGED
@@ -22,12 +22,7 @@ Add the rack-dev-mark gem to your Gemfile.
22
22
  gem "rack-dev-mark"
23
23
  ```
24
24
 
25
- And run `bundle install`. The rest of the installation depends on
26
- whether the asset pipeline is being used.
27
-
28
- Then, initialize planbcd.
29
-
30
- ## Usage
25
+ And run `bundle install`.
31
26
 
32
27
  ### For your Rack app
33
28
 
@@ -41,15 +36,7 @@ run MyApp
41
36
 
42
37
  This gem inserts rack middleware for all the environment except production automatically.
43
38
 
44
- ## Contributing
45
-
46
- 1. Fork it
47
- 2. Create your feature branch (`git checkout -b my-new-feature`)
48
- 3. Commit your changes (`git commit -am 'Add some feature'`)
49
- 4. Push to the branch (`git push origin my-new-feature`)
50
- 5. Create new [Pull Request](../../pull/new/master)
51
-
52
- ### Use custom theme
39
+ ## Custom Theme
53
40
 
54
41
  Define a sub class of `Rack::DevMark::Theme::Base` somewhere in your app.
55
42
 
@@ -66,23 +53,38 @@ end
66
53
 
67
54
  Then, insert it in your app.
68
55
 
69
- For your Rack app
56
+ ### For your Rack app
70
57
 
71
58
  ```ruby
72
59
  use Rack::DevMark::Middleware, Rack::DevMark::Theme::NewTheme.new
73
60
  ```
74
61
 
75
- For your Rails app
62
+ ### For your Rails app
76
63
 
77
- ```ruby:config/application.rb
78
- module MyApp
79
- class Application < Rails::Application
80
- config.middleware.delete Rack::DevMark::Middleware
81
- config.middleware.use Rack::DevMark::Middleware, NewTheme.new
82
- end
83
- end
64
+ ```ruby:application.rb
65
+ Rack::DevMark.theme = NewTheme.new
84
66
  ```
85
67
 
68
+ ## Production Environment
69
+
70
+ You can change production environment name.
71
+
72
+ ### For your Rails app
73
+
74
+ ```ruby:application.rb
75
+ Rack::DevMark.production_env = [:demo, :production]
76
+ ```
77
+
78
+ Then the mark won't show up on demo and production environments.
79
+
80
+ ## Contributing
81
+
82
+ 1. Fork it
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Push to the branch (`git push origin my-new-feature`)
86
+ 5. Create new [Pull Request](../../pull/new/master)
87
+
86
88
  ## Copyright
87
89
 
88
90
  Copyright (c) 2014 Daisuke Taniwaki. See [LICENSE](LICENSE) for details.
data/lib/rack/dev-mark.rb CHANGED
@@ -12,5 +12,21 @@ module Rack
12
12
  def self.env
13
13
  ENV['RAILS_ENV'] || ENV['RACK_ENV']
14
14
  end
15
+
16
+ def self.production_env
17
+ @production_env ||= ['production']
18
+ end
19
+
20
+ def self.production_env=(*production_env)
21
+ @production_env = production_env.flatten.map(&:to_s)
22
+ end
23
+
24
+ def self.theme
25
+ @theme ||= :github_fork_ribbon
26
+ end
27
+
28
+ def self.theme=(theme)
29
+ @theme = theme
30
+ end
15
31
  end
16
32
  end
@@ -3,10 +3,10 @@ require 'rack/dev-mark/middleware'
3
3
  module Rack
4
4
  module DevMark
5
5
  class Railtie < ::Rails::Railtie
6
- config.before_configuration do |app|
6
+ initializer 'rack-dev-mark' do |app|
7
7
  app.middleware.delete Rack::DevMark::Middleware
8
- if Rack::DevMark.env != 'production'
9
- app.middleware.use Rack::DevMark::Middleware
8
+ unless Rack::DevMark.production_env.include? Rack::DevMark.env.to_s
9
+ app.middleware.use Rack::DevMark::Middleware, Rack::DevMark.theme
10
10
  end
11
11
  end
12
12
  end
@@ -11,7 +11,7 @@ module Rack
11
11
  <!--[if lt IE 9]>
12
12
  #{stylesheet_link_tag "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}
13
13
  <![endif]-->
14
- <div class="github-fork-ribbon-wrapper left" id="github-fork-ribbon" onClick="this.style.display='none'"><div class="github-fork-ribbon"><span class="github-fork-ribbon-text" target="_blank">#{env}</span></div></div>
14
+ <div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'"><div class="github-fork-ribbon"><span class="github-fork-ribbon-text">#{env}</span></div></div>
15
15
  EOS
16
16
  html.sub %r{(<body[^>]*>)}i, "\\1#{s.strip}"
17
17
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module DevMark
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
Binary file
Binary file
@@ -6,11 +6,13 @@ require 'rails'
6
6
  require 'rack/dev-mark/railtie'
7
7
 
8
8
  describe Rack::DevMark::Railtie do
9
- let(:env) { nil }
9
+ let(:env) { 'test' }
10
+ let(:production_env) { :production }
10
11
  let(:app) { Class.new(Rails::Application) }
11
12
  before do
12
13
  @env = ENV['RAILS_ENV']
13
14
  ENV['RAILS_ENV'] = env
15
+ Rack::DevMark.production_env = production_env
14
16
  app.initialize!
15
17
  end
16
18
  after do
@@ -22,13 +24,24 @@ describe Rack::DevMark::Railtie do
22
24
  it "adds rack middleware" do
23
25
  expect(app.middleware.middlewares).to include(Rack::DevMark::Middleware)
24
26
  end
27
+ context "production_env has test" do
28
+ let(:production_env) { 'test' }
29
+ it "does not add rack middleware" do
30
+ expect(app.middleware.middlewares).not_to include(Rack::DevMark::Middleware)
31
+ end
32
+ end
25
33
  end
26
34
  context "production env" do
27
35
  let(:env) { 'production' }
28
-
29
36
  it "does not add rack middleware" do
30
37
  expect(app.middleware.middlewares).not_to include(Rack::DevMark::Middleware)
31
38
  end
39
+ context "production_env has abc" do
40
+ let(:production_env) { :abc }
41
+ it "does not add rack middleware" do
42
+ expect(app.middleware.middlewares).to include(Rack::DevMark::Middleware)
43
+ end
44
+ end
32
45
  end
33
46
  end
34
47
 
@@ -8,7 +8,7 @@ describe Rack::DevMark::Theme::GithubForkRibbon do
8
8
  <!--[if lt IE 9]>
9
9
  <style>#{read_stylesheet "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}</style>
10
10
  <![endif]-->
11
- <div class="github-fork-ribbon-wrapper left"><div class="github-fork-ribbon"><a href="https://github.com/simonwhitaker/github-fork-ribbon-css" class="github-fork-ribbon-text" target="_blank">env</a></div></div>body</body></html>
11
+ <div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'"><div class="github-fork-ribbon"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
12
12
  EOS
13
13
  s.strip
14
14
  end
@@ -5,6 +5,7 @@ describe Rack::DevMark do
5
5
  before do
6
6
  @rack_env = ENV['RACK_ENV']
7
7
  @rails_env = ENV['RAILS_ENV']
8
+ Rack::DevMark.production_env = 'production'
8
9
  end
9
10
  after do
10
11
  ENV['RACK_ENV'] = @rack_env
@@ -25,4 +26,22 @@ describe Rack::DevMark do
25
26
  ENV['RAILS_ENV'] = 'def'
26
27
  expect(subject.env).to eq('def')
27
28
  end
29
+ it 'has default production_env' do
30
+ expect(subject.production_env).to eq(['production'])
31
+ end
32
+ it 'sets production_env' do
33
+ Rack::DevMark.production_env = 'abc'
34
+ expect(subject.production_env).to eq(['abc'])
35
+ end
36
+ it 'sets production_env by array' do
37
+ Rack::DevMark.production_env = ['abc', 'def']
38
+ expect(subject.production_env).to eq(['abc', 'def'])
39
+ end
40
+ it 'has default theme' do
41
+ expect(subject.theme).to eq(:github_fork_ribbon)
42
+ end
43
+ it 'sets production_env' do
44
+ Rack::DevMark.theme = :abc
45
+ expect(subject.theme).to eq(:abc)
46
+ end
28
47
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-dev-mark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Taniwaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Differentiate development environemt from production
@@ -87,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".travis.yml"
90
+ - .gitignore
91
+ - .travis.yml
92
92
  - Gemfile
93
93
  - LICENSE
94
94
  - README.md
@@ -132,17 +132,17 @@ require_paths:
132
132
  - lib
133
133
  required_ruby_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - ">="
135
+ - - '>='
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
- - - ">="
140
+ - - '>='
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.2.2
145
+ rubygems_version: 2.0.14
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Differentiate development environemt from production
@@ -155,4 +155,3 @@ test_files:
155
155
  - spec/rack/dev-mark_spec.rb
156
156
  - spec/spec_helper.rb
157
157
  - spec/support/theme_helper.rb
158
- has_rdoc: