fitgem 0.5.0 → 0.5.1
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/README.md +3 -3
- data/lib/fitgem/notifications.rb +7 -13
- data/lib/fitgem/version.rb +1 -1
- data/spec/fitgem_notifications_spec.rb +2 -2
- metadata +22 -22
    
        data/README.md
    CHANGED
    
    | @@ -21,10 +21,10 @@ We've started to develop an example app using the fitgem client.  See [https://g | |
| 21 21 |  | 
| 22 22 | 
             
            The Fitbit API allows for you to set up notification subscription so that when values change (via automatic syncs with the fitbit device) your applications can be notified automatically.  You can set up a default subscription callback URL via the [Fitbit dev site](https://dev.fitbit.com/ 'Fitbit Developer Site') and then use the Subscriptions API to add or remove subscriptions for individual users.
         | 
| 23 23 |  | 
| 24 | 
            -
            __Currently, notification management is experimental in this gem__.  There is currently code to add, remove, and list subscriptions (foods, activities, sleep, body, and all collections). | 
| 24 | 
            +
            __Currently, notification management is experimental in this gem__.  There is currently code to add, remove, and list subscriptions (foods, activities, sleep, body, and all collections).
         | 
| 25 25 |  | 
| 26 26 |  | 
| 27 | 
            -
            # FAQs | 
| 27 | 
            +
            # FAQs
         | 
| 28 28 | 
             
            ## What About ruby-fitbit?
         | 
| 29 29 |  | 
| 30 30 | 
             
            There is a good looking gem called [ruby-fitbit](https://github.com/danmayer/ruby-fitbit "ruby-fitbit") that also aims to collect data from the site.  It was created before they released their REST API and uses screen-scraping to gather the data rather than through their API.  I looked into forking it and refactoring to use the new API but after looking through the code I felt it would be more of a total rewrite and so decided to create a new gem that I could design from scratch.
         | 
| @@ -51,4 +51,4 @@ The Fitbit REST API is in BETA right now, and so it will quite likely change ove | |
| 51 51 |  | 
| 52 52 | 
             
            ### Copyright ###
         | 
| 53 53 |  | 
| 54 | 
            -
            Copyright (c) 2011 Zachery Moneypenny. See LICENSE for further details.
         | 
| 54 | 
            +
            Copyright (c) 2011-2012 Zachery Moneypenny. See LICENSE for further details.
         | 
    
        data/lib/fitgem/notifications.rb
    CHANGED
    
    | @@ -27,7 +27,7 @@ module Fitgem | |
| 27 27 | 
             
                #   a hash containing confirmation information for the subscription.  
         | 
| 28 28 | 
             
                # @since v0.4.0
         | 
| 29 29 | 
             
                def create_subscription(opts)
         | 
| 30 | 
            -
                  resp = raw_post make_subscription_url(opts | 
| 30 | 
            +
                  resp = raw_post make_subscription_url(opts.merge({:use_subscription_id => true})), EMPTY_BODY, make_headers(opts)
         | 
| 31 31 | 
             
                  [resp.code, extract_response_body(resp)]
         | 
| 32 32 | 
             
                end
         | 
| 33 33 |  | 
| @@ -48,7 +48,7 @@ module Fitgem | |
| 48 48 | 
             
                #   a hash containing confirmation information for the subscription.  
         | 
| 49 49 | 
             
                # @since v0.4.0
         | 
| 50 50 | 
             
                def remove_subscription(opts)
         | 
| 51 | 
            -
                  resp = raw_delete make_subscription_url(opts | 
| 51 | 
            +
                  resp = raw_delete make_subscription_url(opts.merge({:use_subscription_id => true})), make_headers(opts)
         | 
| 52 52 | 
             
                  [resp.code, extract_response_body(resp)]
         | 
| 53 53 | 
             
                end
         | 
| 54 54 |  | 
| @@ -81,16 +81,10 @@ module Fitgem | |
| 81 81 | 
             
                # @return [Hash] The headers has to pass to the get/post/put/delete
         | 
| 82 82 | 
             
                #   methods
         | 
| 83 83 | 
             
                def make_headers(opts)
         | 
| 84 | 
            -
                  headers =  | 
| 84 | 
            +
                  headers = {}
         | 
| 85 85 | 
             
                  if opts[:subscriber_id]
         | 
| 86 86 | 
             
                    headers['X-Fitbit-Subscriber-Id'] = opts[:subscriber_id]
         | 
| 87 | 
            -
                    headers.delete :subscriber_id
         | 
| 88 87 | 
             
                  end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                  headers.delete :subscription_id if headers[:subscription_id]
         | 
| 91 | 
            -
                  headers.delete :type if headers[:type]
         | 
| 92 | 
            -
                  headers.delete :use_subscription_id if headers[:use_subscription_id]
         | 
| 93 | 
            -
             | 
| 94 88 | 
             
                  headers
         | 
| 95 89 | 
             
                end
         | 
| 96 90 |  | 
| @@ -109,10 +103,10 @@ module Fitgem | |
| 109 103 | 
             
                def make_subscription_url(opts)
         | 
| 110 104 | 
             
                  validate_subscription_type opts[:type]
         | 
| 111 105 | 
             
                  path = if opts[:type] == :all
         | 
| 112 | 
            -
             | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 106 | 
            +
                    ""
         | 
| 107 | 
            +
                  else
         | 
| 108 | 
            +
                    "/"+opts[:type].to_s
         | 
| 109 | 
            +
                  end
         | 
| 116 110 | 
             
                  url = "/user/#{@user_id}#{path}/apiSubscriptions"
         | 
| 117 111 | 
             
                  if opts[:use_subscription_id]
         | 
| 118 112 | 
             
                    unless opts[:subscription_id]
         | 
    
        data/lib/fitgem/version.rb
    CHANGED
    
    
| @@ -32,7 +32,7 @@ describe Fitgem::Client do | |
| 32 32 |  | 
| 33 33 | 
             
                it "adds the :use_subscription_id flag and calls #make_headers" do
         | 
| 34 34 | 
             
                  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
         | 
| 35 | 
            -
                  @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320" | 
| 35 | 
            +
                  @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320"})
         | 
| 36 36 | 
             
                  @client.create_subscription(opts)
         | 
| 37 37 | 
             
                end
         | 
| 38 38 |  | 
| @@ -69,7 +69,7 @@ describe Fitgem::Client do | |
| 69 69 |  | 
| 70 70 | 
             
                it "adds the :use_subscription_id flag and calls #make_headers" do
         | 
| 71 71 | 
             
                  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
         | 
| 72 | 
            -
                  @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320" | 
| 72 | 
            +
                  @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320" })
         | 
| 73 73 | 
             
                  @client.remove_subscription(opts)
         | 
| 74 74 | 
             
                end
         | 
| 75 75 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fitgem
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.5. | 
| 4 | 
            +
              version: 0.5.1
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,11 +9,11 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012-01- | 
| 12 | 
            +
            date: 2012-01-24 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: oauth
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &70336813924980 !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                none: false
         | 
| 18 18 | 
             
                requirements:
         | 
| 19 19 | 
             
                - - ! '>='
         | 
| @@ -21,10 +21,10 @@ dependencies: | |
| 21 21 | 
             
                    version: '0'
         | 
| 22 22 | 
             
              type: :runtime
         | 
| 23 23 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 24 | 
            +
              version_requirements: *70336813924980
         | 
| 25 25 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 26 26 | 
             
              name: rake
         | 
| 27 | 
            -
              requirement: & | 
| 27 | 
            +
              requirement: &70336813924560 !ruby/object:Gem::Requirement
         | 
| 28 28 | 
             
                none: false
         | 
| 29 29 | 
             
                requirements:
         | 
| 30 30 | 
             
                - - ! '>='
         | 
| @@ -32,10 +32,10 @@ dependencies: | |
| 32 32 | 
             
                    version: '0'
         | 
| 33 33 | 
             
              type: :development
         | 
| 34 34 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements: * | 
| 35 | 
            +
              version_requirements: *70336813924560
         | 
| 36 36 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 37 | 
             
              name: rspec
         | 
| 38 | 
            -
              requirement: & | 
| 38 | 
            +
              requirement: &70336813960400 !ruby/object:Gem::Requirement
         | 
| 39 39 | 
             
                none: false
         | 
| 40 40 | 
             
                requirements:
         | 
| 41 41 | 
             
                - - ! '>='
         | 
| @@ -43,10 +43,10 @@ dependencies: | |
| 43 43 | 
             
                    version: '0'
         | 
| 44 44 | 
             
              type: :development
         | 
| 45 45 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements: * | 
| 46 | 
            +
              version_requirements: *70336813960400
         | 
| 47 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 48 48 | 
             
              name: guard
         | 
| 49 | 
            -
              requirement: & | 
| 49 | 
            +
              requirement: &70336813959180 !ruby/object:Gem::Requirement
         | 
| 50 50 | 
             
                none: false
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 52 | 
             
                - - ! '>='
         | 
| @@ -54,10 +54,10 @@ dependencies: | |
| 54 54 | 
             
                    version: '0'
         | 
| 55 55 | 
             
              type: :development
         | 
| 56 56 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: * | 
| 57 | 
            +
              version_requirements: *70336813959180
         | 
| 58 58 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 59 59 | 
             
              name: guard-rspec
         | 
| 60 | 
            -
              requirement: & | 
| 60 | 
            +
              requirement: &70336813957720 !ruby/object:Gem::Requirement
         | 
| 61 61 | 
             
                none: false
         | 
| 62 62 | 
             
                requirements:
         | 
| 63 63 | 
             
                - - ! '>='
         | 
| @@ -65,10 +65,10 @@ dependencies: | |
| 65 65 | 
             
                    version: '0'
         | 
| 66 66 | 
             
              type: :development
         | 
| 67 67 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements: * | 
| 68 | 
            +
              version_requirements: *70336813957720
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: rb-fsevent
         | 
| 71 | 
            -
              requirement: & | 
| 71 | 
            +
              requirement: &70336813956900 !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                none: false
         | 
| 73 73 | 
             
                requirements:
         | 
| 74 74 | 
             
                - - ! '>='
         | 
| @@ -76,10 +76,10 @@ dependencies: | |
| 76 76 | 
             
                    version: '0'
         | 
| 77 77 | 
             
              type: :development
         | 
| 78 78 | 
             
              prerelease: false
         | 
| 79 | 
            -
              version_requirements: * | 
| 79 | 
            +
              version_requirements: *70336813956900
         | 
| 80 80 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 81 81 | 
             
              name: growl
         | 
| 82 | 
            -
              requirement: & | 
| 82 | 
            +
              requirement: &70336813956040 !ruby/object:Gem::Requirement
         | 
| 83 83 | 
             
                none: false
         | 
| 84 84 | 
             
                requirements:
         | 
| 85 85 | 
             
                - - ! '>='
         | 
| @@ -87,10 +87,10 @@ dependencies: | |
| 87 87 | 
             
                    version: '0'
         | 
| 88 88 | 
             
              type: :development
         | 
| 89 89 | 
             
              prerelease: false
         | 
| 90 | 
            -
              version_requirements: * | 
| 90 | 
            +
              version_requirements: *70336813956040
         | 
| 91 91 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 92 92 | 
             
              name: yard
         | 
| 93 | 
            -
              requirement: & | 
| 93 | 
            +
              requirement: &70336813954640 !ruby/object:Gem::Requirement
         | 
| 94 94 | 
             
                none: false
         | 
| 95 95 | 
             
                requirements:
         | 
| 96 96 | 
             
                - - ! '>='
         | 
| @@ -98,10 +98,10 @@ dependencies: | |
| 98 98 | 
             
                    version: '0'
         | 
| 99 99 | 
             
              type: :development
         | 
| 100 100 | 
             
              prerelease: false
         | 
| 101 | 
            -
              version_requirements: * | 
| 101 | 
            +
              version_requirements: *70336813954640
         | 
| 102 102 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 103 103 | 
             
              name: rdiscount
         | 
| 104 | 
            -
              requirement: & | 
| 104 | 
            +
              requirement: &70336813953360 !ruby/object:Gem::Requirement
         | 
| 105 105 | 
             
                none: false
         | 
| 106 106 | 
             
                requirements:
         | 
| 107 107 | 
             
                - - ! '>='
         | 
| @@ -109,7 +109,7 @@ dependencies: | |
| 109 109 | 
             
                    version: '0'
         | 
| 110 110 | 
             
              type: :development
         | 
| 111 111 | 
             
              prerelease: false
         | 
| 112 | 
            -
              version_requirements: * | 
| 112 | 
            +
              version_requirements: *70336813953360
         | 
| 113 113 | 
             
            description: A client library to send and retrieve workout, weight, and diet data
         | 
| 114 114 | 
             
              from fitbit.com
         | 
| 115 115 | 
             
            email:
         | 
| @@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 168 168 | 
             
                  version: '0'
         | 
| 169 169 | 
             
                  segments:
         | 
| 170 170 | 
             
                  - 0
         | 
| 171 | 
            -
                  hash:  | 
| 171 | 
            +
                  hash: -4091779949925866203
         | 
| 172 172 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 173 173 | 
             
              none: false
         | 
| 174 174 | 
             
              requirements:
         | 
| @@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 177 177 | 
             
                  version: '0'
         | 
| 178 178 | 
             
                  segments:
         | 
| 179 179 | 
             
                  - 0
         | 
| 180 | 
            -
                  hash:  | 
| 180 | 
            +
                  hash: -4091779949925866203
         | 
| 181 181 | 
             
            requirements: []
         | 
| 182 182 | 
             
            rubyforge_project: fitgem
         | 
| 183 183 | 
             
            rubygems_version: 1.8.10
         |