icecream 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -3
- data/lib/icecream/icecream.rb +11 -5
- data/lib/icecream/parser.rb +6 -7
- data/lib/icecream/version.rb +1 -1
- data/spec/icecream_spec.rb +6 -1
- data/spec/spec_helper.rb +1 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d3284c4ec7126ea27315c9fb988eb520b3eea2
|
4
|
+
data.tar.gz: 3b3418fbaec1abadb22e42cee1b4ccddd04afb48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1325bdda2ddb18ab4dcfa12cbc0abbc22ae674127b04550d4496dbc2b11a71bc6b924e1ad93131e2630fee52b26c077e66116c789681021bd49e77304fd365da
|
7
|
+
data.tar.gz: 52d8f01795acdadcc07e68e5c2795f5527a7b6aff5277a875cf1e3ecc0a498f931812954500049275ecc94524edc1b86b3baf4d4cbf4a05a85daf2d557007aef
|
data/README.md
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
ICECREAM
|
2
|
+
=======================================
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/icecream.png)](http://badge.fury.io/rb/icecream)
|
5
4
|
[![Build Status](https://secure.travis-ci.org/camiloribeiro/icecream.png)](http://travis-ci.org/camiloribeiro/icecream)
|
6
5
|
[![Dependency Status](https://gemnasium.com/camiloribeiro/icecream.png)](https://gemnasium.com/camiloribeiro/icecream)
|
@@ -8,6 +7,20 @@ IceCream
|
|
8
7
|
[![Coverage Status](https://coveralls.io/repos/camiloribeiro/icecream/badge.png)](https://coveralls.io/r/camiloribeiro/icecream)
|
9
8
|
[![endorse](https://api.coderwall.com/camiloribeiro/endorsecount.png)](https://coderwall.com/camiloribeiro)
|
10
9
|
|
10
|
+
. , “Without ice cream, there would be darkness and chaos.”
|
11
|
+
* ― Don Kardong
|
12
|
+
` *~.|,~* '
|
13
|
+
' ,~*~~* ` _ “Ice cream is happiness condensed.”
|
14
|
+
,* / \`* ' // ― Jessie Lane Adams
|
15
|
+
,* ; \,O. //
|
16
|
+
,(:::)=// “... everyone knows that ice cream is worth the trouble of being cold.
|
17
|
+
( `~(###) Like all things virtuous, you have to suffer to gain the reward.”
|
18
|
+
%---'`"y ― Brandon Sanderson, The Rithmatist
|
19
|
+
\ /
|
20
|
+
\ / “There were some problems only coffee and ice cream could fix.”
|
21
|
+
__)(__ ― Amal El-Mohtar, Steam-Powered: Lesbian Steampunk Stories
|
22
|
+
'------`
|
23
|
+
|
11
24
|
I was looking for a really simple factory gem, such as factory_girl, but without any magic to use with rails. I was incompetent at that, so I built this really simple factory called IceCream.
|
12
25
|
|
13
26
|
The Idea
|
@@ -79,6 +92,8 @@ Contributing
|
|
79
92
|
|
80
93
|
Fork and send pull requests, as usual. Thank you! :)
|
81
94
|
|
95
|
+
IceCream ASCII art from: http://ascii.co.uk/art/icecream
|
96
|
+
|
82
97
|
LICENCE
|
83
98
|
-------------
|
84
99
|
|
@@ -91,3 +106,5 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
91
106
|
http://www.apache.org/licenses/LICENSE-2.0
|
92
107
|
|
93
108
|
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
109
|
+
|
110
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/camiloribeiro/icecream/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
data/lib/icecream/icecream.rb
CHANGED
@@ -5,10 +5,14 @@ module IceCream
|
|
5
5
|
|
6
6
|
def self.flavor flavor_name, flavor_details
|
7
7
|
object = Parser.objectify flavor_name.to_s, flavor_details
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
.gsub("[","")
|
9
|
+
.gsub("]","")
|
10
|
+
.split(",")
|
11
|
+
.map
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
instance_variables
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
@@ -24,7 +28,9 @@ module IceCream
|
|
24
28
|
end
|
25
29
|
|
26
30
|
def self.merge flavor, comp_flavor
|
27
|
-
|
31
|
+
flavor.instance_variables.each do |variable|
|
32
|
+
flavor.send("#{variable.to_s[1,variable.to_s.size-1]}=".to_sym, comp_flavor.send(variable[1,variable.size-1].to_sym)) if comp_flavor.instance_variables.include? variable.to_sym
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
def initialize(path)
|
data/lib/icecream/parser.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module IceCream
|
3
2
|
class Parser
|
4
3
|
|
@@ -10,7 +9,7 @@ module IceCream
|
|
10
9
|
private
|
11
10
|
|
12
11
|
def self.get_flavor_name path
|
13
|
-
|
12
|
+
title = slice_between_strings(path, "/flavors/", ".flavor")
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.parse_variables particularity
|
@@ -20,12 +19,13 @@ module IceCream
|
|
20
19
|
def self.parse_values particularity
|
21
20
|
particularity.split("=").last.strip
|
22
21
|
end
|
22
|
+
|
23
23
|
def self.slice_between_strings(string, str_start, str_end)
|
24
24
|
start_at = string.index(str_start).to_i + str_start.size
|
25
25
|
end_at = string.index(str_end)
|
26
26
|
string = string.slice start_at..end_at-1
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def self.fix_value value
|
30
30
|
if (value[0] == "[") && (value[-1, 1] == "]")
|
31
31
|
final = value.gsub("[","") .gsub("]","").split(",").map {|element| fix_value element.strip }
|
@@ -43,8 +43,9 @@ module IceCream
|
|
43
43
|
final = ""
|
44
44
|
end
|
45
45
|
final
|
46
|
-
|
46
|
+
|
47
47
|
end
|
48
|
+
|
48
49
|
def self.objectify flavor, all_particularities
|
49
50
|
class_name = flavor.capitalize
|
50
51
|
|
@@ -57,9 +58,7 @@ module IceCream
|
|
57
58
|
|
58
59
|
variables = all_particularities.each { | particularity | parse_variables particularity }
|
59
60
|
values = all_particularities.each { | particularity | parse_values particularity }
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
|
63
62
|
klass.class_eval do
|
64
63
|
attr_accessor *variables
|
65
64
|
|
data/lib/icecream/version.rb
CHANGED
data/spec/icecream_spec.rb
CHANGED
@@ -6,6 +6,11 @@ describe "Icecream" do
|
|
6
6
|
before(:each) do
|
7
7
|
@fridge = IceCream::IceCream.new File.join(File.dirname(__FILE__),"flavors")
|
8
8
|
end
|
9
|
+
|
10
|
+
it "returns all flavors" do
|
11
|
+
@fridge.all.should eq [:@apple, :@chocolate, :@cream]
|
12
|
+
end
|
13
|
+
|
9
14
|
it "has objects for each file in the factory filder" do
|
10
15
|
|
11
16
|
chocolate = @fridge.flavor :chocolate
|
@@ -41,7 +46,7 @@ describe "Icecream" do
|
|
41
46
|
it "merges the objects" do
|
42
47
|
cream = @fridge.flavor :cream
|
43
48
|
complementary_flavor = IceCream::IceCream.flavor :Orange, "[name = 'orange', price = 35.5]"
|
44
|
-
|
49
|
+
|
45
50
|
IceCream::IceCream.merge cream, complementary_flavor
|
46
51
|
|
47
52
|
cream.class.should be Cream
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icecream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -112,8 +112,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project: cello
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.4.4
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Simple Factory to the ones who just wanna a factory
|
119
|
-
test_files:
|
119
|
+
test_files:
|
120
|
+
- spec/flavors/apple.flavor
|
121
|
+
- spec/flavors/chocolate.flavor
|
122
|
+
- spec/flavors/cream.flavor
|
123
|
+
- spec/icecream_spec.rb
|
124
|
+
- spec/parser_spec.rb
|
125
|
+
- spec/spec_helper.rb
|