play_store_info 1.0.0
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README.md +57 -0
- data/Rakefile +6 -0
- data/bin/console +9 -0
- data/bin/setup +7 -0
- data/lib/play_store_info.rb +37 -0
- data/lib/play_store_info/app_parser.rb +53 -0
- data/lib/play_store_info/errors.rb +23 -0
- data/lib/play_store_info/version.rb +3 -0
- data/play_store_info.gemspec +35 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cab2e61da7eecca73560055b1ae10126febad9b6
|
4
|
+
data.tar.gz: 09af52f4a401e558a5af0f3be47d745cc99a117a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cae8dc44688e1ff4c8e9cd873da07c994f3afe9a1127cb15d3c3ea9201d51f58c2ea7ec374530c82b9cf9cd392c3453a0579fdfa8e5a13e6ed0c63fffbe05cb5
|
7
|
+
data.tar.gz: eb6db666221f6769df649389d50a242b05fa39762e6ed7cfe013dbb49762e42d5f08aba977cb4a509a2595943df176392c3d0c67fd95911f6e3928596aabf21f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
AllCops:
|
3
|
+
TargetRubyVersion: 2.3
|
4
|
+
Exclude:
|
5
|
+
- 'db/**/*'
|
6
|
+
|
7
|
+
# Configuration parameters: AllowURI, URISchemes.
|
8
|
+
Metrics/LineLength:
|
9
|
+
Max: 100
|
10
|
+
|
11
|
+
# Offense count: 6
|
12
|
+
# Configuration parameters: Exclude.
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Hugo Sequeira
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
[](https://travis-ci.org/hugocore/app_store_info)
|
2
|
+
|
3
|
+
# PlayStoreInfo
|
4
|
+
|
5
|
+
Get details about any app in the Google Play Store. This gem uses `MetaInspector` to scrape the
|
6
|
+
app's Play Store web page and retrieve the necessary data.
|
7
|
+
|
8
|
+
Compatible with ruby >= 2.3.0
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'play_store_info'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install play_store_info
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
You first have to read the app details, using the store URL or directly with the ID:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
app = PlayStoreInfo.read_url('https://play.google.com/store/apps/details?id=com.airbnb.android&hl=en')
|
32
|
+
app = PlayStoreInfo.read('com.airbnb.android')
|
33
|
+
```
|
34
|
+
|
35
|
+
Then you have some attributes that can be read easily:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
app.id # => "com.airbnb.android"
|
39
|
+
app.name # => "Airbnb"
|
40
|
+
app.icon_url # => "http://lh6.ggpht.com/4jnm0-_9TBUdvNtQpefYE0T33..."
|
41
|
+
app.description # => "Make travel planning as mobile as you are..."
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `sh bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to debug your code.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hugocore/play_store_info.
|
53
|
+
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'play_store_info/errors'
|
2
|
+
require 'play_store_info/app_parser'
|
3
|
+
require 'metainspector'
|
4
|
+
require 'sanitize'
|
5
|
+
|
6
|
+
module PlayStoreInfo
|
7
|
+
MIN_IDS_REGEXP_MATCHES = 2
|
8
|
+
FIRST_ID_REGEXP_MATCH = 1
|
9
|
+
|
10
|
+
def self.read(id, lang = 'en')
|
11
|
+
parse(id, "https://play.google.com/store/apps/details?id=#{id}&hl=#{lang}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.read_url(url)
|
15
|
+
id = url.match(/id=([[:alnum:]\.]+)[&]?/)
|
16
|
+
|
17
|
+
raise InvalidStoreLink unless google_store?(url) && id && id.length == MIN_IDS_REGEXP_MATCHES
|
18
|
+
|
19
|
+
parse(id[FIRST_ID_REGEXP_MATCH], url)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def parse(id, url)
|
25
|
+
inspector ||= MetaInspector.new(url)
|
26
|
+
|
27
|
+
raise AppNotFound unless inspector.response.status == 200
|
28
|
+
|
29
|
+
AppParser.new(id, inspector.parsed).parse
|
30
|
+
rescue Faraday::ConnectionFailed, Faraday::SSLError, Errno::ETIMEDOUT
|
31
|
+
raise ConnectionError
|
32
|
+
end
|
33
|
+
|
34
|
+
def google_store?(url)
|
35
|
+
url.match(%r{\Ahttps://play.google.com})
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module PlayStoreInfo
|
4
|
+
class AppParser
|
5
|
+
def initialize(id, body)
|
6
|
+
@id = id
|
7
|
+
@body = body
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse
|
11
|
+
OpenStruct.new(to_hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_hash
|
15
|
+
{
|
16
|
+
id: @id,
|
17
|
+
name: read_app_name,
|
18
|
+
icon_url: read_logo_url,
|
19
|
+
description: read_description
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def read_app_name
|
26
|
+
@app_name ||= begin
|
27
|
+
name = @body.xpath('//div[@itemprop="name"]/div/text()').text
|
28
|
+
|
29
|
+
raise AppNotFound if name.empty?
|
30
|
+
|
31
|
+
# get the app proper name in case the title contains some description
|
32
|
+
name.split(' - ').first.strip
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def read_logo_url
|
37
|
+
@app_logo ||= begin
|
38
|
+
url = @body.xpath('//img[@itemprop="image"]/@src').first&.value&.strip || ''
|
39
|
+
|
40
|
+
# add the HTTP protocol if the image source is lacking http:// because it starts with //
|
41
|
+
url.match(%r{^https?:\/\/}).nil? ? "http://#{url.gsub(%r{\A\/\/}, '')}" : url
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def read_description
|
46
|
+
@app_description ||= begin
|
47
|
+
description = @body.xpath('//div[@itemprop="description"]').first&.inner_html&.strip
|
48
|
+
|
49
|
+
description.nil? ? '' : Sanitize.fragment(description).strip
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PlayStoreInfo
|
2
|
+
class GenericError < StandardError; end
|
3
|
+
|
4
|
+
class InvalidStoreLink < GenericError
|
5
|
+
def initialize
|
6
|
+
store_link = 'https://play.google.com/store/apps/details?id=com.your.app&hl=en'.freeze
|
7
|
+
|
8
|
+
super "URL should look like '#{store_link}'"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class AppNotFound < GenericError
|
13
|
+
def initialize
|
14
|
+
super 'Could not find app in Google Play Store'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class ConnectionError < GenericError
|
19
|
+
def initialize
|
20
|
+
super 'Could not retrieve your app information at the moment. Please try again later.'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'play_store_info/version'
|
6
|
+
|
7
|
+
# Describe your gem and declare its dependencies:
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'play_store_info'
|
10
|
+
spec.version = PlayStoreInfo::VERSION
|
11
|
+
spec.authors = ['Hugo Sequeira']
|
12
|
+
spec.email = ['hugoandresequeira@gmail.com']
|
13
|
+
|
14
|
+
spec.homepage = 'https://github.com/hugocore/play_store_info'
|
15
|
+
spec.summary = 'Simple Google Play store parser'
|
16
|
+
spec.description = 'Simple Google Play store parser'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
23
|
+
|
24
|
+
spec.add_dependency 'metainspector', '~> 5.1.1'
|
25
|
+
spec.add_dependency 'sanitize', '~> 4.0.1'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.3'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.35'
|
31
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.3'
|
32
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 1.22'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: play_store_info
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hugo Sequeira
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: metainspector
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sanitize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.0.1
|
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.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.35'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.35'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.22'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.22'
|
153
|
+
description: Simple Google Play store parser
|
154
|
+
email:
|
155
|
+
- hugoandresequeira@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
163
|
+
- ".ruby-version"
|
164
|
+
- ".travis.yml"
|
165
|
+
- Gemfile
|
166
|
+
- Gemfile.lock
|
167
|
+
- MIT-LICENSE
|
168
|
+
- README.md
|
169
|
+
- Rakefile
|
170
|
+
- bin/console
|
171
|
+
- bin/setup
|
172
|
+
- lib/play_store_info.rb
|
173
|
+
- lib/play_store_info/app_parser.rb
|
174
|
+
- lib/play_store_info/errors.rb
|
175
|
+
- lib/play_store_info/version.rb
|
176
|
+
- play_store_info.gemspec
|
177
|
+
homepage: https://github.com/hugocore/play_store_info
|
178
|
+
licenses:
|
179
|
+
- MIT
|
180
|
+
metadata: {}
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.5.1
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: Simple Google Play store parser
|
201
|
+
test_files: []
|