iconik 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/iconik.gemspec +2 -2
- data/lib/iconik/google_play.rb +13 -0
- data/lib/iconik/i_tunes.rb +26 -0
- data/lib/iconik/store.rb +9 -0
- data/lib/iconik/version.rb +1 -1
- data/lib/iconik.rb +5 -21
- data/spec/lib/iconik_spec.rb +3 -3
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8deeffa6ca7a750d1b60791cb5961951a18fca5
|
4
|
+
data.tar.gz: 12cfb3a85517c157aa8ed7e1c719f3c698fbd5fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11caa69208055b64e4e4442ce54906ac0fdefd46b27011c27224a64b15ffedad0a12e8580bf203c12f57416f177ab7526673f8e83dd92b23ddd93d85d66c5911
|
7
|
+
data.tar.gz: 2bdd45bac5efdeb168a04dacf3b47525747410db539de732b06fc3639a4613f2b6e4a1246bb2ea13ec1fcbfd250bb59c7beb886494a63cae415cff6ebd47c6de
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Iconik::GooglePlay.get_icon_url 'https://play.google.com/store/apps/details?id=c
|
|
44
44
|
|
45
45
|
## Contributing
|
46
46
|
|
47
|
-
1. Fork it ( https://github.com/
|
47
|
+
1. Fork it ( https://github.com/kazuaking/iconik/fork )
|
48
48
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
49
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
50
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/iconik.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Iconik::VERSION
|
9
9
|
spec.authors = ["kazuaking"]
|
10
10
|
spec.email = ["kazuaki.it@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{This library gets the icon from the page of GooglePlay and the iTunes store.}
|
12
|
+
spec.description = %q{This library gets the icon from the page of GooglePlay and the iTunes store.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'iconik/store'
|
2
|
+
|
3
|
+
module Iconik
|
4
|
+
class ITunes < Iconik::Store
|
5
|
+
attr_reader :appid
|
6
|
+
|
7
|
+
def initialize(arg_url)
|
8
|
+
@url = arg_url
|
9
|
+
@appid = pluck_app_id(url)
|
10
|
+
@client = Iconik::HttpClient.new("http://itunes.apple.com/lookup?id=#{appid}&country=JP")
|
11
|
+
end
|
12
|
+
|
13
|
+
def pluck_icon
|
14
|
+
j = JSON.parse(client.response_body)
|
15
|
+
j['results'][0]['artworkUrl60']
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def pluck_app_id(url)
|
21
|
+
md = url.match(/\/id([0-9]+)/)
|
22
|
+
raise 'no serch app id.' unless md[1]
|
23
|
+
md[1]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/iconik/store.rb
ADDED
data/lib/iconik/version.rb
CHANGED
data/lib/iconik.rb
CHANGED
@@ -1,24 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'iconik/version'
|
2
|
+
require 'iconik/http_client'
|
3
|
+
require 'iconik/google_play'
|
4
|
+
require 'iconik/i_tunes'
|
5
|
+
require 'json'
|
4
6
|
|
5
7
|
module Iconik
|
6
|
-
require 'nokogiri'
|
7
|
-
module ITunes
|
8
|
-
def self.get_icon_url(url)
|
9
|
-
client = Iconik::HttpClient.new(url)
|
10
|
-
r = client.response_body
|
11
|
-
doc = Nokogiri::HTML.parse(r, nil, nil)
|
12
|
-
doc.xpath('//*[@id="left-stack"]/div[1]/a[1]/div/img')[0][:'src-swap']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module GooglePlay
|
17
|
-
def self.get_icon_url(url)
|
18
|
-
client = Iconik::HttpClient.new(url)
|
19
|
-
r = client.response_body
|
20
|
-
doc = Nokogiri::HTML.parse(r, nil, nil)
|
21
|
-
doc.css(".cover-image")[0][:src]
|
22
|
-
end
|
23
|
-
end
|
24
8
|
end
|
data/spec/lib/iconik_spec.rb
CHANGED
@@ -4,11 +4,11 @@ require "iconik"
|
|
4
4
|
describe Iconik do
|
5
5
|
# https://itunes.apple.com/jp/app/ingress/id576505181?mt=8
|
6
6
|
describe "Iconik::ITunes" do
|
7
|
-
subject { Iconik::ITunes.
|
8
|
-
it { expect(subject).to eq 'http://
|
7
|
+
subject { Iconik::ITunes.new('https://itunes.apple.com/jp/app/ingress/id576505181?mt=8').pluck_icon }
|
8
|
+
it { expect(subject).to eq 'http://a734.phobos.apple.com/us/r30/Purple4/v4/98/30/af/9830af8b-5e97-9af2-6a1c-8c3ecd593ed8/Icon-57.png' }
|
9
9
|
end
|
10
10
|
describe "Iconik::GooglePlay" do
|
11
|
-
subject { Iconik::GooglePlay.
|
11
|
+
subject { Iconik::GooglePlay.new('https://play.google.com/store/apps/details?id=com.nianticproject.ingress&hl=ja').pluck_icon }
|
12
12
|
it { expect(subject).to eq 'https://lh3.ggpht.com/j8lGWdhEjmw5rVZ6CiJY_k5D0iPqp_jomAUdyS_n8v5SUQVb8Dt-USXUZXmx1QAca8zJ=w300' }
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iconik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kazuaking
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: This library gets the icon from the page of GooglePlay and the iTunes
|
42
|
+
store.
|
42
43
|
email:
|
43
44
|
- kazuaki.it@gmail.com
|
44
45
|
executables: []
|
@@ -53,7 +54,10 @@ files:
|
|
53
54
|
- Rakefile
|
54
55
|
- iconik.gemspec
|
55
56
|
- lib/iconik.rb
|
57
|
+
- lib/iconik/google_play.rb
|
56
58
|
- lib/iconik/http_client.rb
|
59
|
+
- lib/iconik/i_tunes.rb
|
60
|
+
- lib/iconik/store.rb
|
57
61
|
- lib/iconik/version.rb
|
58
62
|
- spec/lib/iconik_spec.rb
|
59
63
|
- spec/spec_helper.rb
|
@@ -80,7 +84,7 @@ rubyforge_project:
|
|
80
84
|
rubygems_version: 2.2.0
|
81
85
|
signing_key:
|
82
86
|
specification_version: 4
|
83
|
-
summary:
|
87
|
+
summary: This library gets the icon from the page of GooglePlay and the iTunes store.
|
84
88
|
test_files:
|
85
89
|
- spec/lib/iconik_spec.rb
|
86
90
|
- spec/spec_helper.rb
|