apple_system_status 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -1
- data/CHANGELOG.md +14 -6
- data/README.md +1 -1
- data/apple_system_status.gemspec +2 -1
- data/lib/apple_system_status/crawler.rb +34 -16
- data/lib/apple_system_status/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f77961a141ceb44f68bc7c93229402090f61ec
|
4
|
+
data.tar.gz: 8fe3af494c23efe8d421a1dc7cedf8f3954a51a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15189394dc9b10216575c734de79eb7600339d0cf69923f0472c182709f66698bec71a80a53820989e15fb161e389143035dfff4f48bc6cf82f6d1df46aad195
|
7
|
+
data.tar.gz: aee0437ce315516160e9f8c2ad6f26bb7c50d3bab7080c99ce61f6d2ebe9706cfb8ba7d235fad4728aa88c7177bd4a7a64813177da27275ac4bdcecbb7f742a9
|
data/.travis.yml
CHANGED
@@ -3,12 +3,20 @@ rvm:
|
|
3
3
|
- 2.1
|
4
4
|
- 2.2.2
|
5
5
|
- 2.3.1
|
6
|
+
- 2.4.0
|
6
7
|
- ruby-head
|
7
8
|
before_script:
|
8
9
|
- export CI=true
|
9
10
|
- export CODECLIMATE_REPO_TOKEN=89b665462d69ce4c873ee8165d496c4a97b9afaaf48e375c1bc3200e4b45b1e7
|
11
|
+
- mkdir travis-phantomjs
|
12
|
+
- wget https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
|
13
|
+
- tar -xvf $PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis-phantomjs
|
14
|
+
- export PATH=$PWD/travis-phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH
|
15
|
+
- phantomjs --version
|
10
16
|
before_install: gem install bundler -v 1.10.5
|
11
|
-
script:
|
17
|
+
script:
|
18
|
+
- bundle exec rspec
|
19
|
+
- bundle exec codeclimate-test-reporter
|
12
20
|
branches:
|
13
21
|
only:
|
14
22
|
- master
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v0.
|
3
|
+
## [v0.2.0](https://github.com/sue445/apple_system_status/tree/v0.2.0) (2016-09-04)
|
4
|
+
[Full Changelog](https://github.com/sue445/apple_system_status/compare/v0.1.1...v0.2.0)
|
5
|
+
|
6
|
+
**Merged pull requests:**
|
7
|
+
|
8
|
+
- Fix memory leak issue [\#12](https://github.com/sue445/apple_system_status/pull/12) ([sue445](https://github.com/sue445))
|
9
|
+
- Build with ruby 2.3 on TravisCI [\#11](https://github.com/sue445/apple_system_status/pull/11) ([sue445](https://github.com/sue445))
|
10
|
+
|
11
|
+
## [v0.1.1](https://github.com/sue445/apple_system_status/tree/v0.1.1) (2015-09-05)
|
4
12
|
[Full Changelog](https://github.com/sue445/apple_system_status/compare/v0.1.0...v0.1.1)
|
5
13
|
|
6
14
|
**Merged pull requests:**
|
7
15
|
|
8
16
|
- ignore js errors [\#10](https://github.com/sue445/apple_system_status/pull/10) ([sue445](https://github.com/sue445))
|
9
17
|
|
10
|
-
## [v0.1.0](https://github.com/sue445/apple_system_status/tree/v0.1.0) (2015
|
18
|
+
## [v0.1.0](https://github.com/sue445/apple_system_status/tree/v0.1.0) (2015-07-28)
|
11
19
|
[Full Changelog](https://github.com/sue445/apple_system_status/compare/v0.1.0.beta3...v0.1.0)
|
12
20
|
|
13
|
-
## [v0.1.0.beta3](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta3) (2015
|
21
|
+
## [v0.1.0.beta3](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta3) (2015-07-26)
|
14
22
|
[Full Changelog](https://github.com/sue445/apple_system_status/compare/v0.1.0.beta2...v0.1.0.beta3)
|
15
23
|
|
16
24
|
**Merged pull requests:**
|
@@ -21,14 +29,14 @@
|
|
21
29
|
- sort by title [\#6](https://github.com/sue445/apple_system_status/pull/6) ([sue445](https://github.com/sue445))
|
22
30
|
- Write readme [\#4](https://github.com/sue445/apple_system_status/pull/4) ([sue445](https://github.com/sue445))
|
23
31
|
|
24
|
-
## [v0.1.0.beta2](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta2) (2015
|
32
|
+
## [v0.1.0.beta2](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta2) (2015-07-25)
|
25
33
|
[Full Changelog](https://github.com/sue445/apple_system_status/compare/v0.1.0.beta1...v0.1.0.beta2)
|
26
34
|
|
27
35
|
**Merged pull requests:**
|
28
36
|
|
29
37
|
- Fix error when exists blank cell [\#5](https://github.com/sue445/apple_system_status/pull/5) ([sue445](https://github.com/sue445))
|
30
38
|
|
31
|
-
## [v0.1.0.beta1](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta1) (2015
|
39
|
+
## [v0.1.0.beta1](https://github.com/sue445/apple_system_status/tree/v0.1.0.beta1) (2015-07-23)
|
32
40
|
**Merged pull requests:**
|
33
41
|
|
34
42
|
- refactor [\#3](https://github.com/sue445/apple_system_status/pull/3) ([sue445](https://github.com/sue445))
|
@@ -37,4 +45,4 @@
|
|
37
45
|
|
38
46
|
|
39
47
|
|
40
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
48
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
data/apple_system_status.gemspec
CHANGED
@@ -33,11 +33,12 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency "thor"
|
34
34
|
|
35
35
|
spec.add_development_dependency "bundler"
|
36
|
-
spec.add_development_dependency "codeclimate-test-reporter"
|
36
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
37
37
|
spec.add_development_dependency "coveralls"
|
38
38
|
spec.add_development_dependency "pry-byebug"
|
39
39
|
spec.add_development_dependency "rake", "~> 10.0"
|
40
40
|
spec.add_development_dependency "rspec"
|
41
41
|
spec.add_development_dependency "rspec-parameterized"
|
42
|
+
spec.add_development_dependency "simplecov"
|
42
43
|
spec.add_development_dependency "yard"
|
43
44
|
end
|
@@ -6,6 +6,8 @@ module AppleSystemStatus
|
|
6
6
|
class Crawler
|
7
7
|
USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"
|
8
8
|
|
9
|
+
MAX_RETRY_COUNT = 5
|
10
|
+
|
9
11
|
def initialize
|
10
12
|
Capybara.register_driver :poltergeist do |app|
|
11
13
|
Capybara::Poltergeist::Driver.new(app, js_errors: false)
|
@@ -32,29 +34,25 @@ module AppleSystemStatus
|
|
32
34
|
def perform(country: nil, title: nil)
|
33
35
|
@session.visit(apple_url(country))
|
34
36
|
|
35
|
-
title_parts = [
|
36
|
-
@session.find("#key_date_text").text,
|
37
|
-
@session.find("#key_date").text,
|
38
|
-
@session.find("#key_date_post").text,
|
39
|
-
]
|
40
|
-
|
41
37
|
response = {
|
42
|
-
title:
|
38
|
+
title: @session.find(".section-date .date-copy").text.strip,
|
43
39
|
services: [],
|
44
40
|
}
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
42
|
+
MAX_RETRY_COUNT.times do
|
43
|
+
services = fetch_services
|
44
|
+
|
45
|
+
if services.empty?
|
46
|
+
# wait until the page is fully loaded
|
47
|
+
sleep 1
|
48
|
+
else
|
49
|
+
response[:services] = services
|
50
|
+
break
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
54
|
+
raise "Not found services" if response[:services].empty?
|
55
|
+
|
58
56
|
unless title.blank?
|
59
57
|
response[:services].select! { |service| service[:title] == title }
|
60
58
|
end
|
@@ -90,5 +88,25 @@ module AppleSystemStatus
|
|
90
88
|
ensure
|
91
89
|
crawler.quit!
|
92
90
|
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def fetch_services
|
95
|
+
@session.all("#ssp-lights-table td").each_with_object([]) do |td, services|
|
96
|
+
begin
|
97
|
+
names = td.find(".light-container .light-content.light-name").text.split(" - ")
|
98
|
+
light_image = td.find(".light-container .light-content.light-image div")["class"]
|
99
|
+
|
100
|
+
services << {
|
101
|
+
title: names[0],
|
102
|
+
description: names[1],
|
103
|
+
status: light_image.gsub("light-", ""),
|
104
|
+
}
|
105
|
+
rescue Capybara::ElementNotFound
|
106
|
+
# suppress error (for blank cell)
|
107
|
+
# NOTE: Capybara::Node::Matchers#has_css? is very slow!
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
93
111
|
end
|
94
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apple_system_status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.0.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: coveralls
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: simplecov
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: yard
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
239
|
version: '0'
|
226
240
|
requirements: []
|
227
241
|
rubyforge_project:
|
228
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.6.8
|
229
243
|
signing_key:
|
230
244
|
specification_version: 4
|
231
245
|
summary: Apple System Status scraping library
|