skroutz 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.pryrc ADDED
@@ -0,0 +1,10 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ def reload!
5
+ Object.send(:remove_const, :Skroutz)
6
+
7
+ $LOADED_FEATURES.find_all { |file| file =~ %r{\/skroutz\.rb\/} }.
8
+ each(&method(:load)).
9
+ any?
10
+ end
@@ -2,6 +2,19 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [0.1.2] - 2015-04-28
6
+
7
+ ### Added
8
+
9
+ * Favorite <- Sku assoiciation
10
+ * FavoriteList <- Favorite association
11
+ * JSON serialization capability of Skroutz::Resource
12
+ * reload! method for code reloading in development
13
+
14
+ ### Fixed
15
+
16
+ * Skroutz::Resource#resource handling for multiple word resources (eg. FavoriteList)
17
+
5
18
  ## [0.1.1] - 2015-03-29
6
19
 
7
20
  ### Removed
@@ -21,7 +21,7 @@ do so.
21
21
  * Read [how to properly contribute to open source projects on Github][2].
22
22
  * Fork the project.
23
23
  * Use a topic/feature branch to easily amend a pull request later, if necessary.
24
- * Write [good commit messages][3].
24
+ * Comply with our [git style guide](https://github.com/agis-/git-style-guide).
25
25
  * Use the same coding conventions as the rest of the project.
26
26
  * Commit and push until you are happy with your contribution.
27
27
  * Make sure to add tests for it. This is important so I don't break it
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # skroutz.rb
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/skroutz.svg)](http://badge.fury.io/rb/skroutz)
3
4
  [![Build Status](https://travis-ci.org/skroutz/skroutz.rb.svg?branch=master)](https://travis-ci.org/skroutz/skroutz.rb)
4
5
  [![Code Climate](https://codeclimate.com/github/skroutz/skroutz.rb/badges/gpa.svg)](https://codeclimate.com/github/skroutz/skroutz.rb)
5
6
  [![Coverage Status](https://coveralls.io/repos/skroutz/skroutz.rb/badge.svg)](https://coveralls.io/r/skroutz/skroutz.rb)
@@ -166,7 +167,7 @@ For every `Skroutz::Resource` the available associations can be inspected with:
166
167
  # => [:category, :similar, :products, :reviews, :specifications, :manufacturer]
167
168
  ```
168
169
 
169
- You may call any of the assocations listed you may them as methods like:
170
+ You may call any of the assocations listed as methods like:
170
171
 
171
172
  ```ruby
172
173
  iphone = skroutz.skus.find 390486
@@ -295,6 +296,18 @@ Fix any rubocop offences:
295
296
  bundle exec rubocop
296
297
  ```
297
298
 
299
+ ### Console
300
+
301
+ ```bash
302
+ pry -Ilib -rskroutz
303
+ ```
304
+
305
+ ### OAuth2.0 Credentials
306
+
307
+ In order for the client to make requests against our API,
308
+ a valid set of OAuth2.0 credentials provided by us has to be used.
309
+ To get yours send an email at [api@skroutz.gr](mailto: api@skroutz.gr).
310
+
298
311
  # LICENSE
299
312
 
300
313
  Copyright (c) 2015 Skroutz S.A, MIT Licence.
@@ -1 +1,3 @@
1
- class Skroutz::Favorite < Skroutz::Resource; end
1
+ class Skroutz::Favorite < Skroutz::Resource
2
+ association :sku
3
+ end
@@ -1 +1,3 @@
1
- class Skroutz::FavoriteList < Skroutz::Resource; end
1
+ class Skroutz::FavoriteList < Skroutz::Resource
2
+ association :favorites
3
+ end
@@ -3,13 +3,15 @@ class Skroutz::Resource
3
3
 
4
4
  attr_accessor :attributes, :client
5
5
 
6
+ alias :to_hash :attributes
7
+
6
8
  def initialize(attributes, client)
7
9
  @attributes = attributes
8
10
  @client = client
9
11
  end
10
12
 
11
13
  def resource
12
- @resource ||= self.class.to_s.demodulize.downcase
14
+ @resource ||= self.class.to_s.demodulize.tableize.singularize
13
15
  end
14
16
 
15
17
  def resource_prefix
@@ -1,3 +1,3 @@
1
1
  module Skroutz
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Skroutz::FavoriteList do
4
+ include_context 'resource'
5
+
6
+ let(:attributes) { {} }
7
+
8
+ subject(:favorite_list) { described_class.new(attributes, client) }
9
+
10
+ describe 'associations' do
11
+ subject { described_class.associations }
12
+
13
+ it { is_expected.to include :favorites }
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Skroutz::Favorite do
4
+ include_context 'resource'
5
+
6
+ let(:attributes) { {} }
7
+
8
+ subject(:favorite) { described_class.new(attributes, client) }
9
+
10
+ describe 'associations' do
11
+ subject { described_class.associations }
12
+
13
+ it { is_expected.to include :sku }
14
+ end
15
+ end
@@ -42,6 +42,28 @@ describe Skroutz::Resource do
42
42
  end
43
43
  end
44
44
 
45
+ describe '#resource' do
46
+ let(:class_name) { 'Favorite' }
47
+
48
+ before do
49
+ allow(resource).to receive_message_chain('class.to_s').and_return(class_name)
50
+ end
51
+
52
+ subject { resource.resource }
53
+
54
+ it { is_expected.to be_a(String) }
55
+
56
+ context 'when resource is a single word' do
57
+ it { is_expected.to eq('favorite') }
58
+ end
59
+
60
+ context 'when resource contains multiple words' do
61
+ let(:class_name) { 'FavoriteList' }
62
+
63
+ it { is_expected.to eq('favorite_list') }
64
+ end
65
+ end
66
+
45
67
  describe '#inspect' do
46
68
  subject { resource.inspect }
47
69
 
@@ -61,6 +83,12 @@ describe Skroutz::Resource do
61
83
  end
62
84
  end
63
85
 
86
+ describe '#to_hash' do
87
+ subject { resource.method(:to_hash) }
88
+
89
+ it { is_expected.to eq(resource.method(:attributes)) }
90
+ end
91
+
64
92
  describe 'attribute methods' do
65
93
  let(:attributes) { { 'name' => 'john', 'alive' => true, 'kicking' => false } }
66
94
  let(:attribute) { :name }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skroutz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-29 00:00:00.000000000 Z
12
+ date: 2015-04-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -116,6 +116,7 @@ extra_rdoc_files: []
116
116
  files:
117
117
  - .gitignore
118
118
  - .hound.yml
119
+ - .pryrc
119
120
  - .rubocop.yml
120
121
  - .travis.yml
121
122
  - CHANGELOG.md
@@ -186,6 +187,8 @@ files:
186
187
  - spec/fixtures/skus_show.yml
187
188
  - spec/skroutz/client_spec.rb
188
189
  - spec/skroutz/collection_proxy_spec.rb
190
+ - spec/skroutz/favorite_list_spec.rb
191
+ - spec/skroutz/favorite_spec.rb
189
192
  - spec/skroutz/paginated_collection_spec.rb
190
193
  - spec/skroutz/resource_spec.rb
191
194
  - spec/spec_helper.rb
@@ -238,6 +241,8 @@ test_files:
238
241
  - spec/fixtures/skus_show.yml
239
242
  - spec/skroutz/client_spec.rb
240
243
  - spec/skroutz/collection_proxy_spec.rb
244
+ - spec/skroutz/favorite_list_spec.rb
245
+ - spec/skroutz/favorite_spec.rb
241
246
  - spec/skroutz/paginated_collection_spec.rb
242
247
  - spec/skroutz/resource_spec.rb
243
248
  - spec/spec_helper.rb