play_store_info 1.0.1 → 1.0.2
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 +4 -4
- data/lib/play_store_info.rb +20 -18
- data/lib/play_store_info/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 152208b65283d55b94c25cc3e23ddf71b952804a
|
4
|
+
data.tar.gz: 3a66480fd96222bb32d6abbef4bae2e072a528b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8bc2abe739890be73c7b640caa4476b583b2721eca7d3da9492a806f98a065343bb1e3024a4d00eb505fb85e99f281ebc6e5f24071abdc39a583005448a9fbe
|
7
|
+
data.tar.gz: 48a08e58c34854af54a7ffebd27da09aacf2c71fc8d4b0e8e453a94514b6c2004ccafcb27c9d4400f2f4386906bce94a52ab81f68df1d657deed06db8d32085c
|
data/lib/play_store_info.rb
CHANGED
@@ -7,31 +7,33 @@ module PlayStoreInfo
|
|
7
7
|
MIN_IDS_REGEXP_MATCHES = 2
|
8
8
|
FIRST_ID_REGEXP_MATCH = 1
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
class << self
|
11
|
+
def read(id, lang = 'en')
|
12
|
+
parse(id, "https://play.google.com/store/apps/details?id=#{id}&hl=#{lang}")
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def read_url(url)
|
16
|
+
id = url.match(/id=([[:alnum:]\.]+)[&]?/)
|
16
17
|
|
17
|
-
|
18
|
+
raise InvalidStoreLink unless google_store?(url) && id && id.length == MIN_IDS_REGEXP_MATCHES
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
parse(id[FIRST_ID_REGEXP_MATCH], url)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
+
private
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
def parse(id, url)
|
26
|
+
inspector ||= MetaInspector.new(url)
|
26
27
|
|
27
|
-
|
28
|
+
raise AppNotFound unless inspector.response.status == 200
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
AppParser.new(id, inspector.parsed)
|
31
|
+
rescue Faraday::ConnectionFailed, Faraday::SSLError, Errno::ETIMEDOUT
|
32
|
+
raise ConnectionError
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
def google_store?(url)
|
36
|
+
url.match(%r{\Ahttps://play.google.com})
|
37
|
+
end
|
36
38
|
end
|
37
39
|
end
|