envie 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 +108 -0
- data/Rakefile +1 -5
- data/lib/envie.rb +13 -12
- data/spec/unit/envie_spec.rb +15 -6
- metadata +76 -89
- data/README.rdoc +0 -19
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
envie
|
2
|
+
=====
|
3
|
+
|
4
|
+
Feature toggles made easy.
|
5
|
+
|
6
|
+
Non rails usage
|
7
|
+
---------------
|
8
|
+
|
9
|
+
Creating two enviroments:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
production = Envie.production.with(:oauth)
|
13
|
+
development = production.derive.with(:openid)
|
14
|
+
```
|
15
|
+
|
16
|
+
And now making available code for specific features
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
if Envie.has?(:oauth)
|
20
|
+
# code that will run only if oauth is available
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
if Envie.has?(:openid)
|
26
|
+
# code that will run only if openid is available
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
There's a shorthand as well
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
if Envie.oauth?
|
34
|
+
# code that will run only if oauth is available
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Caveat: this won't work with some names as the following methods are already defined:
|
39
|
+
|
40
|
+
:has?, :include?, :const_defined?, :class_variable_defined?, :method_defined?,
|
41
|
+
:public_method_defined?, :private_method_defined?, :protected_method_defined?,
|
42
|
+
:autoload?, :anonymous?, :reachable?, :qualified_const_defined?, :duplicable?,
|
43
|
+
:traced?, :trace_disabled?, :any_unrecognized_keys?, :newrelic_method_exists?,
|
44
|
+
:traced_method_exists?, :in?, :blank?, :present?, :acts_like?, :html_safe?,
|
45
|
+
:is_haml?, :method_exists?, :nil?, :eql?, :tainted?, :untrusted?, :frozen?,
|
46
|
+
:instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :respond_to?,
|
47
|
+
:respond_to_missing?, :equal?
|
48
|
+
|
49
|
+
Code is attached to features, not enviroments, so one can easily move the feature from one place
|
50
|
+
to another without having to "grep" and find all its usage.
|
51
|
+
|
52
|
+
Rails usage
|
53
|
+
-----------
|
54
|
+
|
55
|
+
Set up your enviroment at enviroment.rb
|
56
|
+
|
57
|
+
your definitions must go between application and initilization, e.g.:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require File.expand_path('../application', __FILE__)
|
61
|
+
|
62
|
+
|
63
|
+
# setup feature toggles
|
64
|
+
Envie.production
|
65
|
+
|
66
|
+
Envie.development.with(:geewiz)
|
67
|
+
|
68
|
+
#pick a default
|
69
|
+
Envie.use :development
|
70
|
+
|
71
|
+
# Initialize the rails application
|
72
|
+
Solmarket::Application.initialize!
|
73
|
+
```
|
74
|
+
|
75
|
+
then in environments/production.rb
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Envie.use(:production)
|
79
|
+
```
|
80
|
+
|
81
|
+
now just use the features everywhere: in your routes, controllers and erb (or haml) templates.
|
82
|
+
|
83
|
+
Contributing with Rails usage?
|
84
|
+
|
85
|
+
We are expecting contributions that automatically define enviroments by reading an active record table.
|
86
|
+
|
87
|
+
Installing
|
88
|
+
----------
|
89
|
+
|
90
|
+
gem install envie
|
91
|
+
|
92
|
+
Contributing to envie
|
93
|
+
---------------------
|
94
|
+
|
95
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
96
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
97
|
+
* Fork the project
|
98
|
+
* Start a feature/bugfix branch
|
99
|
+
* Commit and push until you are happy with your contribution
|
100
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
101
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
102
|
+
|
103
|
+
Copyright
|
104
|
+
---------
|
105
|
+
|
106
|
+
Copyright (c) 2011 Guilherme Silveira. See LICENSE.txt for
|
107
|
+
further details.
|
108
|
+
|
data/Rakefile
CHANGED
@@ -19,11 +19,7 @@ Jeweler::Tasks.new do |gem|
|
|
19
19
|
gem.description = %Q{Simple api on feature toggle}
|
20
20
|
gem.email = "guilherme.silveira@caelum.com.br"
|
21
21
|
gem.authors = ["Guilherme Silveira"]
|
22
|
-
gem.version = "0.
|
23
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
24
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
25
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
26
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
22
|
+
gem.version = "0.2.0"
|
27
23
|
end
|
28
24
|
Jeweler::RubygemsDotOrgTasks.new
|
29
25
|
|
data/lib/envie.rb
CHANGED
@@ -2,34 +2,35 @@ require 'envie/env'
|
|
2
2
|
require 'envie/featurable'
|
3
3
|
module Envie
|
4
4
|
class << self
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :current
|
7
|
-
|
7
|
+
|
8
8
|
def all
|
9
9
|
@envs ||= {}
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def method_missing(name)
|
13
|
-
|
13
|
+
if name =~ /^(.*)\?$/
|
14
|
+
feature = $1.to_sym
|
15
|
+
has?(feature)
|
16
|
+
else
|
17
|
+
at(name)
|
18
|
+
end
|
14
19
|
end
|
15
|
-
|
20
|
+
|
16
21
|
def at(name)
|
17
22
|
all[name] ||= Env.new
|
18
23
|
end
|
19
|
-
|
24
|
+
|
20
25
|
def has?(name)
|
21
26
|
@current.has?(name)
|
22
27
|
end
|
23
|
-
|
28
|
+
|
24
29
|
def use(name)
|
25
30
|
@current = at(name)
|
26
31
|
end
|
27
32
|
|
28
33
|
end
|
29
|
-
|
34
|
+
|
30
35
|
Envie.use :production
|
31
36
|
end
|
32
|
-
|
33
|
-
class Object
|
34
|
-
include Envie::Featurable
|
35
|
-
end
|
data/spec/unit/envie_spec.rb
CHANGED
@@ -1,23 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Envie do
|
4
|
-
|
4
|
+
|
5
5
|
context "using envie" do
|
6
|
-
|
6
|
+
|
7
7
|
it "should not duplicate environments at each call" do
|
8
8
|
Envie.extra.should == Envie.extra
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "using should change current the one" do
|
12
12
|
Envie.use(:extra)
|
13
13
|
Envie.current.should == Envie.extra
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should check with the current scope" do
|
17
17
|
Envie.current.should_receive(:has?).with(:magic).and_return(true)
|
18
18
|
Envie.has?(:magic).should == true
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
|
+
it "should check with the current scope" do
|
22
|
+
Envie.current.should_receive(:has?).with(:magic).and_return(true)
|
23
|
+
Envie.has?(:magic).should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should respond to foo? like has?(:foo)" do
|
27
|
+
Envie.current.should_receive(:has?).with(:magic).and_return(true)
|
28
|
+
Envie.magic?.should == true
|
29
|
+
end
|
21
30
|
end
|
22
|
-
|
31
|
+
|
23
32
|
end
|
metadata
CHANGED
@@ -1,101 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: envie
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 0.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Guilherme Silveira
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type: :development
|
23
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 3
|
32
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 2.3.0
|
34
|
-
requirement: *id001
|
35
|
-
prerelease: false
|
36
|
-
name: rspec
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
22
|
type: :development
|
39
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
25
|
none: false
|
41
|
-
requirements:
|
26
|
+
requirements:
|
42
27
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 1
|
47
|
-
- 0
|
48
|
-
- 0
|
49
|
-
version: 1.0.0
|
50
|
-
requirement: *id002
|
51
|
-
prerelease: false
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
52
31
|
name: bundler
|
53
|
-
|
54
|
-
type: :development
|
55
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
56
33
|
none: false
|
57
|
-
requirements:
|
34
|
+
requirements:
|
58
35
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
- 1
|
63
|
-
- 5
|
64
|
-
- 2
|
65
|
-
version: 1.5.2
|
66
|
-
requirement: *id003
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.0.0
|
38
|
+
type: :development
|
67
39
|
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
68
47
|
name: jeweler
|
69
|
-
|
70
|
-
type: :development
|
71
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
72
49
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
|
78
|
-
- 0
|
79
|
-
version: "0"
|
80
|
-
requirement: *id004
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.5.2
|
54
|
+
type: :development
|
81
55
|
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.2
|
62
|
+
- !ruby/object:Gem::Dependency
|
82
63
|
name: rcov
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
83
78
|
description: Simple api on feature toggle
|
84
79
|
email: guilherme.silveira@caelum.com.br
|
85
80
|
executables: []
|
86
|
-
|
87
81
|
extensions: []
|
88
|
-
|
89
|
-
extra_rdoc_files:
|
82
|
+
extra_rdoc_files:
|
90
83
|
- LICENSE.txt
|
91
|
-
- README.
|
92
|
-
files:
|
84
|
+
- README.md
|
85
|
+
files:
|
93
86
|
- .document
|
94
87
|
- .rspec
|
95
88
|
- Gemfile
|
96
89
|
- Gemfile.lock
|
97
90
|
- LICENSE.txt
|
98
|
-
- README.
|
91
|
+
- README.md
|
99
92
|
- Rakefile
|
100
93
|
- lib/envie.rb
|
101
94
|
- lib/envie/env.rb
|
@@ -105,41 +98,35 @@ files:
|
|
105
98
|
- spec/unit/env_spec.rb
|
106
99
|
- spec/unit/envie_spec.rb
|
107
100
|
- spec/unit/featurable_spec.rb
|
108
|
-
has_rdoc: true
|
109
101
|
homepage: http://github.com/caelum/envie
|
110
|
-
licenses:
|
102
|
+
licenses:
|
111
103
|
- MIT
|
112
104
|
post_install_message:
|
113
105
|
rdoc_options: []
|
114
|
-
|
115
|
-
require_paths:
|
106
|
+
require_paths:
|
116
107
|
- lib
|
117
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
109
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
segments:
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
segments:
|
124
115
|
- 0
|
125
|
-
|
126
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
hash: -3665411169633953052
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
118
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
135
123
|
requirements: []
|
136
|
-
|
137
124
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.
|
125
|
+
rubygems_version: 1.8.19
|
139
126
|
signing_key:
|
140
127
|
specification_version: 3
|
141
128
|
summary: Simple api on feature toggle
|
142
|
-
test_files:
|
129
|
+
test_files:
|
143
130
|
- spec/acceptance_spec.rb
|
144
131
|
- spec/spec_helper.rb
|
145
132
|
- spec/unit/env_spec.rb
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= envie
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to envie
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
-
* Fork the project
|
10
|
-
* Start a feature/bugfix branch
|
11
|
-
* Commit and push until you are happy with your contribution
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2011 Guilherme Silveira. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|