fatsecret-api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/fatsecret.rb +33 -4
- metadata +7 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9901a6007d2268f296d95a26809107793412937
|
4
|
+
data.tar.gz: 0a14830a389b83069c8a338026b3dab392ac27ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae103a0622e8107aba4d73a125c6b28e987f129f1f428db9d560998374d9126e075e29756cefccac715f8ba8ab9c194b358122b5e7934d87737ff0381e87fa57
|
7
|
+
data.tar.gz: cb3e40047d9a989ae1e68f6865d4c710b4479db75e6c1918d59de4b2a7211c48d4bc7d287d334cbca221083bfee1cd211eab194e4361bf1b3d83ae3a14670d72
|
data/lib/fatsecret.rb
CHANGED
@@ -22,12 +22,18 @@ class FatSecret
|
|
22
22
|
def self.init(key, secret)
|
23
23
|
@@key = key
|
24
24
|
@@secret = secret
|
25
|
-
|
25
|
+
return nil #don't return the secret key
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
#--------------------------------
|
30
|
+
#--- Food Functionality
|
31
|
+
#--------------------------------
|
26
32
|
|
27
33
|
def self.search_food(expression)
|
28
34
|
query = {
|
29
35
|
:method => 'foods.search',
|
30
|
-
:search_expression => expression
|
36
|
+
:search_expression => expression.esc
|
31
37
|
}
|
32
38
|
get(query)
|
33
39
|
end
|
@@ -38,7 +44,30 @@ class FatSecret
|
|
38
44
|
:food_id => id
|
39
45
|
}
|
40
46
|
get(query)
|
41
|
-
|
47
|
+
end
|
48
|
+
|
49
|
+
#--------------------------------
|
50
|
+
#--- Recipe Functionality
|
51
|
+
#--------------------------------
|
52
|
+
|
53
|
+
def self.search_recipes(expression,max_results=20)
|
54
|
+
query = {
|
55
|
+
:method => 'recipes.search',
|
56
|
+
:search_expression => expression.esc,
|
57
|
+
:max_results => max_results
|
58
|
+
}
|
59
|
+
get(query)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.recipe(id)
|
63
|
+
query = {
|
64
|
+
:method => 'recipe.get',
|
65
|
+
:recipe_id => id
|
66
|
+
}
|
67
|
+
get(query)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
42
71
|
|
43
72
|
private
|
44
73
|
|
@@ -46,7 +75,7 @@ class FatSecret
|
|
46
75
|
params = {
|
47
76
|
:format => 'json',
|
48
77
|
:oauth_consumer_key => @@key,
|
49
|
-
:oauth_nonce =>
|
78
|
+
:oauth_nonce => SecureRandom.hex,
|
50
79
|
:oauth_signature_method => SHA1,
|
51
80
|
:oauth_timestamp => Time.now.to_i,
|
52
81
|
:oauth_version => "1.0",
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fatsecret-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ibrahim Muhammad
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2012-02-19 00:00:00.
|
11
|
+
date: 2012-02-19 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: A simple hello world gem
|
15
14
|
email: ibrahim.mohammad@gmail.com
|
@@ -20,26 +19,25 @@ files:
|
|
20
19
|
- lib/fatsecret.rb
|
21
20
|
homepage: http://www.github.com/whistler/fatsecret
|
22
21
|
licenses: []
|
22
|
+
metadata: {}
|
23
23
|
post_install_message:
|
24
24
|
rdoc_options: []
|
25
25
|
require_paths:
|
26
26
|
- lib
|
27
27
|
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
28
|
requirements:
|
30
|
-
- -
|
29
|
+
- - '>='
|
31
30
|
- !ruby/object:Gem::Version
|
32
31
|
version: '0'
|
33
32
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
33
|
requirements:
|
36
|
-
- -
|
34
|
+
- - '>='
|
37
35
|
- !ruby/object:Gem::Version
|
38
36
|
version: '0'
|
39
37
|
requirements: []
|
40
38
|
rubyforge_project:
|
41
|
-
rubygems_version:
|
39
|
+
rubygems_version: 2.0.7
|
42
40
|
signing_key:
|
43
|
-
specification_version:
|
41
|
+
specification_version: 4
|
44
42
|
summary: Connects to FatSecret API and retreives nutritional data
|
45
43
|
test_files: []
|