ruboty-livedoor_weather 0.1.2 → 0.2.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: 8bbb1ba7319abbf046ec754a1bfc8d92bf40e6f8
4
- data.tar.gz: f0f0e0c8611d210695c7661d03826f2ee9f543fa
3
+ metadata.gz: 92db96ea940c9ae3582cd0a2d70c0a171a63b065
4
+ data.tar.gz: 831caf452894e8ebdf4e567c88ab8f5a0a2267eb
5
5
  SHA512:
6
- metadata.gz: a5cec509856fa4d637568c56a5365605a4a0fd39764c381232f2df987424c0b4f86ab2c9ea1fe6ea4287d977fdcfd3ef893eba03540ad960421fcff3482fa104
7
- data.tar.gz: b0311972f7027624968b4d1f4768af0a88c7ea6e6c9a9e41b089fe8144eb09149c7e84ac31c551406f92604b35e99d108985cc07b65822b7907f2446dfa30771
6
+ metadata.gz: a96daf9e5ced354fd97275ba562bd0c9dcde25b3a6debe02d5f642b1172ea6ebdf07b1570455fce4d10a8a111b2f1e40d712448a6c78352f977225c932eab427
7
+ data.tar.gz: dfb4756bab7c17f6f58c3c3deca0bfd487b1869131c3002b2c807fde8cd645ee4f6232dc9b6fc53507535b2fe543fb622a9c950a393800250ffd12ba5fcf75ea
data/README.md CHANGED
@@ -12,6 +12,9 @@ gem 'ruboty-livedoor_weather'
12
12
 
13
13
  ## Usage
14
14
 
15
+
16
+ ### Simple way
17
+
15
18
  Talk to your ruboty:
16
19
 
17
20
  ```
@@ -20,15 +23,26 @@ ruboty livedoor_weather
20
23
 
21
24
  Then shows forecasts specified by `ENV['LDW_CITY']` (default : '東京').
22
25
 
26
+ ### Specify area
27
+
23
28
  You can specify city to show forecast:
24
29
 
25
30
  ```
26
31
  ruboty livedoor_weather 種子島
27
32
  ```
28
33
 
34
+ ### Also sho pinpoint locations
35
+
36
+ You can specify locations to show URL to pinpoint location page:
37
+
38
+ ```
39
+ ruboty livedoor_weather 京都 京都市中京区 長岡京市
40
+ ```
41
+
42
+ Show all pinpoint locations if location list includes `all`.
43
+
29
44
  List of cities is [here](http://weather.livedoor.com/forecast/rss/primary_area.xml).
30
45
 
31
46
  ## License
32
47
 
33
48
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
-
@@ -19,9 +19,23 @@ module Ruboty::LivedoorWeather
19
19
 
20
20
  response = RestClient.get(ENDPOINT, params: { city: cc })
21
21
  json = JSON.parse(response)
22
-
23
22
  forecasts = format_forecasts(json['forecasts'])
24
- "*#{@city}* の天気予報です。\n#{forecasts}\n\n#{remove_linebreak(json['description']['text'])}"
23
+
24
+ result = [
25
+ "*#{@city}* の天気予報です。",
26
+ forecasts,
27
+ "\n",
28
+ remove_linebreak(json['description']['text']),
29
+ ]
30
+
31
+ pinpoint_locations = format_pinpoint_locations(json['pinpointLocations'], @locations)
32
+
33
+ unless pinpoint_locations.empty?
34
+ result += ["\n", "【ピンポイント天気】"]
35
+ result += pinpoint_locations
36
+ end
37
+
38
+ result.join("\n")
25
39
  end
26
40
 
27
41
  private
@@ -51,6 +65,12 @@ module Ruboty::LivedoorWeather
51
65
  "気温:#{min}/#{max} #{unit == 'celsius' ? 'C' : 'F' }"
52
66
  end
53
67
 
68
+ def format_pinpoint_locations(data, locations)
69
+ data.find_all { |d|
70
+ locations.include?('all') || locations.include?(d['name'])
71
+ }.map { |d| "#{d['name']} : #{d['link']}" }
72
+ end
73
+
54
74
  def remove_linebreak(forecast_description)
55
75
  forecast_description.gsub(/[^\n。】]\n/) { |m| m.delete("\n") }
56
76
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module LivedoorWeather
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-livedoor_weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIOYA, Hiromu