active_admin_environment 0.0.2 → 1.0.0

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: 30f8762ae67853404b158cbec0f2affdbe43a275
4
- data.tar.gz: 4bef84a8355c396990ca5e642cb70de5409be025
3
+ metadata.gz: 7230c3503b40013a5e8db94ff1e822c46e418073
4
+ data.tar.gz: 21320561204cdfca1775d19e9bb3f7efed9db1b4
5
5
  SHA512:
6
- metadata.gz: 5ec6acd9d584f84add90c39f234996a37be492d99569dd81d418df37eb3f51197f13ed9d205fd4edfc26ff9da8fe887a860380c7e8a17559d0d27a0ab2489b57
7
- data.tar.gz: b32a6c4e62e46f09e60180a2816c0a7240805032958e1d90cf4f56b87099fba035890e9c0e65a12d590adb43a14ebd0c6965f7eec1a134a43841a7e5e6a76567
6
+ metadata.gz: 56e2e74f17102181c3beec7758931b5a4d41cb2ab9dd11ae1bfb2751ea1fee9500d24a832b0e7a8bff9fa2f376878f8c7c35232cf793bfe229130a04206507e5
7
+ data.tar.gz: 7846c3e4ac56dfb1ee1604a2fc3c467951096c928dd50ebd04246d0bbf8dee92e01386f6a62a8638f9a7e052893a5e173997e32d8e5c4431aa622372dc2b9715
data/.gitignore CHANGED
@@ -15,4 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- vendor/bundle
18
+ vendor
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color -f d
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ActiveAdminEnvironment
2
2
 
3
- TODO: Write a gem description
3
+ Change AcitiveAdmin appearance by rails environment.
4
+
5
+ ![alt tag](/images/production.png)
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,21 +10,35 @@ Add this line to your application's Gemfile:
8
10
 
9
11
  gem 'active_admin_environment'
10
12
 
11
- And then execute:
13
+ After installed gem, execute:
12
14
 
13
- $ bundle
15
+ $ rails generate active_admin_environment:install
14
16
 
15
- Or install it yourself as:
17
+ Generating default css and initializers:
16
18
 
17
- $ gem install active_admin_environment
19
+ app/assets/stylesheets/active_admin_environment
20
+ ├── development.css.scss
21
+ └── production.css.scss
22
+ config/initializers
23
+ └── active_admin_environment.rb
18
24
 
19
- After installed gem, execute:
25
+ ## Usage
20
26
 
21
- $ rails generate active_admin_environment:install
27
+ This gem is for environment named production, development.
22
28
 
23
- ## Usage
29
+ development
30
+ ![alt tag](/images/develop.png)
31
+
32
+ production
33
+ ![alt tag](/images/production.png)
34
+
35
+ ### Change color or add different environment
24
36
 
25
- TODO: Write usage instructions here
37
+ Edit initializer (config/initializers/active_admin_environment.rb)
38
+
39
+ Execute bellow to regenerate css files :
40
+
41
+ $ rails generate active_admin_environment:css
26
42
 
27
43
  ## Contributing
28
44
 
@@ -31,3 +47,4 @@ TODO: Write usage instructions here
31
47
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
48
  4. Push to the branch (`git push origin my-new-feature`)
33
49
  5. Create new Pull Request
50
+
@@ -24,5 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rspec-rails"
28
+ spec.add_development_dependency "ammeter"
27
29
 
28
30
  end
Binary file
Binary file
Binary file
@@ -1,11 +1,14 @@
1
- require "active_admin_environment/version"
1
+ require 'active_admin_environment/version'
2
+ require 'rails/all'
2
3
 
4
+ module ActiveAdminEnvironment
5
+ DEFAULT_COLORS = { :development => "#5e6469", :production => "#ff0000" }
6
+ mattr_accessor :environment_colors
7
+ self.environment_colors = DEFAULT_COLORS
3
8
 
4
- #module ActiveAdminEnvironment
5
- # module Rails
6
- # class Engine < ::Rails::Engine
7
- # end
8
- # end
9
- #end
9
+ def self.setup
10
+ yield self
11
+ end
12
+ end
10
13
 
11
14
  require 'active_admin_environment/engine'
@@ -1,10 +1,13 @@
1
+ require 'rails/all'
2
+
1
3
  module ActiveAdminEnvironment
2
4
  class Engine < Rails::Engine
3
5
  if Rails.version >= "3.1"
4
6
  initializer "ActiveAdminEnvironment precompile hook" do |app|
5
- if Rails.env.production? || Rails.env.development? || Rails.env.staging?
6
- app.config.assets.precompile += %W(active_admin_environment/active_admin_#{Rails.env.to_s}.css)
7
- ActiveAdmin.application.register_stylesheet "active_admin_#{Rails.env.to_s}.css"
7
+ define_envs = ActiveAdminEnvironment.environment_colors.keys.map(&:to_sym)
8
+ if define_envs.include?(Rails.env.to_sym)
9
+ app.config.assets.precompile += %W(active_admin_environment/#{Rails.env.to_s}.css)
10
+ ActiveAdmin.application.register_stylesheet "active_admin_environment/#{Rails.env.to_s}.css"
8
11
  end
9
12
  end
10
13
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminEnvironment
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,12 @@
1
+ require 'generators/active_admin_environment/generator_base'
2
+
3
+ module ActiveAdminEnvironment
4
+ module Generators
5
+ class CssGenerator < Base
6
+ desc "Generate CSS file each environment in a rails 3 application"
7
+ def copy_css_files
8
+ generate_css_files
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails/generators'
2
+ module ActiveAdminEnvironment
3
+ module Generators
4
+ class Base < ::Rails::Generators::Base
5
+ def self.source_root
6
+ @_active_admin_environment_source_root ||= File.expand_path("../templates", __FILE__)
7
+ end
8
+
9
+ private
10
+ def generate_css_files
11
+ remove_dir "app/assets/stylesheets/active_admin_environment"
12
+ ActiveAdminEnvironment.environment_colors.each do |env, color|
13
+ @env = env.to_s.camelize
14
+ @color = color
15
+ template "active_admin_environment.css.scss.erb", "app/assets/stylesheets/active_admin_environment/#{env}.css.scss"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ require 'generators/active_admin_environment/generator_base'
2
+
3
+ module ActiveAdminEnvironment
4
+ module Generators
5
+ class InstallGenerator < Base
6
+ desc "Installs ActiveAdminEnvironment in a rails 3 application"
7
+
8
+ def copy_Initializer
9
+ copy_file "initializer.rb", "config/initializers/active_admin_environment.rb"
10
+ end
11
+
12
+ def copy_css_files
13
+ generate_css_files
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,15 +1,15 @@
1
1
  body.active_admin {
2
2
  #header{
3
- background: -webkit-linear-gradient(-90deg, #6a7176, #ff0000);
3
+ background: -webkit-linear-gradient(-90deg, #6a7176, <%= @color %>);
4
4
  }
5
5
 
6
6
  #page_title {
7
7
  position: relative;
8
8
  }
9
9
  #page_title:before {
10
- content: "Production - ";
10
+ content: "<%= @env %> - ";
11
11
  padding-left: 40px;
12
- color: #ff6600;
12
+ color: <%= @color %>;
13
13
  }
14
14
  #page_title:after {
15
15
  position: absolute;
@@ -21,7 +21,7 @@ body.active_admin {
21
21
  -webkit-border-radius: 100%;
22
22
  -moz-border-radius: 100%;
23
23
  border-radius: 100%;
24
- background: #ff6600;
24
+ background: <%= @color %>;
25
25
  content: "!";
26
26
  color: #ffffff;
27
27
  text-align: center;
@@ -30,3 +30,4 @@ body.active_admin {
30
30
  font-size: 24px
31
31
  }
32
32
  }
33
+
@@ -0,0 +1,8 @@
1
+ ActiveAdminEnvironment.setup do |config|
2
+ # Set base color each environment by Hash
3
+ # ex. { :ENVIRONMENT_SYMBOL => color_code, .... }
4
+ config.environment_colors = {
5
+ :development => "#5e6469",
6
+ :production => "#ff0000"
7
+ }
8
+ end
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
- require 'active_admin_environment'
3
2
 
4
3
  describe ActiveAdminEnvironment do
5
4
  it { should be_true }
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'generators/active_admin_environment/css_generator'
3
+
4
+ describe ActiveAdminEnvironment::Generators::CssGenerator do
5
+ destination File.expand_path("../../../../tmp", __FILE__)
6
+ before do
7
+ prepare_destination
8
+ end
9
+
10
+ describe "copy css files" do
11
+ describe "production.css" do
12
+ subject { file('app/assets/stylesheets/active_admin_environment/production.css.scss') }
13
+ before do
14
+ run_generator
15
+ end
16
+ it { should exist }
17
+ it { should contain(/Production/) }
18
+ end
19
+
20
+ describe "development.css" do
21
+ subject { file('app/assets/stylesheets/active_admin_environment/development.css.scss') }
22
+ before do
23
+ run_generator
24
+ end
25
+ it { should exist }
26
+ it { should contain(/Development/) }
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'generators/active_admin_environment/install_generator'
3
+
4
+ describe ActiveAdminEnvironment::Generators::InstallGenerator do
5
+ destination File.expand_path("../../../../tmp", __FILE__)
6
+ before do
7
+ prepare_destination
8
+ end
9
+
10
+ describe "copy initializer" do
11
+ subject { file('config/initializers/active_admin_environment.rb') }
12
+ before do
13
+ run_generator
14
+ end
15
+
16
+ describe 'exists initilizer file' do
17
+ it { should exist }
18
+ it { should contain(/production/) }
19
+ it { should contain(/development/) }
20
+ end
21
+ end
22
+
23
+ describe "copy css files" do
24
+ describe "production.css" do
25
+ subject { file('app/assets/stylesheets/active_admin_environment/production.css.scss') }
26
+ before do
27
+ run_generator
28
+ end
29
+ it { should exist }
30
+ it { should contain(/Production/) }
31
+ end
32
+
33
+ describe "development.css" do
34
+ subject { file('app/assets/stylesheets/active_admin_environment/development.css.scss') }
35
+ before do
36
+ run_generator
37
+ end
38
+ it { should exist }
39
+ it { should contain(/Development/) }
40
+ end
41
+ end
42
+ end
43
+
@@ -1,4 +1,9 @@
1
1
  require 'rubygems'
2
+ require 'active_admin_environment'
3
+ require 'rails/all'
4
+ require 'rspec/rails'
5
+ require 'ammeter/init'
6
+
2
7
 
3
8
  # カスタムマッチャを書きたかったらここに。
4
9
  RSpec::Matchers.define :my_matcher do |expected|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_environment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keishake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-17 00:00:00.000000000 Z
11
+ date: 2013-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -80,6 +80,34 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: ammeter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: Change ActiveAdmin page style by environment
84
112
  email:
85
113
  - keishake0925@gmail.com
@@ -88,20 +116,27 @@ extensions: []
88
116
  extra_rdoc_files: []
89
117
  files:
90
118
  - .gitignore
119
+ - .rspec
91
120
  - .ruby-version
92
121
  - Gemfile
93
122
  - LICENSE.txt
94
123
  - README.md
95
124
  - Rakefile
96
125
  - active_admin_environment.gemspec
126
+ - images/develop.png
127
+ - images/production.png
128
+ - images/staging.png
97
129
  - lib/active_admin_environment.rb
98
130
  - lib/active_admin_environment/engine.rb
99
131
  - lib/active_admin_environment/version.rb
100
- - lib/rails/generators/active_admin_environment/install/install_generator.rb
101
- - lib/rails/generators/active_admin_environment/install/templates/active_admin_development.css.scss
102
- - lib/rails/generators/active_admin_environment/install/templates/active_admin_production.css.scss
103
- - lib/rails/generators/active_admin_environment/install/templates/active_admin_staging.css.scss
132
+ - lib/generators/active_admin_environment/css_generator.rb
133
+ - lib/generators/active_admin_environment/generator_base.rb
134
+ - lib/generators/active_admin_environment/install_generator.rb
135
+ - lib/generators/active_admin_environment/templates/active_admin_environment.css.scss.erb
136
+ - lib/generators/active_admin_environment/templates/initializer.rb
104
137
  - spec/active_admin_environment_spec.rb
138
+ - spec/generators/active_admin_environment/css_generator_spec.rb
139
+ - spec/generators/active_admin_environment/install_generator_spec.rb
105
140
  - spec/spec_helper.rb
106
141
  homepage: https://github.com/Keishake/active_admin_environment
107
142
  licenses:
@@ -129,4 +164,6 @@ specification_version: 4
129
164
  summary: Change ActiveAdmin page style by environment
130
165
  test_files:
131
166
  - spec/active_admin_environment_spec.rb
167
+ - spec/generators/active_admin_environment/css_generator_spec.rb
168
+ - spec/generators/active_admin_environment/install_generator_spec.rb
132
169
  - spec/spec_helper.rb
@@ -1,18 +0,0 @@
1
- module ActiveAdminEnvironment
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- desc "Installs ActiveAdminEnvironment in a rails 3 application"
5
-
6
- def self.source_root
7
- @_active_admin_environment_source_root ||= File.expand_path("../templates", __FILE__)
8
- end
9
-
10
- def copy_css_files
11
- %w(development staging production).each do |e|
12
- template "active_admin_#{e}.css.scss", "app/assets/stylesheets/active_admin_#{e}.css.scss"
13
- end
14
- end
15
-
16
- end
17
- end
18
- end
@@ -1,28 +0,0 @@
1
- body.active_admin {
2
- #page_title {
3
- position: relative;
4
- }
5
- #page_title:before {
6
- content: "Development - ";
7
- padding-left: 40px;
8
- color: #5e6469;
9
- }
10
- #page_title:after {
11
- position: absolute;
12
- top: -8px;
13
- left: 0;
14
- width: 30px;
15
- height: 30px;
16
- padding: 0;
17
- -webkit-border-radius: 100%;
18
- -moz-border-radius: 100%;
19
- border-radius: 100%;
20
- background: #5e6469;
21
- content: "!";
22
- color: #ffffff;
23
- text-align: center;
24
- line-height: 30px;
25
- font-weight: normal;
26
- font-size: 24px
27
- }
28
- }
@@ -1,32 +0,0 @@
1
- body.active_admin {
2
- #header{
3
- background: -webkit-linear-gradient(-90deg, #6a7176, #0000ff);
4
- }
5
-
6
- #page_title {
7
- position: relative;
8
- }
9
- #page_title:before {
10
- content: "Staging - ";
11
- padding-left: 40px;
12
- color: #0066ff;
13
- }
14
- #page_title:after {
15
- position: absolute;
16
- top: -8px;
17
- left: 0;
18
- width: 30px;
19
- height: 30px;
20
- padding: 0;
21
- -webkit-border-radius: 100%;
22
- -moz-border-radius: 100%;
23
- border-radius: 100%;
24
- background: #0066ff;
25
- content: "!";
26
- color: #ffffff;
27
- text-align: center;
28
- line-height: 30px;
29
- font-weight: normal;
30
- font-size: 24px
31
- }
32
- }