lita-cwb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b2baf2f2b60a57f28cc81102d390276af8f5f48
4
+ data.tar.gz: ef518266d33b5cfb6549403266e5fafad6002477
5
+ SHA512:
6
+ metadata.gz: b093e48577c42a1f45d3208015b3cc0228bc5f31f6de15669b825f612e40e2c4859dc6cfad450e95a9f51499557d77832da0d96fcfdb46d56b048ff81cca3ed9
7
+ data.tar.gz: 565b5c412da38daa7294fe78f80f84f0bb441aaab60b7a4f90b79df7b042180fd8b6ac4dcaf39f625aa3ca0bcde256d3c14ce54715e58372b90f9a6e8d11270c
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,19 @@
1
+ # lita-cwb
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-cwb to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-cwb"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ TODO: Describe any configuration attributes the plugin exposes.
16
+
17
+ ## Usage
18
+
19
+ TODO: Describe the plugin's features and how to use them.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/cwb"
8
+
9
+ Lita::Handlers::Cwb.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,74 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+
4
+ module Lita
5
+ module Handlers
6
+ class Cwb < Handler
7
+ route(/^cwb\s+f\s(.*)/, :f, command: true, help: { "cwb f [WHERE]" => "Show me forecast information for location WHERE." })
8
+
9
+ def f(response)
10
+ where = response.matches.first.first
11
+ where.strip!
12
+ where.sub!('臺', '台')
13
+
14
+ case where
15
+ when "台北市", "台北"
16
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-009.xml"
17
+ when "新北市", "新北"
18
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-010.xml"
19
+ when "基隆市", "基隆", "雞籠"
20
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-011.xml"
21
+ when "花蓮縣", "花蓮", "洄瀾"
22
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-012.xml"
23
+ when "宜蘭縣", "宜蘭"
24
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-013.xml"
25
+ when "金門縣", "金門"
26
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-014.xml"
27
+ when "澎湖縣", "澎湖"
28
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-015.xml"
29
+ when "台南市", "台南"
30
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-016.xml"
31
+ when "高雄市", "高雄", "打狗"
32
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-017.xml"
33
+ when "嘉義縣"
34
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-018.xml"
35
+ when "嘉義市"
36
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-019.xml"
37
+ when "苗栗縣", "苗栗"
38
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-020.xml"
39
+ when "台中市", "台中"
40
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-021.xml"
41
+ when "桃園市", "桃園"
42
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-022.xml"
43
+ when "新竹縣"
44
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-023.xml"
45
+ when "新竹市"
46
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-024.xml"
47
+ when "屏東縣", "屏東"
48
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-025.xml"
49
+ when "南投縣", "南投"
50
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-026.xml"
51
+ when "台東縣", "台東"
52
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-027.xml"
53
+ when "彰化縣", "彰化"
54
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-028.xml"
55
+ when "雲林縣", "雲林"
56
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-029.xml"
57
+ when "連江縣", "馬祖"
58
+ uri = "http://opendata.cwb.gov.tw/opendata/MFC/F-C0032-030.xml"
59
+ else
60
+ response.reply t('not_match_location', {:where => where})
61
+ return
62
+ end
63
+
64
+ data = Nokogiri::XML(open(uri))
65
+ response.reply data.css("dataset location locationName").text
66
+ data.css("dataset parameterSet parameter").each do |params|
67
+ response.reply params.css("parameterValue").text
68
+ end
69
+ end
70
+ end
71
+
72
+ Lita.register_handler(Cwb)
73
+ end
74
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-cwb"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Huei-Horng Yo"]
5
+ spec.email = ["hiroshi@ghostsinthelab.org"]
6
+ spec.description = "Lita handler with Open Data from Central Weather Bureau"
7
+ spec.summary = "Lita handler with Open Data from Central Weather Bureau, get forecasts information from CWB."
8
+ spec.homepage = "https://github.com/hiroshiyui/lita-cwb"
9
+ spec.license = "MPL-2.0"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 4.3"
18
+ spec.add_runtime_dependency "nokogiri", "~> 1.6.6.2"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "pry-byebug"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rack-test"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
25
+ end
@@ -0,0 +1,5 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ cwb:
5
+ not_match_location: "No weather information for %{where}"
@@ -0,0 +1,4 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Cwb, lita_handler: true do
4
+ end
@@ -0,0 +1,6 @@
1
+ require "lita-cwb"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-cwb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Huei-Horng Yo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.6.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.6.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ description: Lita handler with Open Data from Central Weather Bureau
112
+ email:
113
+ - hiroshi@ghostsinthelab.org
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - README.md
121
+ - Rakefile
122
+ - lib/lita-cwb.rb
123
+ - lib/lita/handlers/cwb.rb
124
+ - lita-cwb.gemspec
125
+ - locales/en.yml
126
+ - spec/lita/handlers/cwb_spec.rb
127
+ - spec/spec_helper.rb
128
+ - templates/.gitkeep
129
+ homepage: https://github.com/hiroshiyui/lita-cwb
130
+ licenses:
131
+ - MPL-2.0
132
+ metadata:
133
+ lita_plugin_type: handler
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.4.6
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Lita handler with Open Data from Central Weather Bureau, get forecasts information
154
+ from CWB.
155
+ test_files:
156
+ - spec/lita/handlers/cwb_spec.rb
157
+ - spec/spec_helper.rb