weatherfetch 0.0.1 → 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.
- checksums.yaml +4 -4
 - data/lib/weatherfetch/cli.rb +13 -18
 - data/lib/weatherfetch/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: adf062366579620ac82e2d599cd7f162be4b134d7fa011185d52fc0a548b0002
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: dacd56d05c3c1e17f07dde431dad3c1f95bf83361e795c8113e998f91cad7aa3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 48e0fbf3dc2ef9e3b6c41e25981c915ad6758a0e4e9c99b70ca17e9a409adbe33ce8514fdef7739121733b63965b718ef2d03517f86bbaeb0d37da833f54b49d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 73101963a77f63414fd5934030a5a6d5af47b38f8f86083a7c48f5b174db3f8c53150fa0181f761f3981f4ba9a1082a948a30c17bff84ccf2ac9fc8e4bc18acd
         
     | 
    
        data/lib/weatherfetch/cli.rb
    CHANGED
    
    | 
         @@ -10,16 +10,9 @@ module WeatherFetch 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  true
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                desc ' 
     | 
| 
       14 
     | 
    
         
            -
                def  
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
                  r = HTTParty.get('http://api.openweathermap.org/data/2.5/weather', options)
         
     | 
| 
       17 
     | 
    
         
            -
                  puts r
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                desc 'hourly', 'Get hourly weather for a given city'
         
     | 
| 
       21 
     | 
    
         
            -
                def hourly(city)
         
     | 
| 
       22 
     | 
    
         
            -
                  response = fetch_city_data(city, 'hourly')
         
     | 
| 
      
 13 
     | 
    
         
            +
                desc 'hourly', 'Get hourly weather for a given location'
         
     | 
| 
      
 14 
     | 
    
         
            +
                def hourly(location)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  response = fetch_location_data(location, 'hourly')
         
     | 
| 
       23 
16 
     | 
    
         | 
| 
       24 
17 
     | 
    
         
             
                  rows = response['hourly'].map do |hour|
         
     | 
| 
       25 
18 
     | 
    
         
             
                    [
         
     | 
| 
         @@ -34,19 +27,21 @@ module WeatherFetch 
     | 
|
| 
       34 
27 
     | 
    
         
             
                  table = Terminal::Table.new(
         
     | 
| 
       35 
28 
     | 
    
         
             
                    headings: create_headings(['Hour', 'Actual', 'Feels Like', 'Conditions', 'Humidity']),
         
     | 
| 
       36 
29 
     | 
    
         
             
                    rows: rows,
         
     | 
| 
       37 
     | 
    
         
            -
                    title: Rainbow( 
     | 
| 
      
 30 
     | 
    
         
            +
                    title: "🌧  #{Rainbow(location.capitalize).cornflower} 🌞"
         
     | 
| 
       38 
31 
     | 
    
         
             
                  )
         
     | 
| 
       39 
32 
     | 
    
         | 
| 
       40 
33 
     | 
    
         
             
                  puts table
         
     | 
| 
       41 
34 
     | 
    
         
             
                end
         
     | 
| 
       42 
35 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                desc 'daily', 'Get daily weather for a given  
     | 
| 
       44 
     | 
    
         
            -
                def daily( 
     | 
| 
       45 
     | 
    
         
            -
                  response =  
     | 
| 
      
 36 
     | 
    
         
            +
                desc 'daily', 'Get daily weather for a given location'
         
     | 
| 
      
 37 
     | 
    
         
            +
                def daily(location)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  response = fetch_location_data(location, 'daily')
         
     | 
| 
       46 
39 
     | 
    
         | 
| 
       47 
40 
     | 
    
         
             
                  rows = response['daily'].map do |day|
         
     | 
| 
       48 
41 
     | 
    
         
             
                    [
         
     | 
| 
       49 
42 
     | 
    
         
             
                      Rainbow(Time.at(day['dt']).strftime('%m/%d')).darkolivegreen,
         
     | 
| 
      
 43 
     | 
    
         
            +
                      Rainbow("#{day['temp']['min']}°F").darkolivegreen,
         
     | 
| 
      
 44 
     | 
    
         
            +
                      Rainbow("#{day['temp']['max']}°F").darkolivegreen,
         
     | 
| 
       50 
45 
     | 
    
         
             
                      Rainbow("#{day['temp']['morn']}°F").darkolivegreen,
         
     | 
| 
       51 
46 
     | 
    
         
             
                      Rainbow("#{day['temp']['day']}°F").darkolivegreen,
         
     | 
| 
       52 
47 
     | 
    
         
             
                      Rainbow("#{day['temp']['eve']}°F").darkolivegreen,
         
     | 
| 
         @@ -57,9 +52,9 @@ module WeatherFetch 
     | 
|
| 
       57 
52 
     | 
    
         
             
                  end
         
     | 
| 
       58 
53 
     | 
    
         | 
| 
       59 
54 
     | 
    
         
             
                  table = Terminal::Table.new do |t|
         
     | 
| 
       60 
     | 
    
         
            -
                    t.headings = create_headings(['Date', 'Morning', 'Afternoon', 'Evening', 'Night', 'Conditions', 'Humidity'])
         
     | 
| 
      
 55 
     | 
    
         
            +
                    t.headings = create_headings(['Date', 'Min', 'Max', 'Morning', 'Afternoon', 'Evening', 'Night', 'Conditions', 'Humidity'])
         
     | 
| 
       61 
56 
     | 
    
         
             
                    t.rows = rows
         
     | 
| 
       62 
     | 
    
         
            -
                    t.title = Rainbow( 
     | 
| 
      
 57 
     | 
    
         
            +
                    t.title = "🌧  #{Rainbow(location.capitalize).cornflower} 🌞"
         
     | 
| 
       63 
58 
     | 
    
         
             
                    t.style = { all_separators: :true }
         
     | 
| 
       64 
59 
     | 
    
         
             
                  end
         
     | 
| 
       65 
60 
     | 
    
         | 
| 
         @@ -71,8 +66,8 @@ module WeatherFetch 
     | 
|
| 
       71 
66 
     | 
    
         
             
                  headings.map { |h| Rainbow(h).red }
         
     | 
| 
       72 
67 
     | 
    
         
             
                end
         
     | 
| 
       73 
68 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                def  
     | 
| 
       75 
     | 
    
         
            -
                  latitude, longitude = Geocoder.search( 
     | 
| 
      
 69 
     | 
    
         
            +
                def fetch_location_data(location, type)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  latitude, longitude = Geocoder.search(location).first.coordinates
         
     | 
| 
       76 
71 
     | 
    
         | 
| 
       77 
72 
     | 
    
         
             
                  exclusions = ['hourly', 'minutely', 'current', 'daily'].reject do |ex|
         
     | 
| 
       78 
73 
     | 
    
         
             
                    ex == type
         
     | 
    
        data/lib/weatherfetch/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: weatherfetch
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dylan Andrews
         
     | 
| 
         @@ -107,7 +107,7 @@ files: 
     | 
|
| 
       107 
107 
     | 
    
         
             
            - lib/weatherfetch.rb
         
     | 
| 
       108 
108 
     | 
    
         
             
            - lib/weatherfetch/cli.rb
         
     | 
| 
       109 
109 
     | 
    
         
             
            - lib/weatherfetch/version.rb
         
     | 
| 
       110 
     | 
    
         
            -
            homepage:
         
     | 
| 
      
 110 
     | 
    
         
            +
            homepage: https://github.com/DylanAndrews/weatherfetch
         
     | 
| 
       111 
111 
     | 
    
         
             
            licenses:
         
     | 
| 
       112 
112 
     | 
    
         
             
            - MIT
         
     | 
| 
       113 
113 
     | 
    
         
             
            metadata: {}
         
     | 
| 
         @@ -129,5 +129,5 @@ requirements: [] 
     | 
|
| 
       129 
129 
     | 
    
         
             
            rubygems_version: 3.1.2
         
     | 
| 
       130 
130 
     | 
    
         
             
            signing_key:
         
     | 
| 
       131 
131 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       132 
     | 
    
         
            -
            summary:  
     | 
| 
      
 132 
     | 
    
         
            +
            summary: CLI tool for fetching weather data
         
     | 
| 
       133 
133 
     | 
    
         
             
            test_files: []
         
     |