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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jon
1
+ Copyright (c) 2010 Jon Gaudette
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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-ruby #{version}"
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.2
1
+ 0.0.3
@@ -22,26 +22,24 @@ class WiScale
22
22
  end
23
23
 
24
24
  def get_meas(*params)
25
- if params.length == 1
26
- #TODO pass params to api for things like limie
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
- ret_val = JSON.parse(HTTParty.get(api_url + '/measure', :query => {:action => 'getmeas', :userid => userid, :publickey => publickey, :limit => 1}))
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
@@ -4,7 +4,7 @@ require 'shoulda'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'wiscale-ruby'
7
+ require 'wiscale'
8
8
 
9
9
  class Test::Unit::TestCase
10
10
  end
@@ -1,7 +1,17 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestWiscaleRuby < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
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
metadata CHANGED
@@ -5,11 +5,11 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
- - Jon
12
+ - Jon Gaudette
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []