Skip to content

Commit baed54b

Browse files
author
Arjan van der Gaag
committed
initial commit
0 parents  commit baed54b

26 files changed

+335
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.gem
2+
.bundle
3+
Gemfile.lock
4+
pkg/*

CHANGELOG.md

Whitespace-only changes.

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source "http://rubygems.org"
2+
gemspec

Guardfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
guard 'minitest' do
2+
watch(%r|^spec/(.*)_spec\.rb|)
3+
watch(%r|^lib/(.*)\.rb|) { |m| "spec/#{m[1]}_spec.rb" }
4+
watch(%r|^spec/spec_helper\.rb|) { "spec" }
5+
end

LICENSE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (C) 2011 by Arjan van der Gaag
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
```ruby
2+
Bol::Category.find(params[:id]).products
3+
Bol::Category.find(params[:id]).subcategories
4+
Bol::Category.find(params[:id]).top_products
5+
Bol::Category.find(params[:id]).search()
6+
Bol::Product.find(params[:id])
7+
Bol::Product.search(params[:query]).limit(10).offset(10).order('sales_ranking ASC')
8+
Bol::Product.search(params[:query]).page(params[:page])
9+
```
10+
11+
```ruby
12+
Bol.configure do |c|
13+
c.key = '...'
14+
c.secret = ''
15+
c.per_page = 10
16+
c.default_order = 'sales_ranking'
17+
end
18+
```

Rakefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'bundler/gem_tasks'
2+
3+
require 'rake/testtask'
4+
Rake::TestTask.new do |t|
5+
t.libs << 'test'
6+
t.test_files = FileList['test/test_*.rb']
7+
t.verbose = true
8+
end
9+
10+
task default: :test

bol.gemspec

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- encoding: utf-8 -*-
2+
$:.push File.expand_path('../lib', __FILE__)
3+
require 'bol/version'
4+
5+
Gem::Specification.new do |s|
6+
s.name = 'bol'
7+
s.version = Bol::VERSION
8+
s.authors = ['Arjan van der Gaag']
9+
s.email = ['[email protected]']
10+
s.homepage = ""
11+
s.summary = %q{Simple Ruby wrapper around the bol.com developer API}
12+
s.description = %q{Access the bol.com product catalog from a Ruby project.}
13+
14+
s.files = `git ls-files`.split("\n")
15+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17+
s.require_paths = ['lib']
18+
19+
s.add_development_dependency 'rake'
20+
s.add_development_dependency 'turn'
21+
s.add_development_dependency 'guard'
22+
s.add_development_dependency 'guard-minitest'
23+
s.add_development_dependency 'vcr'
24+
s.add_development_dependency 'fakeweb'
25+
s.add_development_dependency 'rb-fsevent'
26+
s.add_development_dependency 'growl'
27+
end

lib/bol.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'bol/version'
2+
3+
module Bol
4+
autoload :Category, 'bol/category'
5+
autoload :Configuration, 'bol/configuration'
6+
autoload :Product, 'bol/product'
7+
autoload :Query, 'bol/query'
8+
autoload :Request, 'bol/request'
9+
autoload :Requests, 'bol/requests'
10+
end

lib/bol/category.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Bol
2+
class Category
3+
end
4+
end

lib/bol/configuration.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Bol
2+
class Configuration
3+
end
4+
end

lib/bol/product.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Bol
2+
class Product
3+
end
4+
end

lib/bol/query.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Bol
2+
class Query
3+
end
4+
end

lib/bol/request.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Bol
2+
class Request
3+
end
4+
end

lib/bol/requests.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module Bol
2+
module Requests
3+
autoload :Product, 'bol/requests/product'
4+
autoload :Category, 'bol/requests/category'
5+
autoload :Search, 'bol/requests/search'
6+
autoload :List, 'bol/requests/list'
7+
end
8+
end

lib/bol/requests/category.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Bol
2+
module Requests
3+
class Category
4+
end
5+
end
6+
end

lib/bol/requests/list.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Bol
2+
module Requests
3+
class List
4+
end
5+
end
6+
end

lib/bol/requests/product.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Bol
2+
module Requests
3+
class Product
4+
end
5+
end
6+
end

lib/bol/requests/search.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Bol
2+
module Requests
3+
class Search
4+
end
5+
end
6+
end

lib/bol/version.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Bol
2+
VERSION = '0.0.1'
3+
end

spec/bol_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'minitest/spec'
2+
require 'bol'
3+
4+
describe Bol do
5+
describe '#configure' do
6+
it 'should create configuration object'
7+
it 'should yield config object without argument'
8+
it 'should raise with non-hash argument'
9+
it 'should not yield with argument'
10+
end
11+
12+
describe '#products' do
13+
it 'should delegate to new empty category products'
14+
end
15+
16+
describe '#search' do
17+
it 'should delegate to new empty category search'
18+
end
19+
end

spec/category_spec.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'minitest/spec'
2+
3+
describe Bol::Category do
4+
describe 'combining categories' do
5+
it 'should add two categories for a combined scope'
6+
it 'should subtract two categories to reduce scope'
7+
it 'should manually add category IDs'
8+
end
9+
10+
describe '#search' do
11+
it 'should create new query'
12+
it 'should create new request'
13+
it 'should not send request'
14+
it 'should set query term'
15+
it 'should return query'
16+
end
17+
18+
describe 'list methods' do
19+
it 'should create new request'
20+
it 'should return new request'
21+
it 'should allow setting order'
22+
it 'should allow setting limit'
23+
it 'should allow setting offset'
24+
it 'should allow setting page'
25+
end
26+
27+
describe 'default category' do
28+
it 'should set request category scope to 0'
29+
end
30+
31+
describe 'subcategories' do
32+
it 'should create category list request'
33+
it 'should return array of Category objects'
34+
end
35+
36+
describe '#find' do
37+
it 'should create request'
38+
it 'should set id on request'
39+
it 'should request category scope when found'
40+
it 'should raise error when not found'
41+
end
42+
end

spec/configuration_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'minitest/spec'
2+
3+
describe Bol::Configuration do
4+
describe 'as a hash' do
5+
it 'should should set known keys'
6+
it 'should raise for unknown keys'
7+
end
8+
9+
describe 'as attributes' do
10+
it 'should should set known keys'
11+
it 'should raise for unknown keys'
12+
end
13+
end

spec/product_spec.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'minitest/spec'
2+
3+
describe Bol::Product do
4+
describe '#find' do
5+
it 'should create new request'
6+
it 'should not send request'
7+
it 'should set id param'
8+
it 'should return product instance'
9+
it 'should raise error when not found'
10+
end
11+
12+
describe 'attributes' do
13+
it 'should delegate [] to attributes'
14+
it 'should expose attributes as methods'
15+
16+
describe 'release date' do
17+
it 'should parse to a Datetime'
18+
end
19+
20+
describe 'cover' do
21+
it 'should return medium by default'
22+
it 'should take format as argument'
23+
it 'should raise on invalid format'
24+
end
25+
end
26+
end

spec/query_spec.rb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'minitest/spec'
2+
3+
describe Bol::Query do
4+
describe 'category scope' do
5+
it 'should set category scope'
6+
it 'should raise unless given a number'
7+
it 'should set category param'
8+
end
9+
10+
describe '#limit' do
11+
it 'should raise unless given a number'
12+
it 'should add parameter to request'
13+
it 'should return query'
14+
end
15+
16+
describe '#page' do
17+
it 'should raise unless given numeric'
18+
it 'should default to 1'
19+
it 'should add limit param to request'
20+
it 'should add offset param to request'
21+
it 'should use per page config to determine offset value'
22+
it 'should return query'
23+
end
24+
25+
describe '#offset' do
26+
it 'should raise unless given a number'
27+
it 'should add parameter to request'
28+
it 'should return query'
29+
end
30+
31+
describe '#order' do
32+
it 'should convert to string'
33+
it 'should raise unless wrong format'
34+
it 'should add order direction on request'
35+
it 'should add order key on request'
36+
it 'should return query'
37+
end
38+
end
39+

spec/request_spec.rb

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'minitest/spec'
2+
3+
describe Bol::Request do
4+
describe 'category scope' do
5+
it 'should set category scope'
6+
it 'should raise when scope is not an id'
7+
it 'should keep scope across requests'
8+
it 'should reset scope'
9+
it 'should add scope as param'
10+
end
11+
12+
describe 'signing' do
13+
it 'should raise error when key and secret are not configured'
14+
it 'should add signature to request by default'
15+
end
16+
17+
describe 'firing' do
18+
it 'should trigger HTTP request on looping'
19+
it 'should trigger event manually'
20+
end
21+
22+
describe Bol::Requests::Product do
23+
it 'should get from correct URL'
24+
it 'should require param id'
25+
it 'should yield Product'
26+
end
27+
28+
describe Bol::Requests::Category do
29+
it 'should get from correct URL'
30+
it 'should require param id'
31+
it 'should yield Category'
32+
end
33+
34+
describe Bol::Requests::Search do
35+
it 'should get from correct URL'
36+
it 'should require param term'
37+
it 'should allow key ...'
38+
it 'should yield Product'
39+
end
40+
41+
describe Bol::Requests::List do
42+
it 'should get from correct URL'
43+
it 'should require param type'
44+
it 'should yield Product'
45+
end
46+
end

0 commit comments

Comments
 (0)