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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b62c64474f4f154233d848c9b86fbb84b3188a6c
4
- data.tar.gz: 5e8e63d3c65b5bce498192e22a0212d05726b6b1
3
+ metadata.gz: b8deeffa6ca7a750d1b60791cb5961951a18fca5
4
+ data.tar.gz: 12cfb3a85517c157aa8ed7e1c719f3c698fbd5fb
5
5
  SHA512:
6
- metadata.gz: d63ac1f39b1462bdc08d938f0bf49fb3510a76c37e4d13f9800165400ddcc0abdfec8f4b119dbf06a6a0956bf33ec10107913b1ff81ab110d9e2df6870aea848
7
- data.tar.gz: 96d36891d6ba278ee939caafe86ec1a17f572d2894d9b5d4c8bd1f4eba7f762fe3f18cd740a191d98773c0fccbcee282ffd3ce057f288f825984b64483b67c62
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/[my-github-username]/iconik/fork )
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{app icon URL getting for apple store, google play and web favicon.}
12
- spec.description = %q{app icon URL getting for apple store, google play and web favicon.}
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,13 @@
1
+ require 'iconik/store'
2
+ require 'nokogiri'
3
+
4
+ module Iconik
5
+ class GooglePlay < Iconik::Store
6
+
7
+ def pluck_icon
8
+ r = client.response_body
9
+ doc = Nokogiri::HTML.parse(r, nil, nil)
10
+ doc.css('.cover-image')[0][:src]
11
+ end
12
+ end
13
+ end
@@ -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
@@ -0,0 +1,9 @@
1
+ module Iconik
2
+ class Store
3
+ attr_reader :url, :client
4
+ def initialize(url)
5
+ @url = url
6
+ @client = Iconik::HttpClient.new(url)
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Iconik
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/iconik.rb CHANGED
@@ -1,24 +1,8 @@
1
- require "iconik/version"
2
- require "iconik/http_client"
3
- require "json"
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
@@ -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.get_icon_url 'https://itunes.apple.com/jp/app/ingress/id576505181?mt=8' }
8
- it { expect(subject).to eq 'http://a5.mzstatic.com/us/r30/Purple4/v4/53/8c/f5/538cf5ae-f6fe-ef7b-15fd-bb7d7d84563a/mzl.vwbatafr.175x175-75.jpg' }
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.get_icon_url 'https://play.google.com/store/apps/details?id=com.nianticproject.ingress&hl=ja' }
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.1.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-09-22 00:00:00.000000000 Z
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: app icon URL getting for apple store, google play and web favicon.
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: app icon URL getting for apple store, google play and web favicon.
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