fitbit-to-graphite 0.1.2 → 0.2.0
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 +1 -0
 - data/bin/fitbit-to-graphite.rb +12 -2
 - data/fitbit-to-graphite.gemspec +1 -1
 - metadata +1 -1
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -29,6 +29,7 @@ Specific options: 
     | 
|
| 
       29 
29 
     | 
    
         
             
                -h, --host=HOST                  The hostname or ip of the host graphite is running on
         
     | 
| 
       30 
30 
     | 
    
         
             
                -p, --port=PORT                  The port graphite is listening on
         
     | 
| 
       31 
31 
     | 
    
         
             
                -n, --namespace=NAMESPACE        The graphite metric path to store data in
         
     | 
| 
      
 32 
     | 
    
         
            +
                -d, --date=NAMESPACE             the date to get data for in the format YYYY-MM-DD
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
            Common options:
         
     | 
| 
       34 
35 
     | 
    
         
             
                    --help                       Show this message
         
     | 
    
        data/bin/fitbit-to-graphite.rb
    CHANGED
    
    | 
         @@ -11,7 +11,7 @@ require 'choice' 
     | 
|
| 
       11 
11 
     | 
    
         
             
            require 'fitgem'
         
     | 
| 
       12 
12 
     | 
    
         
             
            require 'tzinfo'
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            PROGRAM_VERSION = "0. 
     | 
| 
      
 14 
     | 
    
         
            +
            PROGRAM_VERSION = "0.2.0"
         
     | 
| 
       15 
15 
     | 
    
         
             
            SLEEP_STATE_TYPES = ['deep', 'light', 'awake']
         
     | 
| 
       16 
16 
     | 
    
         
             
            # this is just to be compatible with jawbone data
         
     | 
| 
       17 
17 
     | 
    
         
             
            JAWBONE_SLEEP_STATES = { 'awake' => 1, 'light' => 2, 'deep' => 3 }
         
     | 
| 
         @@ -41,6 +41,12 @@ Choice.options do 
     | 
|
| 
       41 
41 
     | 
    
         
             
                desc 'The graphite metric path to store data in'
         
     | 
| 
       42 
42 
     | 
    
         
             
              end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
      
 44 
     | 
    
         
            +
              option :date do
         
     | 
| 
      
 45 
     | 
    
         
            +
                short '-d'
         
     | 
| 
      
 46 
     | 
    
         
            +
                long '--date=NAMESPACE'
         
     | 
| 
      
 47 
     | 
    
         
            +
                desc 'the date to get data for in the format YYYY-MM-DD'
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       44 
50 
     | 
    
         
             
              separator ''
         
     | 
| 
       45 
51 
     | 
    
         
             
              separator 'Common options: '
         
     | 
| 
       46 
52 
     | 
    
         | 
| 
         @@ -126,7 +132,11 @@ def extract_data(client, &block) 
     | 
|
| 
       126 
132 
     | 
    
         
             
              user_info = client.user_info
         
     | 
| 
       127 
133 
     | 
    
         
             
              user_timezone_name = user_info['user']['timezone']
         
     | 
| 
       128 
134 
     | 
    
         
             
              user_timezone = offset = TZInfo::Timezone.get(user_timezone_name).current_period.utc_total_offset / (60*60)
         
     | 
| 
       129 
     | 
    
         
            -
               
     | 
| 
      
 135 
     | 
    
         
            +
              if Choice[:date]
         
     | 
| 
      
 136 
     | 
    
         
            +
                today = date = Date.strptime(Choice[:date],"%Y-%m-%d")
         
     | 
| 
      
 137 
     | 
    
         
            +
              else
         
     | 
| 
      
 138 
     | 
    
         
            +
                today = Date.today
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
       130 
140 
     | 
    
         
             
              all_sleep_data = client.sleep_on_date(today)['sleep']
         
     | 
| 
       131 
141 
     | 
    
         
             
              if all_sleep_data.nil?
         
     | 
| 
       132 
142 
     | 
    
         
             
                puts "API rate limit potentially exceeded."
         
     | 
    
        data/fitbit-to-graphite.gemspec
    CHANGED