iconik 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b62c64474f4f154233d848c9b86fbb84b3188a6c
4
+ data.tar.gz: 5e8e63d3c65b5bce498192e22a0212d05726b6b1
5
+ SHA512:
6
+ metadata.gz: d63ac1f39b1462bdc08d938f0bf49fb3510a76c37e4d13f9800165400ddcc0abdfec8f4b119dbf06a6a0956bf33ec10107913b1ff81ab110d9e2df6870aea848
7
+ data.tar.gz: 96d36891d6ba278ee939caafe86ec1a17f572d2894d9b5d4c8bd1f4eba7f762fe3f18cd740a191d98773c0fccbcee282ffd3ce057f288f825984b64483b67c62
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iconik.gemspec
4
+ gemspec
5
+
6
+ gem 'nokogiri'
7
+ group :test do
8
+ gem 'rspec'
9
+ gem 'webmock'
10
+ gem 'vcr'
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 kazuaking
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Iconik
2
+
3
+ This library gets the icon from the page of GooglePlay and the iTunes store .
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'iconik'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install iconik
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+
24
+ require "iconik"
25
+
26
+ # iTunes store
27
+
28
+ Iconik::ITunes.get_icon_url 'https://itunes.apple.com/jp/app/ingress/id576505181?mt=8'
29
+ => "http://a5.mzstatic.com/us/r30/Purple4/v4/53/8c/f5/538cf5ae-f6fe-ef7b-15fd-bb7d7d84563a/mzl.vwbatafr.175x175-75.jpg"
30
+
31
+ # Google play
32
+
33
+ Iconik::GooglePlay.get_icon_url 'https://play.google.com/store/apps/details?id=com.nianticproject.ingress&hl=ja'
34
+ => "https://lh3.ggpht.com/j8lGWdhEjmw5rVZ6CiJY_k5D0iPqp_jomAUdyS_n8v5SUQVb8Dt-USXUZXmx1QAca8zJ=w300"
35
+
36
+ ```
37
+
38
+ ## TODO
39
+
40
+
41
+ - web thumbnail
42
+ - CI
43
+
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/iconik/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/iconik.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iconik/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iconik"
8
+ spec.version = Iconik::VERSION
9
+ spec.authors = ["kazuaking"]
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.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
data/lib/iconik.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "iconik/version"
2
+ require "iconik/http_client"
3
+ require "json"
4
+
5
+ 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
+ end
@@ -0,0 +1,17 @@
1
+ module Iconik
2
+ require 'open-uri'
3
+ class HttpClient
4
+ attr_reader :url
5
+
6
+ def initialize(url)
7
+ @url = url
8
+ end
9
+
10
+ def response_body
11
+ open(url) do |f|
12
+ charset = f.charset
13
+ f.read
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Iconik
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+ require "iconik"
3
+
4
+ describe Iconik do
5
+ # https://itunes.apple.com/jp/app/ingress/id576505181?mt=8
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' }
9
+ end
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' }
12
+ it { expect(subject).to eq 'https://lh3.ggpht.com/j8lGWdhEjmw5rVZ6CiJY_k5D0iPqp_jomAUdyS_n8v5SUQVb8Dt-USXUZXmx1QAca8zJ=w300' }
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'webmock/rspec'
8
+ require 'vcr'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+
21
+ VCR.configure do |c|
22
+ c.cassette_library_dir = 'spec/vcr'
23
+ c.hook_into :webmock
24
+ c.allow_http_connections_when_no_cassette = true
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iconik
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kazuaking
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: app icon URL getting for apple store, google play and web favicon.
42
+ email:
43
+ - kazuaki.it@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - iconik.gemspec
55
+ - lib/iconik.rb
56
+ - lib/iconik/http_client.rb
57
+ - lib/iconik/version.rb
58
+ - spec/lib/iconik_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.0
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: app icon URL getting for apple store, google play and web favicon.
84
+ test_files:
85
+ - spec/lib/iconik_spec.rb
86
+ - spec/spec_helper.rb