fetch_app 0.0.1
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 +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/fetch_app.gemspec +25 -0
- data/lib/fetch_app/version.rb +3 -0
- data/lib/fetch_app.rb +99 -0
- data/sh.sh +3 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c51d50531602c86cf33bf56cbc3a622b6399fba3
|
4
|
+
data.tar.gz: b640628b002ccb9044299ec4473778b9cd15ce66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e245ca52275d252e7ea3d86ddcf83de790d346a40587d84a49721ab7055bbbab0c1b2691a476bd397354f34c84e816bb23ed782ce2343a4654863e360d2400d2
|
7
|
+
data.tar.gz: 1e83db569a4e47dac4db1fc3e0da395d049ee3d67b8a69b447f9514ece46bf4ab7c21a43691b576ca513452921657354b87abcd0a6de20b51d037fd484445ece
|
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/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Will
|
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,37 @@
|
|
1
|
+
# FetchApp
|
2
|
+
|
3
|
+
* 根据应用的id查询应用的gem
|
4
|
+
* 应用限于安卓应用和苹果应用
|
5
|
+
|
6
|
+
|
7
|
+
``
|
8
|
+
FetchApp.fetch_app('ios','**.**')
|
9
|
+
FetchApp.fetch_ios('**.**')
|
10
|
+
FetchApp.fetch_android('**')
|
11
|
+
``
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'fetch_app'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install fetch_app
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
One Gem To Fetch Android or IOS
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/fetch_app/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/fetch_app.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fetch_app/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fetch_app"
|
8
|
+
spec.version = FetchApp::VERSION
|
9
|
+
spec.authors = ["Will"]
|
10
|
+
spec.email = ["yh@fir.im"]
|
11
|
+
spec.summary = %q{one gem fetch app.}
|
12
|
+
spec.description = %q{one gem to fetch app.}
|
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
|
+
|
24
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.8.0', '>= 1.1.4'
|
25
|
+
end
|
data/lib/fetch_app.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require "fetch_app/version"
|
2
|
+
require 'rest-client'
|
3
|
+
require 'json'
|
4
|
+
module FetchApp
|
5
|
+
ANDROID_BASE_URL = 'http://www.wandoujia.com/apps/'
|
6
|
+
IOS_BASE_URL = 'http://itunes.apple.com/lookup?country=cn&'
|
7
|
+
# Your code goes here...
|
8
|
+
class << self
|
9
|
+
def fetch_app type,bundle_id
|
10
|
+
type ||= 'ios'
|
11
|
+
type = type.downcase
|
12
|
+
if type != 'ios' && type != 'android'
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
|
16
|
+
self.send("fetch_#{type}",bundle_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fetch_ios bundle_id=""
|
20
|
+
url = IOS_BASE_URL ;
|
21
|
+
|
22
|
+
if bundle_id.is_a?(Numeric)
|
23
|
+
bundle_id = bundle_id.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
return raise 'bundle_id is error' if !bundle_id || bundle_id.empty?
|
27
|
+
if /^[0-9]*$/.match(bundle_id)
|
28
|
+
url += 'id='
|
29
|
+
else
|
30
|
+
url += 'bundleId='
|
31
|
+
end
|
32
|
+
|
33
|
+
url += bundle_id
|
34
|
+
|
35
|
+
data = RestClient.get(url)
|
36
|
+
raise 'app info nil' if !data
|
37
|
+
|
38
|
+
body = data.body
|
39
|
+
|
40
|
+
begin
|
41
|
+
info = JSON.parse(body)
|
42
|
+
if info["resultCount"] == 1
|
43
|
+
info = info['results'][0]
|
44
|
+
|
45
|
+
if info["kind"] == 'software'
|
46
|
+
info_detail = {
|
47
|
+
name: info["trackName"],
|
48
|
+
app_id: info["bundleId"],
|
49
|
+
desc: info["description"],
|
50
|
+
link: info["trackViewUrl"],
|
51
|
+
icon: info["artworkUrl512"],
|
52
|
+
screens: info["screenshotUrls"],
|
53
|
+
version: info["version"],
|
54
|
+
track_id: info["trackId"],
|
55
|
+
gener: info["genres"][0]
|
56
|
+
}
|
57
|
+
return info_detail
|
58
|
+
else
|
59
|
+
raise 'app info nil'
|
60
|
+
end
|
61
|
+
else
|
62
|
+
raise 'app info nil'
|
63
|
+
end
|
64
|
+
rescue Exception => e
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch_android bundle_id
|
70
|
+
return raise 'bundle_id is error' if !bundle_id || bundle_id.empty?
|
71
|
+
url = ANDROID_BASE_URL+"#{bundle_id}?json"
|
72
|
+
data = RestClient.get(url)
|
73
|
+
return raise 'app info null' if !data
|
74
|
+
begin
|
75
|
+
info = JSON.parse(data.body)
|
76
|
+
puts 'info[:packageName]',info["packageName"]
|
77
|
+
if info && info["packageName"]
|
78
|
+
info_detail = {
|
79
|
+
name: info["app"]["title"],
|
80
|
+
app_id: info["packageName"],
|
81
|
+
version: info["app"]["latestApk"]["versionName"],
|
82
|
+
desc: info["app"]["description"].gsub("<br />","\n"),
|
83
|
+
link: info["app"]["latestApk"]["downloadUrl"]["referUrl"],
|
84
|
+
icon: info["app"]["icons"]["px256"] || info["app"]["icons"]["px100"],
|
85
|
+
screens: info["app"]["screenshots"]["normal"],
|
86
|
+
gener: info["app"]["categories"][0]["name"]
|
87
|
+
}
|
88
|
+
return info_detail
|
89
|
+
else
|
90
|
+
return raise 'app info null'
|
91
|
+
end
|
92
|
+
rescue Exception => e
|
93
|
+
raise e
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
data/sh.sh
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetch_app
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-23 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.8.0
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.1.4
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.8.0
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.1.4
|
61
|
+
description: one gem to fetch app.
|
62
|
+
email:
|
63
|
+
- yh@fir.im
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- fetch_app.gemspec
|
74
|
+
- lib/fetch_app.rb
|
75
|
+
- lib/fetch_app/version.rb
|
76
|
+
- sh.sh
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: one gem fetch app.
|
101
|
+
test_files: []
|