icecream 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34ed85459ee26a0ae8f61298e8a406c8a68b7c86
4
- data.tar.gz: dcb254332f4362c31006254f95d24c19a0b10c07
3
+ metadata.gz: 82e9776464a75175104c839f1639376b1ed9e62a
4
+ data.tar.gz: 2cc5414e69e87b049a53d088ed2c4c6eb2ff3d64
5
5
  SHA512:
6
- metadata.gz: 3e4c82d5ea344431394d13c91c84bd3f7459f5d7ba9aeb6ee74e4b914430867f9da8b397db36e8270ba5e0a48cc5d2245fc2c58385f7088b649ce5137cf8db1f
7
- data.tar.gz: 4e916af70805783fe9bceb48a73e6403dd24e5e4646ce8fb5727018362a3c87af0b8506d22c4489097acdc1f275f1578914565cdcd0f2e8d5c6ca277ab4f2d5c
6
+ metadata.gz: 41a1c9e18c71c4a84ca6e5a4e2e297972f079bf018e83fce0138b1bbc61de6f1aeb8c0bc8e8f23142deaed41964f1c67ebc38445f20eb45405f063eaa969a66e
7
+ data.tar.gz: 8daba892d5280fe2fab8e3fca4f8623168dc37e0b2bbb6e019a57b00d3d3be1bc1caacd07b4f5def68970f7254fdd546c3760953f31e7b9451bb4d803dce1b13
data/README.md CHANGED
@@ -60,6 +60,18 @@ You can also, define an object from nowhere, creating it with a single line!
60
60
 
61
61
  $ IceCream::IceCream.flavor :Orange, "[name = 'orange', color = :orange, price = 35.5, calories = 3]"
62
62
 
63
+ If you are working with big sets of data, you can update information of an object with the information of another object using merge. For instance:
64
+
65
+ $ chocolate = @fridge.flavor :chocolate
66
+ # it has: name => "chocolate", color => :brown, price => 15.5 and calories => 150.
67
+
68
+ $ update = IceCream::IceCream.flavor :Update_chocolate, "[name = 'Dark Chocolate', price = 55.5]"
69
+ # you created a new object with part of the data that chocolate has
70
+
71
+ $ IceCream::IceCream.merge chocolate, update
72
+ $ chocolate
73
+ # returns: name => "Dark Chocolate", color => :brown, price => 55.5 and calories => 150.
74
+
63
75
  Have fun!
64
76
 
65
77
  Contributing
@@ -23,6 +23,10 @@ module IceCream
23
23
  end
24
24
  end
25
25
 
26
+ def self.merge flavor, comp_flavor
27
+ flavor.instance_variables.each {|variable| 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 }
28
+ end
29
+
26
30
  def initialize(path)
27
31
  Dir.glob("#{path}/*.flavor") do |flavor_file_path|
28
32
  flavor = Parser.get_flavor flavor_file_path
@@ -1,3 +1,3 @@
1
1
  module IceCream
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -3,8 +3,10 @@ require File.dirname(__FILE__) + "/spec_helper"
3
3
 
4
4
  describe "Icecream" do
5
5
  describe "Gets all the objects to factory directory" do
6
- it "has objects for each file in the factory filder" do
6
+ before(:each) do
7
7
  @fridge = IceCream::IceCream.new File.join(File.dirname(__FILE__),"flavors")
8
+ end
9
+ it "has objects for each file in the factory filder" do
8
10
 
9
11
  chocolate = @fridge.flavor :chocolate
10
12
  chocolate.class.should be Chocolate
@@ -36,5 +38,17 @@ describe "Icecream" do
36
38
  new_flavor.price.should eq 35.5
37
39
  new_flavor.calories.should eq 3
38
40
  end
41
+ it "merges the objects" do
42
+ cream = @fridge.flavor :cream
43
+ complementary_flavor = IceCream::IceCream.flavor :Orange, "[name = 'orange', price = 35.5]"
44
+
45
+ IceCream::IceCream.merge cream, complementary_flavor
46
+
47
+ cream.class.should be Cream
48
+ cream.name.should eq "orange"
49
+ cream.color.should eq :yellow
50
+ cream.price.should eq 35.5
51
+ cream.calories.should eq 200
52
+ end
39
53
  end
40
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icecream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Ribeiro