wiscale 0.0.2 → 0.0.3
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/LICENSE +1 -1
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/wiscale.rb +10 -12
- data/test/helper.rb +1 -1
- data/test/test_wiscale.rb +12 -2
- metadata +3 -3
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.description = %Q{Ruby Wrapper for Withings Wifi Scale API}
|
10
10
|
gem.email = "jon@digital-drip.com"
|
11
11
|
gem.homepage = "http://github.com/jgaudette/wiscale"
|
12
|
-
gem.authors = ["Jon"]
|
12
|
+
gem.authors = ["Jon Gaudette"]
|
13
13
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
14
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
15
|
end
|
@@ -47,7 +47,7 @@ Rake::RDocTask.new do |rdoc|
|
|
47
47
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
48
|
|
49
49
|
rdoc.rdoc_dir = 'rdoc'
|
50
|
-
rdoc.title = "wiscale
|
50
|
+
rdoc.title = "wiscale #{version}"
|
51
51
|
rdoc.rdoc_files.include('README*')
|
52
52
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
53
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/wiscale.rb
CHANGED
@@ -22,26 +22,24 @@ class WiScale
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def get_meas(*params)
|
25
|
-
|
26
|
-
|
27
|
-
ret_val = JSON.parse(HTTParty.get(api_url + '/measure', :query => {:action => 'getmeas', :userid => userid, :publickey => publickey}))
|
28
|
-
else
|
29
|
-
ret_val = JSON.parse(HTTParty.get(api_url + '/measure', :query => {:action => 'getmeas', :userid => userid, :publickey => publickey}))
|
30
|
-
end
|
25
|
+
params = Array.new unless params
|
26
|
+
params[0] = Hash.new unless params[0]
|
31
27
|
|
28
|
+
params[0][:action] = 'getmeas'
|
29
|
+
params[0][:userid] = userid
|
30
|
+
params[0][:publickey] = publickey
|
31
|
+
|
32
|
+
ret_val = JSON.parse(HTTParty.get(api_url + '/measure', :query => params[0]))
|
32
33
|
|
33
34
|
if ret_val['status'] == 0
|
34
35
|
OpenStruct.new(ret_val['body'])
|
36
|
+
else
|
37
|
+
ret_val['status']
|
35
38
|
end
|
36
39
|
end
|
37
40
|
|
38
|
-
#TODO this should call get_meas(:limit=>1) once first todo is done
|
39
41
|
def get_last_meas
|
40
|
-
|
41
|
-
|
42
|
-
if ret_val['status'] == 0
|
43
|
-
return OpenStruct.new(ret_val['body'])
|
44
|
-
end
|
42
|
+
get_meas(:limit => 1)
|
45
43
|
end
|
46
44
|
|
47
45
|
def api_url
|
data/test/helper.rb
CHANGED
data/test/test_wiscale.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestWiscaleRuby < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
context "no login required" do
|
5
|
+
should "return 0 for connected" do
|
6
|
+
client = WiScale.new
|
7
|
+
assert(client.get_status == 0)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "invalid login" do
|
12
|
+
should "fail to get last measurement" do
|
13
|
+
client = WiScale.new(:userid => '2384', :publickey => 'asdf')
|
14
|
+
assert_equal 2555, client.get_last_meas
|
15
|
+
end
|
6
16
|
end
|
7
17
|
end
|