pm25 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/lib/pm25/base.rb +31 -0
- data/lib/pm25/cities/beijing.rb +5 -0
- data/lib/pm25/cities/chengdu.rb +5 -0
- data/lib/pm25/cities/guangzhou.rb +5 -0
- data/lib/pm25/cities/shanghai.rb +5 -0
- data/lib/pm25/cities/shenyang.rb +5 -0
- data/lib/pm25/exceptions.rb +3 -0
- data/lib/pm25/version.rb +3 -0
- data/lib/pm25.rb +5 -0
- data/pm25.gemspec +26 -0
- data/spec/pm25_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d4e9cf8a047d64cfb512a1b1e34b74c757bca21
|
4
|
+
data.tar.gz: 8b3d11aecaec6fd94ee6a3e13f4b8b5b6e77e8c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4e2a47f1af8ff811132040b5e92365df8773906129e5af96b127f8352d9e56d24eb0b62787afbeb578c9590649f5711a5452cd78637eab2a42ca1756e49b647
|
7
|
+
data.tar.gz: 34a8c136097602f86e226a1b88eea5d1fc21c4866d2e39bbcdfe0f959f8e6f27a0365e542a3c37badaf994eda0c61f86c75f59a24dac211b900c7bae8f3648a5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Xuhao
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# PM25
|
2
|
+
|
3
|
+
[![Build Status](https://www.travis-ci.org/ekohe/pm25.png?branch=master)](https://www.travis-ci.org/ekohe/pm25)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/ekohe/pm25.png)](https://codeclimate.com/github/ekohe/pm25)
|
5
|
+
|
6
|
+
PM2.5 and ozone readings Data From U.S. Consulate.
|
7
|
+
|
8
|
+
Include below cities of China:
|
9
|
+
|
10
|
+
- Beijing
|
11
|
+
- Shanghai
|
12
|
+
- Chengdu
|
13
|
+
- Guangzhou
|
14
|
+
- Shenyang
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'pm25'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install pm25
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Beijing
|
34
|
+
PM25::Beijing.get
|
35
|
+
# => return an array include current and history data:
|
36
|
+
# [{"title"=>"06/04/2013 6:00:00 PM",
|
37
|
+
# "link"=>"http://www.stateair.net/web/post/1/1.html",
|
38
|
+
# "description"=>
|
39
|
+
# "06-04-2013 18:00; PM2.5; 71.0; 159; Unhealthy (at 24-hour exposure at this level)",
|
40
|
+
# "Param"=>"PM2.5",
|
41
|
+
# "Conc"=>"71.0",
|
42
|
+
# "AQI"=>"159",
|
43
|
+
# "Desc"=>"Unhealthy (at 24-hour exposure at this level)",
|
44
|
+
# "ReadingDateTime"=>"06/04/2013 6:00:00 PM"},
|
45
|
+
# {"title"=>"06/04/2013 5:00:00 PM",
|
46
|
+
# ......
|
47
|
+
|
48
|
+
# Shanghai
|
49
|
+
PM25::Shanghai.get
|
50
|
+
|
51
|
+
# Chengdu
|
52
|
+
PM25::Chengdu.get
|
53
|
+
|
54
|
+
# Guangzhou
|
55
|
+
PM25::Guangzhou.get
|
56
|
+
|
57
|
+
# Shenyang
|
58
|
+
PM25::Shenyang.get
|
59
|
+
```
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/pm25/base.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'active_support/core_ext/class/attribute'
|
3
|
+
require 'active_support/core_ext/hash/conversions'
|
4
|
+
module PM25
|
5
|
+
class Base
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
class_attribute :base_uri, :city_id
|
9
|
+
self.base_uri = URI::HTTP.build({host: 'www.stateair.net'})
|
10
|
+
|
11
|
+
def self.get
|
12
|
+
Hash.from_xml(HTTParty.get(url).body)['rss']['channel']['item']
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.uri
|
16
|
+
raise NotImplementedError, "Please set value for 'city_id' class attributes in '#{self.name}' class." unless self.city_id
|
17
|
+
self.base_uri.path = "/web/rss/1/#{self.city_id.to_s}.xml"
|
18
|
+
self.base_uri
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.url
|
22
|
+
uri.to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'pm25/cities/beijing'
|
28
|
+
require 'pm25/cities/chengdu'
|
29
|
+
require 'pm25/cities/guangzhou'
|
30
|
+
require 'pm25/cities/shanghai'
|
31
|
+
require 'pm25/cities/shenyang'
|
data/lib/pm25/version.rb
ADDED
data/lib/pm25.rb
ADDED
data/pm25.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pm25/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pm25"
|
8
|
+
spec.version = Pm25::VERSION
|
9
|
+
spec.authors = ["Xuhao"]
|
10
|
+
spec.email = ["xuhao@rubyfans.com"]
|
11
|
+
spec.description = %q{PM2.5 reporting from U.S. Consulate}
|
12
|
+
spec.summary = %q{PM2.5 reporting from U.S. Consulate}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_dependency 'activesupport'
|
25
|
+
spec.add_dependency 'httparty'
|
26
|
+
end
|
data/spec/pm25_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pm25
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xuhao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
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: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: PM2.5 reporting from U.S. Consulate
|
84
|
+
email:
|
85
|
+
- xuhao@rubyfans.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- .travis.yml
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/pm25.rb
|
98
|
+
- lib/pm25/base.rb
|
99
|
+
- lib/pm25/cities/beijing.rb
|
100
|
+
- lib/pm25/cities/chengdu.rb
|
101
|
+
- lib/pm25/cities/guangzhou.rb
|
102
|
+
- lib/pm25/cities/shanghai.rb
|
103
|
+
- lib/pm25/cities/shenyang.rb
|
104
|
+
- lib/pm25/exceptions.rb
|
105
|
+
- lib/pm25/version.rb
|
106
|
+
- pm25.gemspec
|
107
|
+
- spec/pm25_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
homepage: ''
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.0.3
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: PM2.5 reporting from U.S. Consulate
|
133
|
+
test_files:
|
134
|
+
- spec/pm25_spec.rb
|
135
|
+
- spec/spec_helper.rb
|