phone_sites 0.0.4

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: 17b512ca7432eceb6cddd1ceb618d4d48286ee80
4
+ data.tar.gz: 42aeb31271a225c724aee16317cc1b50c2d3ba6c
5
+ SHA512:
6
+ metadata.gz: f43af80ed9a3053a1c11e8d19bef89360a0eebeae8cb7f232db3a7d130efb7392ee644e560aa65ef2b075b88dfcaf642c9d5e731ed521d817fbe7daa8a85da11
7
+ data.tar.gz: 3c27ae22440f8abdaa73b477ec39b5132cd12a94a86c3ff486bec843b1bbe0729e420fcf3c9c6cb25a50b13649168d6ddda47b8264178d1f6860348c28605e89
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
11
+ *.iml
12
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,229 @@
1
+ # require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - bin/**
7
+ - db/migrate/**/*
8
+ - rails
9
+ - config.ru
10
+ - Guardfile
11
+ - Rakefile
12
+ - spec.old/**/*
13
+ - lib/tasks/**
14
+ - lib/game_pay/**/*
15
+ - lib/active_job/**
16
+ - daemons/daemons
17
+ - daemons/que_daemon_ctl
18
+ - daemons/setup.rb
19
+ - config/unicorn/**
20
+ - config/initializers/**
21
+ - config/environments/**
22
+ - config/boot.rb
23
+ - config/environment.rb
24
+ - vendor/crm/crm.gemspec
25
+ - vendor/crm/bin/**
26
+ - vendor/crm/test/**/*
27
+ - Gemfile
28
+ Rails:
29
+ Enabled: true
30
+
31
+ Documentation:
32
+ Enabled: false
33
+
34
+ SpaceBeforeFirstArg:
35
+ Enabled: false
36
+
37
+ # Single Quotes
38
+ StringLiterals:
39
+ Enabled: false
40
+
41
+ Metrics/ClassLength:
42
+ Enabled: false
43
+
44
+ Metrics/AbcSize:
45
+ Enabled: false
46
+
47
+ Metrics/MethodLength:
48
+ Max: 20
49
+ Exclude:
50
+ - db/**/*
51
+ - apps/assets/javascripts/**/*
52
+
53
+ Metrics/LineLength:
54
+ Max: 100
55
+ Exclude:
56
+ - spec/**/*
57
+ - db/**/*
58
+ - config/deploy/**/*
59
+ - config/initializers/*
60
+ - config/environments/*
61
+
62
+ Metrics/PerceivedComplexity:
63
+ Enabled: false
64
+
65
+ Metrics/CyclomaticComplexity:
66
+ Enabled: false
67
+
68
+ Metrics/ParameterLists:
69
+ Exclude:
70
+
71
+ Lint/AmbiguousOperator:
72
+ Enabled: false
73
+
74
+ Lint/Void:
75
+ Exclude:
76
+
77
+ Lint/HandleExceptions:
78
+ Enabled: false
79
+
80
+ Lint/RescueException:
81
+ Exclude:
82
+
83
+ Lint/UnusedBlockArgument:
84
+ Enabled: true
85
+
86
+ Lint/AssignmentInCondition:
87
+ Enabled: false
88
+
89
+ Lint/Eval:
90
+ Exclude:
91
+
92
+ Lint/ShadowingOuterLocalVariable:
93
+ Exclude:
94
+
95
+ Style/AlignParameters:
96
+ Enabled: false
97
+
98
+ Style/MultilineOperationIndentation:
99
+ Enabled: false
100
+
101
+ Style/Encoding:
102
+ Enabled: false
103
+
104
+ Style/ClassAndModuleChildren:
105
+ Enabled: false #Breaks rails loader
106
+
107
+ Style/PercentLiteralDelimiters:
108
+ PreferredDelimiters:
109
+ '%i': '[]'
110
+ '%r': '{}'
111
+ '%w': '[]'
112
+ '%W': '[]'
113
+
114
+ Style/NumericLiterals:
115
+ Enabled: false
116
+
117
+ Style/RegexpLiteral:
118
+ Enabled: false
119
+
120
+ Style/AccessorMethodName:
121
+ Enabled: false # Not disabling now
122
+
123
+ Style/AlignArray:
124
+ Exclude:
125
+
126
+ Style/AsciiComments: #А почему бы и нет?
127
+ Enabled: false
128
+
129
+ Style/CommentAnnotation:
130
+ Enabled: false
131
+
132
+ Style/IfUnlessModifier:
133
+ Enabled: false
134
+
135
+ Style/RescueModifier:
136
+ Enabled: false
137
+
138
+ Style/AndOr:
139
+ Enabled: false #Does not make much sense
140
+
141
+ Style/DoubleNegation:
142
+ Enabled: false #Avoid the use of double negation (!!)
143
+
144
+ Style/TrivialAccessors:
145
+ AllowPredicates: true
146
+
147
+ Style/PredicateName:
148
+ Exclude:
149
+
150
+ Style/GlobalVars:
151
+ Exclude:
152
+
153
+ Style/ClassVars:
154
+ Exclude:
155
+
156
+ Style/MethodName:
157
+ Enabled: false
158
+
159
+ Rails/HasAndBelongsToMany:
160
+ Enabled: false # C: Prefer has_many :through to has_and_belongs_to_many.
161
+
162
+ Rails/Validation:
163
+ Enabled: false # Prefer the new style validations validates :column, presence: value over validates_presence_of
164
+
165
+ Rails/Output:
166
+ Exclude:
167
+
168
+ Rails/OutputSafety:
169
+ Enabled: false
170
+
171
+ Rails/Exit:
172
+ Enabled: false
173
+
174
+ Style/SignalException:
175
+ EnforcedStyle: only_raise
176
+
177
+ Style/SymbolArray:
178
+ Enabled: true # Disabled by default
179
+ Exclude:
180
+ # - config/routes.rb # a lot
181
+ - db/migrate/**/* # just a lot of fails
182
+
183
+ Style/AlignHash:
184
+ Exclude:
185
+
186
+ Style/TrailingCommaInLiteral:
187
+ EnforcedStyleForMultiline: comma
188
+ Exclude:
189
+ - apps/**/assets/javascripts/**/*
190
+
191
+ Style/LineEndConcatenation:
192
+ Exclude:
193
+ - apps/assets/javascripts/**/*
194
+
195
+ Style/ModuleFunction:
196
+ Enabled: false
197
+
198
+ Style/HashSyntax:
199
+ Exclude:
200
+
201
+ Style/EmptyLinesAroundClassBody:
202
+ Enabled: false
203
+
204
+ Style/EmptyLinesAroundModuleBody:
205
+ Enabled: false
206
+
207
+ Style/EmptyLinesAroundBlockBody:
208
+ Enabled: false
209
+
210
+ Rails/Delegate:
211
+ Exclude:
212
+
213
+ Style/GuardClause:
214
+ Enabled: false
215
+
216
+ Style/SpaceInsideBrackets:
217
+ Enabled: false
218
+
219
+ Style/AlignParameters:
220
+ Enabled: false
221
+
222
+ Style/MultilineOperationIndentation:
223
+ Enabled: false
224
+
225
+ Style/SingleLineBlockParams:
226
+ Enabled: false
227
+
228
+ Style/StringLiteralsInInterpolation:
229
+ Enabled: false
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at gophan1992@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in PhoneSites.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Igor Pavlov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ # coding: utf-8
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'phone_sites/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "phone_sites"
9
+ spec.version = PhoneSites::VERSION
10
+ spec.authors = ["Igor Pavlov"]
11
+ spec.email = ["gophan1992@gmail.com"]
12
+
13
+ spec.summary = "Gem for web-scraping data for phone sites"
14
+ spec.description = "Description"
15
+ spec.homepage = "http://bitbucket.org/BEaStia/phone_sites/"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ #if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "http://rubygems.org"
22
+ #else
23
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
24
+ #end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.12"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_runtime_dependency "faraday", "~> 0.9.2"
36
+ spec.add_development_dependency "minitest", "~>5.9.0", ">= 5.9.0"
37
+ spec.add_runtime_dependency "nokogiri", "~>1.6.8", ">= 1.6.8"
38
+ spec.add_development_dependency "rubocop", '~> 0'
39
+ spec.add_runtime_dependency "memoist", '~> 0'
40
+ end
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # PhoneSites
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/phone_sites`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'phone_sites'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install phone_sites
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/untitled7. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "phone_sites"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ class Base
4
+ def initialize(data)
5
+ parseable_fields.each do |name|
6
+ public_send("#{name}=", parse(data, name))
7
+ end
8
+ end
9
+
10
+ def parse(_, _)
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def self.parseable_attributes(*names)
15
+ names.each { |name| attr_accessor name }
16
+ define_method("parseable_fields") { names }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ class BaseResponse
4
+ def perform(url, method = 'get', options = {})
5
+ Faraday.public_send(method, url, options)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ module GsmArena
4
+ class Connection
5
+ def self.get_manufacturers
6
+ Manufacturer.all
7
+ end
8
+
9
+ def self.get_models(manufacturer)
10
+ manufacturer.models
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ require 'uri'
3
+ module PhoneSites
4
+ module GsmArena
5
+ class Manufacturer < PhoneSites::Manufacturer
6
+
7
+ def parse(data, attr_name)
8
+ case attr_name
9
+ when :name
10
+ data.children.select { |x| x.is_a?(Nokogiri::XML::Text) }.first.text
11
+ when :url
12
+ data.get_attribute("href")
13
+ when :count
14
+ data.children.select { |x| x.is_a?(Nokogiri::XML::Element) && x.name == "span" }
15
+ .first.children.first.text.split(" ").first.to_i
16
+ else
17
+ raise NotImplementedError
18
+ end
19
+ end
20
+
21
+ def models
22
+ pages_count.times.inject([]) do |sum, i|
23
+ sum.concat(self.class.models_response.perform(self, build_url(i)))
24
+ end
25
+ end
26
+
27
+ def pages_count
28
+ (count.to_f / PhoneSites::GsmArena::PhoneModel::ITEMS_PER_PAGE).ceil
29
+ end
30
+
31
+ def build_url(page)
32
+ url_end = page.zero? ? url : url.gsub(".php", "-#{page}.php")
33
+ URI.join(self.class.base_url, url_end).to_s
34
+ end
35
+
36
+ def self.manufacturer_response
37
+ GsmArena::ManufacturersListResponse.new
38
+ end
39
+
40
+ def self.models_response
41
+ PhoneSites::GsmArena::ModelListResponse.new
42
+ end
43
+
44
+ def self.manufacturers_url
45
+ ::URI.join(GsmArena::BASE_URL, GsmArena::MANUFACTURERS_URL).to_s
46
+ end
47
+
48
+ def self.base_url
49
+ GsmArena::BASE_URL
50
+ end
51
+
52
+ def self.all
53
+ url = manufacturers_url
54
+ manufacturer_response.perform(url)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ module GsmArena
4
+ class ManufacturersListResponse < ::PhoneSites::BaseResponse
5
+ def perform(url, method = 'get', options = {})
6
+ response = super(url, method, options)
7
+ Nokogiri::HTML(response.body).css('table a').map do |elem|
8
+ Manufacturer.new(elem)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ module GsmArena
4
+ class ModelInfoResponse < ::PhoneSites::BaseResponse
5
+ def perform(url, method = 'get', options = {})
6
+ response = super(url, method, options)
7
+ body = Nokogiri::HTML(response.body)
8
+ body.css('#specs-list table tr td')
9
+ .map(&:text)
10
+ .each_slice(2)
11
+ .each_with_object({}) do |(key, value), hash|
12
+ properties = normalize_property(key, value)
13
+ hash.merge!(properties) if valid?(key)
14
+ end
15
+ end
16
+
17
+ private
18
+ def normalize_property_value(value)
19
+ val = value.tr("\r\n ", '').strip
20
+ case val
21
+ when "Yes"
22
+ true
23
+ when "No"
24
+ false
25
+ when "-"
26
+ nil
27
+ else
28
+ val
29
+ end
30
+ end
31
+
32
+ def normalize_property(key, value)
33
+ { key.strip => normalize_property_value(value) }
34
+ end
35
+
36
+ def valid?(key)
37
+ key.length != 1
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ module GsmArena
4
+ class ModelListResponse < ::PhoneSites::BaseResponse
5
+ def perform(manufacturer, url, method = 'get', options = {})
6
+ response = super(url, method, options)
7
+ Nokogiri::HTML(response.body).css('.makers li a').map do |elem|
8
+ PhoneSites::GsmArena::PhoneModel.new(elem, manufacturer)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ require 'memoist'
3
+
4
+ module PhoneSites
5
+ module GsmArena
6
+ class PhoneModel < PhoneSites::PhoneModel
7
+ extend ::Memoist
8
+
9
+ ITEMS_PER_PAGE = 40
10
+
11
+ def parse(data, attr_name)
12
+ case attr_name
13
+ when :name
14
+ data.children.last.text
15
+ when :url
16
+ data.attribute("href").text
17
+ when :picture_url
18
+ data.css("img").attribute("src").text
19
+ when :description
20
+ data.css("img").attribute("title").text
21
+ else
22
+ raise NotImplementedError
23
+ end
24
+ end
25
+
26
+ def info
27
+ ModelInfoResponse.new.perform(URI.join(PhoneSites::GsmArena::BASE_URL, url).to_s)
28
+ end
29
+
30
+ memoize :info
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require 'faraday'
3
+ require 'nokogiri'
4
+ require 'phone_sites'
5
+ require_relative '../phone_sites/gsm_arena/manufacturers_list_response'
6
+ require_relative '../phone_sites/gsm_arena/connection'
7
+ require_relative '../phone_sites/gsm_arena/manufacturer'
8
+ require_relative '../phone_sites/gsm_arena/phone_model'
9
+ require_relative '../phone_sites/gsm_arena/model_list_response'
10
+ require_relative '../phone_sites/gsm_arena/model_info_response'
11
+ module PhoneSites
12
+ module GsmArena
13
+ BASE_URL = 'http://www.gsmarena.com/'
14
+ MANUFACTURERS_URL = 'makers.php3'
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ class Manufacturer < Base
4
+ parseable_attributes :name, :url, :count
5
+
6
+ def models
7
+ raise NotImplementedError
8
+ end
9
+
10
+ def self.manufacturers_url
11
+ raise NotImplementedError
12
+ end
13
+
14
+ def self.base_url
15
+ raise NotImplementedError
16
+ end
17
+
18
+ def self.all
19
+ raise NotImplementedError
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ class PhoneModel < Base
4
+
5
+ parseable_attributes :name, :url, :picture_url, :description
6
+ attr_accessor :manufacturer
7
+
8
+ def initialize(data, manufacturer)
9
+ self.manufacturer = manufacturer
10
+ super(data)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module PhoneSites
3
+ VERSION = "0.0.4"
4
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require "phone_sites/version"
3
+ require 'faraday'
4
+ require 'nokogiri'
5
+ require 'phone_sites/base'
6
+ require 'phone_sites/manufacturer'
7
+ require 'phone_sites/base_response'
8
+ require 'phone_sites/phone_model'
9
+ require 'phone_sites/gsm_arena'
10
+
11
+ module PhoneSites
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phone_sites
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Igor Pavlov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-04 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.9.0
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 5.9.0
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: 5.9.0
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 5.9.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: nokogiri
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.6.8
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.6.8
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: 1.6.8
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.6.8
95
+ - !ruby/object:Gem::Dependency
96
+ name: rubocop
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: memoist
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ description: Description
124
+ email:
125
+ - gophan1992@gmail.com
126
+ executables: []
127
+ extensions: []
128
+ extra_rdoc_files: []
129
+ files:
130
+ - ".DS_Store"
131
+ - ".gitignore"
132
+ - ".rubocop.yml"
133
+ - CODE_OF_CONDUCT.md
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - PhoneSites.gemspec
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - lib/phone_sites.rb
142
+ - lib/phone_sites/base.rb
143
+ - lib/phone_sites/base_response.rb
144
+ - lib/phone_sites/gsm_arena.rb
145
+ - lib/phone_sites/gsm_arena/connection.rb
146
+ - lib/phone_sites/gsm_arena/manufacturer.rb
147
+ - lib/phone_sites/gsm_arena/manufacturers_list_response.rb
148
+ - lib/phone_sites/gsm_arena/model_info_response.rb
149
+ - lib/phone_sites/gsm_arena/model_list_response.rb
150
+ - lib/phone_sites/gsm_arena/phone_model.rb
151
+ - lib/phone_sites/manufacturer.rb
152
+ - lib/phone_sites/phone_model.rb
153
+ - lib/phone_sites/version.rb
154
+ homepage: http://bitbucket.org/BEaStia/phone_sites/
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.5.1
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Gem for web-scraping data for phone sites
178
+ test_files: []