sell_object 0.1.3 → 0.1.4

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: e66f41e5be9b9edf6af8dd1aa6db9593b9e57029
4
- data.tar.gz: d8005a5e92b84d1228e94ff025291489f92016b4
3
+ metadata.gz: 665de705c01ee47f22ee95e56e6d8f82dd62a366
4
+ data.tar.gz: 9f0d8b807b17be2ccabfd34d169acdab16b55997
5
5
  SHA512:
6
- metadata.gz: fb98d17c1d0624b74b641f84cf7daf431dbb96b17b3ed8ee7c3158697644dc2770ca593502dcf07686feef4453f9b96a86181eab003402fe60247265aca0ae67
7
- data.tar.gz: 114e737c66420a74851a29ca6c8c9496ef893798e9dbdd38114376aaf1e07b49b5d5de88e8a2bfdc773bc1ed8a15eee7d80a95f0916c1c8b9405848f53b78f80
6
+ metadata.gz: ebd40595762cc31d6bb553ca92ea62b2adc0a8ae68e65c88a45ce15ab0d678f51b43259fd70db786c958cfbb26a1e09fb2e51a9726ad7e210e045e80c9435ec4
7
+ data.tar.gz: d8819b592e8bc6b5857b464cab798a4393ab77e9cdc042090d3d639f43f090f75fbcb875ded15736d3d56a9842b0f6cce71e4c8b8ba6dad5e5c549585d83169f
data/.travis.yml CHANGED
@@ -1,6 +1,2 @@
1
1
  language: ruby
2
2
  script: bundle exec rspec spec
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1.0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
1
  ## v0.1.0
2
2
 
3
- * initial release with shopping engines: ShoppingUOL (Brazil) and Buscape (Brazil)
3
+ * initial release with shopping engines: ShoppingUOL (Brazil) and Buscape (Brazil)
4
+
5
+ ## v0.1.4
6
+
7
+ * Drop dependency for ruby 1.9.3
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # SellObject
2
2
 
3
- By [Ima Bold](http://imabold.com).
4
-
5
3
  [![Code Climate](https://codeclimate.com/github/imaboldcompany/sell_object.png)](https://codeclimate.com/github/imaboldcompany/sell_object)
6
- [![Build Status](https://travis-ci.org/imaboldcompany/sell_object.svg?branch=master)](https://travis-ci.org/imaboldcompany/sell_object)
4
+ [![Build Status](https://travis-ci.org/dferrazm/sell_object.svg?branch=master)](https://travis-ci.org/dferrazm/sell_object)
7
5
 
8
6
  SellObject is an extensible solution to make it easy exporting ruby objects to be used on price comparison shopping engines. The gem adds helper methods that format your objects, making them ready to be consumable by the supported price comparison engines.
9
7
 
@@ -38,7 +36,7 @@ This will add the SellObject initializer into your Rails config/initializers fol
38
36
 
39
37
  ### Setting up the class
40
38
 
41
- Suppose you have a class `Product` and want to make its objects sellable through Shopping UOL.
39
+ Suppose you have a class `Product` and want to make its objects sellable through Shopping UOL.
42
40
  You do that by using `sell_through` as shown below:
43
41
 
44
42
  ```ruby
@@ -73,16 +71,16 @@ SellObject comes with a default mapping to be applied through the exporting proc
73
71
  module SellObject
74
72
  module DefaultMappings
75
73
  def self.shopping_uol
76
- {
77
- :CODIGO => :id,
78
- :DESCRICAO => :description,
74
+ {
75
+ :CODIGO => :id,
76
+ :DESCRICAO => :description,
79
77
  :PRECO => :price,
80
78
  :URL => :url,
81
79
  :URL_IMAGEM => :image_url,
82
80
  :DEPARTAMENTO => :category
83
81
  }
84
82
  end
85
- end
83
+ end
86
84
  end
87
85
  ```
88
86
  If you want to use the default mapping, just make sure that the object responds to the required methods. In our example, `product` would have to respond to `:id`, `:description`, `:price` and so forth.
@@ -93,13 +91,13 @@ If you want to create your own mapping, you can define a module named with the o
93
91
  module SellObject
94
92
  module ProductMappings
95
93
  def self.shopping_uol
96
- {
97
- :CODIGO => :code,
98
- :DESCRICAO => :details,
94
+ {
95
+ :CODIGO => :code,
96
+ :DESCRICAO => :details,
99
97
  :URL => :web_page
100
98
  }
101
99
  end
102
- end
100
+ end
103
101
  end
104
102
  ```
105
103
  In this case, `product` would have to respond to `:code`, `:details` and `:web_page`. Note that we didn't overwrite all the attribute mappings. The leftovers will fall back to the default mapping. So in this example, `product` would still have to respond to the `:price`, `:image_url` and `:category` methods.
@@ -132,7 +130,7 @@ Here's the list of shopping engines that require a store name for the exporting
132
130
 
133
131
  ## Contributing
134
132
 
135
- Questions or problems? Please post them on the [issue tracker](https://github.com/imaboldcompany/sell_object/issues).
133
+ Questions or problems? Please post them on the [issue tracker](https://github.com/dferrazm/sell_object/issues).
136
134
 
137
135
  You can contribute by doing the following:
138
136
 
@@ -144,4 +142,4 @@ You can contribute by doing the following:
144
142
 
145
143
  ## License
146
144
 
147
- MIT License.
145
+ MIT License.
@@ -1,3 +1,3 @@
1
1
  module SellObject
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/sell_object.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["d.ferrazm@gmail.com"]
11
11
  spec.description = %q{Extensible solution to make it easy to export ruby objects to be used on price comparison shopping engines}
12
12
  spec.summary = %q{Sell your Ruby on Rails objects on price comparison shopping engines}
13
- spec.homepage = "http://github.com/imaboldcompany/sell_object"
13
+ spec.homepage = "http://github.com/dferrazm/sell_object"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -18,11 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = '>= 1.9.3'
22
-
23
21
  spec.add_development_dependency "bundler", "~> 1.3"
24
22
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
26
24
 
27
25
  spec.add_dependency "nokogiri"
28
26
  end
@@ -5,7 +5,7 @@ describe SellObject::Buscape::FormatterProxy do
5
5
  let(:formatter) { SellObject::Buscape::FormatterProxy.new target_object }
6
6
 
7
7
  it 'extends from SellObject::FormatterProxy' do
8
- expect(formatter.is_a? SellObject::FormatterProxy).to be_true
8
+ expect(formatter.is_a? SellObject::FormatterProxy).to be_truthy
9
9
  end
10
10
 
11
11
  describe '#preco' do
@@ -17,4 +17,4 @@ describe SellObject::Buscape::FormatterProxy do
17
17
  expect { formatter.preco :description }.to raise_error ArgumentError, 'method expects a number, got String: Lorem ipsum'
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -12,7 +12,7 @@ describe SellObject::Buscape do
12
12
  let(:product) { Product.new }
13
13
 
14
14
  before do
15
- SellObject::XmlFormatter.stub(:format).and_return 'xml element'
15
+ allow(SellObject::XmlFormatter).to receive(:format).and_return 'xml element'
16
16
  end
17
17
 
18
18
  describe 'class_methods' do
@@ -36,50 +36,50 @@ describe SellObject::Buscape do
36
36
  expect(remove_xml_noise product.to_buscape('My Awesome Store')).to match /<My_Awesome_Store><produtos>.*<\/produtos><\/My_Awesome_Store>/
37
37
  end
38
38
  end
39
- end
39
+ end
40
40
  end
41
- end
41
+ end
42
42
 
43
43
  describe '#wrap_xml' do
44
44
  before do
45
- SellObject::Config.stub(:store_name).and_return 'awesome'
45
+ allow(SellObject::Config).to receive(:store_name).and_return 'awesome'
46
46
  end
47
47
 
48
48
  it 'inserts the timestamp into the xml' do
49
49
  timestamp = Time.now.to_s
50
- subject.stub(:timestamp).and_return '2014-03-29 13:28:32 -0300'
50
+ allow(subject).to receive(:timestamp).and_return '2014-03-29 13:28:32 -0300'
51
51
  expect(subject.wrap_xml 'xml elements').to include '<!--2014-03-29 13:28:32 -0300-->'
52
52
  end
53
53
 
54
54
  it 'inserts the given elements inside the <produtos> tag' do
55
- expect(remove_xml_noise subject.wrap_xml('xml elements')).to include '<produtos>xml elements</produtos>'
55
+ expect(remove_xml_noise subject.wrap_xml('xml elements')).to include '<produtos>xml elements</produtos>'
56
56
  end
57
57
 
58
58
  it 'wraps the <produtos> tag with the store name set up in config' do
59
- SellObject::Config.stub(:store_name).and_return 'awesome'
59
+ allow(SellObject::Config).to receive(:store_name).and_return 'awesome'
60
60
  expect(remove_xml_noise subject.wrap_xml('elements')).to match /<awesome><produtos>.*<\/produtos><\/awesome>/
61
- end
61
+ end
62
62
 
63
63
  it 'raises an error if theres no store name set up' do
64
- SellObject::Config.stub(:store_name).and_return nil
64
+ allow(SellObject::Config).to receive(:store_name).and_return nil
65
65
  expect { subject.wrap_xml 'elements' }.to raise_error ArgumentError, 'No store name found (nil). You have to either pass it as an argument or set it up in SellObject::Config'
66
66
  end
67
67
 
68
68
  context 'when passing the store name as an argument' do
69
69
  it 'wraps the <produtos> tag with the given store name' do
70
70
  expect(remove_xml_noise subject.wrap_xml('elements', 'boring')).to match /<boring><produtos>.*<\/produtos><\/boring>/
71
- end
71
+ end
72
72
  end
73
73
  end
74
74
 
75
75
  describe '#timestamp' do
76
76
  it 'returns the time now correctly formatted' do
77
- Time.stub(:now).and_return Time.new(2014,3,28,10,42,48,'-03:00')
77
+ allow(Time).to receive(:now).and_return Time.new(2014,3,28,10,42,48,'-03:00')
78
78
  expect(subject.timestamp).to eq 'Generated at 2014-03-28T10:42:48GMT-3'
79
- Time.stub(:now).and_return Time.new(2011,1,4,17,22,58,'+01:00')
79
+ allow(Time).to receive(:now).and_return Time.new(2011,1,4,17,22,58,'+01:00')
80
80
  expect(subject.timestamp).to eq 'Generated at 2011-01-04T17:22:58GMT+1'
81
- Time.stub(:now).and_return Time.new(2011,1,4,17,22,58,'+00:00')
81
+ allow(Time).to receive(:now).and_return Time.new(2011,1,4,17,22,58,'+00:00')
82
82
  expect(subject.timestamp).to eq 'Generated at 2011-01-04T17:22:58GMT+0'
83
83
  end
84
84
  end
85
- end
85
+ end
@@ -5,7 +5,7 @@ describe SellObject::XmlFormatter do
5
5
  let(:target_object) { double some_value: 'some value' }
6
6
 
7
7
  before do
8
- SellObject.stub(:mapping_for).with(target_object, :foo).and_return({some_tag: :some_value})
8
+ allow(SellObject).to receive(:mapping_for).with(target_object, :foo).and_return({some_tag: :some_value})
9
9
  end
10
10
 
11
11
  it 'formats an object into a xml element based on its mapping, given an engine and a xml root' do
@@ -12,12 +12,8 @@ describe SellObject do
12
12
  Object.send :remove_const, :TargetClass
13
13
  end
14
14
 
15
- it 'makes the target class extend SellObject::ClassMethods' do
16
- expect(TargetClass.is_a? SellObject::ClassMethods).to be_true
17
- end
18
-
19
15
  describe 'ClassMethods' do
20
- describe '#sell_through' do
16
+ describe '#sell_through' do
21
17
  context 'passing invalid arguments' do
22
18
  it 'raises ArgumentError with an invalid engine' do
23
19
  expect { TargetClass.sell_through :foo }.to raise_error ArgumentError, 'invalid shopping engine foo'
@@ -28,22 +24,22 @@ describe SellObject do
28
24
  end
29
25
  end
30
26
 
31
- context 'buscape' do
27
+ context 'buscape' do
32
28
  it 'includes the module SellObject::Buscape in the target class' do
33
29
  TargetClass.sell_through :buscape
34
- expect(TargetClass.included_modules).to include SellObject::Buscape
30
+ expect(TargetClass.included_modules).to include SellObject::Buscape
35
31
  end
36
32
  end
37
33
 
38
- context 'shopping_uol' do
34
+ context 'shopping_uol' do
39
35
  it 'includes the module SellObject::ShoppingUol in the target class' do
40
36
  TargetClass.sell_through :shopping_uol
41
- expect(TargetClass.included_modules).to include SellObject::ShoppingUol
37
+ expect(TargetClass.included_modules).to include SellObject::ShoppingUol
42
38
  end
43
39
  end
44
40
  end
45
41
  end
46
- end
42
+ end
47
43
 
48
44
  describe '#supported_engines' do
49
45
  it 'returns the supported shopping engines array' do
@@ -59,13 +55,13 @@ describe SellObject do
59
55
  end
60
56
  expect(config_module.name).to eq 'SellObject::Config'
61
57
  end
62
- end
58
+ end
63
59
 
64
60
  describe '#mapping_for' do
65
61
  before do
66
- SellObject.stub(:supported_engines).and_return %w(bar)
67
- SellObject::DefaultMappings.stub(:bar).and_return({t1: :v1, t2: :v2})
68
-
62
+ allow(SellObject).to receive(:supported_engines).and_return %w(bar)
63
+ allow(SellObject::DefaultMappings).to receive(:bar).and_return({t1: :v1, t2: :v2})
64
+
69
65
  class TargetObject
70
66
  end
71
67
  end
@@ -83,7 +79,7 @@ describe SellObject do
83
79
  expect(subject.mapping_for TargetObject.new, :bar).to eq({t1: :v1, t2: :v2})
84
80
  end
85
81
  end
86
-
82
+
87
83
  context 'when there\s a custom mapping defined' do
88
84
  before do
89
85
  module SellObject::TargetObjectMappings
@@ -115,6 +111,6 @@ describe SellObject do
115
111
  subject.store_name = 'My Store'
116
112
  expect(subject.store_name).to eq 'My Store'
117
113
  end
118
- end
114
+ end
119
115
  end
120
- end
116
+ end
@@ -7,21 +7,21 @@ shared_examples_for 'shopping_engine' do |engine|
7
7
  let(:products) { [lame_product, boring_product] }
8
8
 
9
9
  before do
10
- lame_product.stub(:id).and_return 'PR1'
11
- lame_product.stub(:description).and_return 'Some lame product'
12
- lame_product.stub(:price).and_return 10.5
13
- lame_product.stub(:category).and_return 'Electronics'
14
- lame_product.stub(:url).and_return 'http://example.com/lame-product'
15
- lame_product.stub(:image_url).and_return 'http://example.com/images/lame-product.png'
10
+ allow(lame_product).to receive(:id).and_return 'PR1'
11
+ allow(lame_product).to receive(:description).and_return 'Some lame product'
12
+ allow(lame_product).to receive(:price).and_return 10.5
13
+ allow(lame_product).to receive(:category).and_return 'Electronics'
14
+ allow(lame_product).to receive(:url).and_return 'http://example.com/lame-product'
15
+ allow(lame_product).to receive(:image_url).and_return 'http://example.com/images/lame-product.png'
16
16
 
17
- boring_product.stub(:id).and_return 'PR2'
18
- boring_product.stub(:description).and_return 'Some boring product'
19
- boring_product.stub(:price).and_return 7
20
- boring_product.stub(:category).and_return 'Kitchenware'
21
- boring_product.stub(:url).and_return 'http://example.com/boring-product'
22
- boring_product.stub(:image_url).and_return 'http://example.com/images/boring-product.png'
17
+ allow(boring_product).to receive(:id).and_return 'PR2'
18
+ allow(boring_product).to receive(:description).and_return 'Some boring product'
19
+ allow(boring_product).to receive(:price).and_return 7
20
+ allow(boring_product).to receive(:category).and_return 'Kitchenware'
21
+ allow(boring_product).to receive(:url).and_return 'http://example.com/boring-product'
22
+ allow(boring_product).to receive(:image_url).and_return 'http://example.com/images/boring-product.png'
23
23
 
24
- SellObject::Config.stub(:store_name).and_return 'awesome_store'
24
+ allow(SellObject::Config).to receive(:store_name).and_return 'awesome_store'
25
25
  end
26
26
 
27
27
  describe 'class_methods' do
@@ -34,10 +34,10 @@ shared_examples_for 'shopping_engine' do |engine|
34
34
 
35
35
  context 'using custom mappings' do
36
36
  before do
37
- lame_product.stub(:custom_description).and_return 'My custom lame product description'
38
- lame_product.stub(:custom_url).and_return 'http://example.com/custom-lame-product'
39
- boring_product.stub(:custom_description).and_return 'My custom boring product description'
40
- boring_product.stub(:custom_url).and_return 'http://example.com/custom-boring-product'
37
+ allow(lame_product).to receive(:custom_description).and_return 'My custom lame product description'
38
+ allow(lame_product).to receive(:custom_url).and_return 'http://example.com/custom-lame-product'
39
+ allow(boring_product).to receive(:custom_description).and_return 'My custom boring product description'
40
+ allow(boring_product).to receive(:custom_url).and_return 'http://example.com/custom-boring-product'
41
41
 
42
42
  module SellObject::ProductMappings
43
43
  def self.buscape
@@ -47,7 +47,7 @@ shared_examples_for 'shopping_engine' do |engine|
47
47
  def self.shopping_uol
48
48
  { :DESCRICAO => :custom_description, :URL => :custom_url }
49
49
  end
50
- end
50
+ end
51
51
  end
52
52
 
53
53
  after do
@@ -57,7 +57,7 @@ shared_examples_for 'shopping_engine' do |engine|
57
57
  it 'generates the XML accordingly with all the objects attributes and the custom mappings' do
58
58
  expect(remove_xml_noise Product.send("to_#{engine}", products)).to eq remove_xml_noise macros::CUSTOM_MAPPING_FIXTURE_MANY
59
59
  end
60
- end
60
+ end
61
61
  end
62
62
  end
63
63
 
@@ -66,11 +66,6 @@ shared_examples_for 'shopping_engine' do |engine|
66
66
  it 'generates the XML accordingly with the object attributes' do
67
67
  expect(remove_xml_noise lame_product.send("to_#{engine}")).to eq remove_xml_noise macros::DEFAULT_MAPPING_FIXTURE_ONE
68
68
  end
69
-
70
- # it "calls the #to_#{engine} class method passing the instance wrapped in an array" do
71
- # Product.should_receive(:"to_#{engine}").with [lame_product]
72
- # lame_product.send "to_#{engine}"
73
- # end
74
- end
69
+ end
75
70
  end
76
- end
71
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sell_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Ferraz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Extensible solution to make it easy to export ruby objects to be used
@@ -74,9 +74,9 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
78
- - .rspec
79
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
80
  - CHANGELOG.md
81
81
  - Gemfile
82
82
  - LICENSE.txt
@@ -104,7 +104,7 @@ files:
104
104
  - spec/support/engine_macros.rb
105
105
  - spec/support/shared_examples/shopping_engine.rb
106
106
  - spec/support/spec_macros.rb
107
- homepage: http://github.com/imaboldcompany/sell_object
107
+ homepage: http://github.com/dferrazm/sell_object
108
108
  licenses:
109
109
  - MIT
110
110
  metadata: {}
@@ -114,17 +114,17 @@ require_paths:
114
114
  - lib
115
115
  required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - '>='
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 1.9.3
119
+ version: '0'
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.0.14
127
+ rubygems_version: 2.2.2
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Sell your Ruby on Rails objects on price comparison shopping engines