variants 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,25 +1,45 @@
1
- # Variants [ ![Build status](http://travis-ci.org/kossnocorp/variants.png) ](http://travis-ci.org/kossnocorp/variants)
1
+ # Variants gem — be boss of your views [ ![Build status](http://travis-ci.org/kossnocorp/variants.png) ](http://travis-ci.org/kossnocorp/variants)
2
2
 
3
- Be boss of your views.
3
+ Your views are full of conditions and looks like mess of **if** and **else**'s you should know how hard work with it. Variants created to solve this promblem.
4
4
 
5
- TODO: More info, stay in touch.
5
+ This project uses Semantic Versioning for release numbering.
6
+
7
+ ## Usage
8
+
9
+ `app/views/layouts/application.html.haml`:
10
+
11
+ ``` haml
12
+ %ul
13
+ - if v :logged_in?
14
+ %li= link_to 'Sign Out', sign_out_path
15
+ - else
16
+ %li= link_to 'Sign In', sign_in_path
17
+ %li= link_to 'Sign Up', sign_up_path
18
+ ```
19
+
20
+ ![Screenshot #1](https://github.com/kossnocorp/variants/raw/master/doc/screenshot_1.png)
21
+
22
+ If you want to see some page as if you are logged in you can just pass GET param:
23
+
24
+ `http://example.dev/?logged_in?=true`
25
+
26
+ ![Screenshot #1](https://github.com/kossnocorp/variants/raw/master/doc/screenshot_2.png)
6
27
 
7
28
  ## Installation
8
29
 
9
- Puts this line into Gemfile:
30
+ Puts this line into `Gemfile` then run `$ bundle`:
10
31
 
11
32
  ``` ruby
12
- gem 'variants', '0.1.0'
33
+ gem 'variants', '0.2.0'
13
34
  ```
14
35
 
15
- ## Examples
36
+ Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:
16
37
 
17
- ``` haml
18
- - if variant :logged_in?
19
- = link_to 'Sign out', sign_out_path
38
+ ``` ruby
39
+ config.gem 'variants', :version => '0.2.0'
20
40
  ```
21
41
 
22
- TODO: Examples, examples, examples
42
+ Or manually install variants gem: `$ gem install variants`
23
43
 
24
44
  ## API
25
45
 
Binary file
Binary file
@@ -11,7 +11,10 @@ module Variants
11
11
  if Rails.env.development?
12
12
  # Override conditions if params[:variant_name] is presented
13
13
  unless self.params[name].nil?
14
- return self.params[name].to_s == 'true'
14
+ if force_variant = self.params[name].to_s == 'true'
15
+ self.send("on_#{name.to_s}", *args) if self.respond_to?("on_#{name.to_s}")
16
+ end
17
+ return force_variant
15
18
  end
16
19
  end
17
20
 
@@ -1,3 +1,3 @@
1
1
  module Variants
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -112,6 +112,24 @@ describe Variants do
112
112
 
113
113
  end
114
114
 
115
+ context 'run fake data helper' do
116
+
117
+ it 'should call fake data helper if is defined' do
118
+ self.stub!(:params).and_return( { 'variant_name' => true }.with_indifferent_access )
119
+ self.should_receive(:on_variant_name)
120
+ self.variant(:variant_name, 42)
121
+ end
122
+
123
+ it 'should pass arguments to fake data helper' do
124
+ self.stub!(:params).and_return( { 'variant_name' => true }.with_indifferent_access )
125
+ self.should_receive(:on_variant_name).with(42)
126
+ self.should_receive(:another_variant_name).with(42, 11).and_return(true)
127
+ self.variant(:variant_name, 42)
128
+ self.variant(:another_variant_name, 42, 11)
129
+ end
130
+
131
+ end
132
+
115
133
  end
116
134
 
117
135
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ['kossnocorp@gmail.com']
11
11
  s.homepage = ""
12
12
  s.summary = %q{Be boss of your views}
13
- s.description = %q{Be boss of your views}
13
+ s.description = %q{Your views are full of conditions and looks like mess of if and else's you should know how hard work with it. Variants created to solve this problem.}
14
14
 
15
15
  s.rubyforge_project = "variants"
16
16
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: variants
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sasha Koss
@@ -15,10 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-01 00:00:00 Z
18
+ date: 2011-05-10 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: Be boss of your views
21
+ description: Your views are full of conditions and looks like mess of if and else's you should know how hard work with it. Variants created to solve this problem.
22
22
  email:
23
23
  - kossnocorp@gmail.com
24
24
  executables: []
@@ -35,6 +35,8 @@ files:
35
35
  - Gemfile
36
36
  - README.md
37
37
  - Rakefile
38
+ - doc/screenshot_1.png
39
+ - doc/screenshot_2.png
38
40
  - lib/variants.rb
39
41
  - lib/variants/helpers.rb
40
42
  - lib/variants/version.rb