if_statement 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -30,14 +30,34 @@ feature :nuke do
30
30
  end
31
31
  ```
32
32
 
33
+ ## Installation
34
+
35
+ In a Rails 3 project, add this to your `Gemfile`:
36
+
37
+ ``` ruby
38
+ gem 'if_statement'
39
+ ```
40
+
41
+ and then run `bundle install`
42
+
33
43
  ## Setting what these thing evalute to
34
44
 
35
- The best place for now would be `config/initializers/if_statement.rb`:
45
+ Global settings should be in `config/features.rb`:
46
+
47
+ ``` ruby
48
+ IfStatement.setup do
49
+ set(:nuts) { current_person.has_no :allergies }
50
+ set :wipe_db, false
51
+ end
52
+ ```
53
+
54
+ Environment specific settings can be in `config/features/environment.rb`:
36
55
 
37
56
  ``` ruby
57
+ # config/features/development.rb
38
58
  IfStatement.setup do
39
59
  set(:nuts) { current_person.has_no :allergies }
40
- set :nuke, Rails.env.production?
60
+ set :wipe_db, true
41
61
  end
42
62
  ```
43
63
 
@@ -0,0 +1,22 @@
1
+ require 'if_statement'
2
+ require 'rails'
3
+
4
+ module IfStatement
5
+ class Railtie < Rails::Railtie
6
+
7
+ # loaded on Rails initialization
8
+ initializer "if_statement.configure_rails_initialization" do
9
+ ActionController::Base.send :include, IfStatement::Features
10
+ ActiveRecord::Base.send :include, IfStatement::Features
11
+ ActionView::Base.send :include, IfStatement::Features
12
+ end
13
+
14
+ config.to_prepare do
15
+ global_config = Rails.root.join 'config', 'features.rb'
16
+ local_config = Rails.root.join 'config', 'features', "#{ Rails.env }.rb"
17
+
18
+ load global_config if File.exists? global_config
19
+ load local_config if File.exists? local_config
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module IfStatement
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/if_statement.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'if_statement/version'
2
2
  require 'if_statement/features'
3
+ require 'if_statement/railtie' if defined? Rails
3
4
 
4
5
  module IfStatement
5
6
  class << self
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: if_statement
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Lunny
@@ -52,9 +52,8 @@ files:
52
52
  - install.rb
53
53
  - lib/if_statement.rb
54
54
  - lib/if_statement/features.rb
55
- - lib/if_statement/import.rb
55
+ - lib/if_statement/railtie.rb
56
56
  - lib/if_statement/version.rb
57
- - rails/init.rb
58
57
  - spec/if_statement_features_spec.rb
59
58
  - spec/if_statement_spec.rb
60
59
  - spec/spec_helper.rb
@@ -1,6 +0,0 @@
1
- # import the IfStatement methods into the core Rails classes
2
- ActionController::Base.send :include, IfStatement::Features
3
-
4
- ActiveRecord::Base.send :include, IfStatement::Features
5
-
6
- ActionView::Base.send :include, IfStatement::Features
data/rails/init.rb DELETED
@@ -1,2 +0,0 @@
1
- require "if_statement"
2
- require "if_statement/import"