tesco 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/README.md +64 -66
  2. data/Rakefile +19 -19
  3. data/VERSION +1 -1
  4. data/lib/tesco.rb +568 -566
  5. data/tesco.gemspec +39 -0
  6. metadata +23 -44
  7. data/readme.md +0 -67
@@ -0,0 +1,39 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tesco}
8
+ s.version = "0.4.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["JP Hastings-Spital"]
12
+ s.date = %q{2012-03-12}
13
+ s.description = %q{Search the Tesco Groceries API, through a very object oriented library}
14
+ s.email = %q{jphastings@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "README.md",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "lib/tesco.rb",
23
+ "tesco.gemspec"
24
+ ]
25
+ s.homepage = %q{http://github.com/jphastings/TescoGroceries}
26
+ s.require_paths = ["lib"]
27
+ s.rubygems_version = %q{1.7.2}
28
+ s.summary = %q{An extremely straightforward library for the Tesco Grocery API}
29
+
30
+ if s.respond_to? :specification_version then
31
+ s.specification_version = 3
32
+
33
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
34
+ else
35
+ end
36
+ else
37
+ end
38
+ end
39
+
metadata CHANGED
@@ -1,71 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tesco
3
- version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - JP Hastings-Spital
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-07-22 00:00:00 +01:00
19
- default_executable:
12
+ date: 2012-03-12 00:00:00.000000000Z
20
13
  dependencies: []
21
-
22
14
  description: Search the Tesco Groceries API, through a very object oriented library
23
15
  email: jphastings@gmail.com
24
16
  executables: []
25
-
26
17
  extensions: []
27
-
28
- extra_rdoc_files:
18
+ extra_rdoc_files:
19
+ - README.md
20
+ files:
29
21
  - README.md
30
- files:
31
22
  - Rakefile
32
23
  - VERSION
33
24
  - lib/tesco.rb
34
- - readme.md
35
- - README.md
36
- has_rdoc: true
25
+ - tesco.gemspec
37
26
  homepage: http://github.com/jphastings/TescoGroceries
38
27
  licenses: []
39
-
40
28
  post_install_message:
41
- rdoc_options:
42
- - --charset=UTF-8
43
- require_paths:
29
+ rdoc_options: []
30
+ require_paths:
44
31
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
32
+ required_ruby_version: !ruby/object:Gem::Requirement
46
33
  none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
39
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
63
44
  requirements: []
64
-
65
45
  rubyforge_project:
66
- rubygems_version: 1.3.7
46
+ rubygems_version: 1.7.2
67
47
  signing_key:
68
48
  specification_version: 3
69
49
  summary: An extremely straightforward library for the Tesco Grocery API
70
50
  test_files: []
71
-
data/readme.md DELETED
@@ -1,67 +0,0 @@
1
- Tesco Grocery API
2
- =================
3
- A seriously simple library for accessing the Tesco Grocery API.
4
-
5
- Preparations
6
- ------------
7
- The first step here is to [register](https://secure.techfortesco.com/tescoapiweb/) at the Tech for Tesco so you can use their Grocery API.
8
- Some of the calls (like working with baskets) will require non-anonymous login, so you may also want a Tesco account. They don't use any Oauth type stuff, you'll just need a username and password.
9
-
10
- Examples
11
- --------
12
- Everyone loves examples. You don't want to read through all the documentation to get started!
13
-
14
- require 'tesco'
15
-
16
- t = Tesco::Groceries.new('dev_key','api_key')
17
-
18
- # Returns a Products object (see below, it's basically a read-only array)
19
- s = t.search("Chocolates")
20
-
21
- # Check out the Product class for more info about these badboys.
22
- p milky = s[0]
23
- # => Tesco Milk Chocolate Big Buttons 170G
24
-
25
- # Now you'll need to log in:
26
- t.login('joebloggs@tesco.com','supersecret!')
27
-
28
- # This will return *the* instance (ie. calling it twice will give you the same object)
29
- # of the basket for t's currently logged in user.
30
- b = t.basket
31
-
32
- # You can arrange products in the basket like so:
33
- b < milky # Push into the basket (or increment quantity)
34
- b > milky # Completely remove from the basket
35
- # b[milky] is now a 'BasketItem' Object, which you can use to alter amounts and the shopper note.
36
- b[milky].quantity = 5 # Set a specific quantity
37
- b[milky].note = "Please say \"I'm the Milky Bar Kid!\" as you pick it up. Please!"
38
-
39
- # Potentially counter-intuitive, request
40
-
41
- # There can only ever be one basket instance per logged in user:
42
- b.object_id == t.basket.object_id # => true
43
-
44
- # But logging in as a new user won't bugger things up:
45
- t.login('fredsmith@tesco.com','supersecreter!')
46
- b2 = t.basket
47
- b.customer_id # => 1234
48
- b2.customer_id # => 5678
49
-
50
- # And it'll make sure you're not going to bugger things up:
51
- b > milky
52
- # NotAuthenticatedError, Please reauthenticate as this basket's owner before attempting to modify it
53
-
54
-
55
- ### The Products Class
56
- As with most APIs that cover loads of information, the data is usually paginated. In order to make life simple I've designed this library so you don't have to worry about that at all. Paginated responses are
57
-
58
- ### Keeping up with Tesco API development
59
- The default endpoint for the service is currently the [beta 1](http://www.techfortesco.com/groceryapi_b1/RESTService.aspx). You can alter this after instantiating a Tesco object with:
60
-
61
- t.endpoint = "http://another.tesco.api/testing"
62
-
63
- I'll endeavour to keep this library as up to date as I can, but in the event that there's a method you want to use that I haven't created you can either hack at the code by forking the [repo on Github](http://github.com/jphastings/TescoGroceries) or you can just do this:
64
-
65
- t.the_new_api_call(:searchtext => "A string!", :becool => true)
66
-
67
- This will send the command to the Tesco API as 'THENEWAPICALL' with the parameters in tow. You'll get a Hash back of the parsed JSON that comes direct from the API, so no fancy objects/DSL to work with, but the `api_request` method (which does all the hard work) *will* raise a subclass of TescoApiError if your request was dodgey, as per usual.