myfitnesspal_stats 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66ddbff289f059d81ec064e40692a968d4d40673
4
- data.tar.gz: fc894c035079922d741710fcf9dbfd341afaff63
3
+ metadata.gz: 9d42029eb432096466f91d8baffb2050cabdcd1c
4
+ data.tar.gz: 4ae50ed3bce56ab84ec9a1d835c3ba6ffd7f8ff7
5
5
  SHA512:
6
- metadata.gz: 940b1d0a786aa34214d1def9700d87fedc7877cbb53a3c2dffeb4f2262d40398f49e3de89e519e6dd0a9ae33190d996fb9c33df5ea45de85ab15e5948c4c0822
7
- data.tar.gz: 4ec088f40903288ec0b3a4999f1efdbe89371c63363d8849263be57bb989f66fe761d6ecc28d8ff4c2611b8ea44e1e564fe7cd6d42609cc8a8f6c7c6440e2309
6
+ metadata.gz: c5ea67837661b35c51c72a220b16c2a047ca792e2cb754e2574bded85f2beaa4f1c725055c89279ddffb32a9479cfa2296cc4f360ff83ee17baa2bd438921cc2
7
+ data.tar.gz: 97c105ab83c385b4957421664de9df842f347c2f0c38219fa004d7f5ba9cda47989c23beeeda0092404144dd1eecff39f845e8056d07b8aa53ee183696aba283
data/README.md CHANGED
@@ -20,16 +20,16 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Once installation is complete, you cam start accessing your information by initializing a new web scraper:
24
-
23
+ **Getting Started:** Once installation of this gem is complete, initialize a new web scraper:
25
24
  ```ruby
25
+ include 'myfitnesspal_stats'
26
+
26
27
  # Insert your username and password for Myfitnesspal
27
28
  # WARNING: DO NOT HARDCODE THIS INTO YOUR SCRIPT IF IT IS A PUBLIC SCRIPT. FUTURE REVISIONS WILL MAKE SURE TO SOLVE THIS PROBLEM.
28
29
  scraper = Scraper.new('username', 'password')
29
30
  ```
30
31
 
31
- To access a specified date and the nutritional information for that day, fetch a specified date and call the `nutrition_totals` method on that day.
32
-
32
+ **Accessing nutritional information:** To access nutritional information for a specified date, create a new `Day` instance and then call the `.nutrition_totals` on that day:
33
33
  ```ruby
34
34
  # The year, month, and day should all be numbers. Although a string will still work
35
35
  scraper.get_date(year, month, day)
@@ -44,12 +44,33 @@ day = scraper.get_date(2015, 01, 15)
44
44
  pp day.nutrition_totals
45
45
  # ==>
46
46
  {:Date=>"Thursday, 15 January 2015",
47
- :Calories=>[2, 2, -9],
48
- :Fat=>[49, 50, 1],
49
- :Carbs=>[296, 290, -6],
50
- :Fiber=>[45, 35, -10],
51
- :Protein=>[197, 195, -2],
52
- :"Potass."=>[2, 4, 1]}
47
+ :Calories=>["2,399", "2,390", "-9"],
48
+ :Fat=>["49", "50", "1"],
49
+ :Carbs=>["296", "290", "-6"],
50
+ :Fiber=>["45", "35", "-10"],
51
+ :Protein=>["197", "195", "-2"],
52
+ :"Potass."=>["2,476", "4,000", "1,524"]}
53
+ ```
54
+
55
+ **How to retrive data from the hash:** This is simple ruby practice, but in order to save any frustration I will outline the process here:
56
+ ```ruby
57
+ day = scraper.get_date(2015, 01, 15)
58
+ nutrition_data = day.nutrition_totals
59
+
60
+ pp nutrition_data[:Date]
61
+ pp nutrition_data[:Calories]
62
+ pp nutrition_data[:Calories][0]
63
+ pp nutrition_data[:Fiber][1]
64
+ pp nutrition_data[:Carbs][1, 2]
65
+
66
+ #### OUTPUT:
67
+
68
+ # ==> "Thursday, 15 January 2015"
69
+ # ==> ["2,399", "2,390", "-9"]
70
+ # ==> "2,399"
71
+ # ==> "35"
72
+ # ==> ["290", "-6"]
73
+
53
74
  ```
54
75
 
55
76
 
@@ -26,9 +26,9 @@ class Day
26
26
 
27
27
  # Go through the nutrients table, find the values for its respective column
28
28
  nutrients.each_with_index do |nutrient, index|
29
- todays_total = totals_table.search('td')[index+1].text.strip.to_i
30
- daily_goal = totals_table.search('td')[index+9].text.strip.to_i
31
- difference = totals_table.search('td')[index+17].text.strip.to_i
29
+ todays_total = totals_table.search('td')[index+1].text.strip
30
+ daily_goal = totals_table.search('td')[index+9].text.strip
31
+ difference = totals_table.search('td')[index+17].text.strip
32
32
 
33
33
  nutrient_totals[nutrient.to_sym] = todays_total, daily_goal, difference
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module MyfitnesspalStats
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myfitnesspal_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hunter Ducharme
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.4.5
144
+ rubygems_version: 2.4.6
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Programatically access your daily nutrition from myfitnesspal.