imeister 0.1.0
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 +10 -0
- data/.travis.yml +3 -0
- data/Gemfile +8 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/imeister.gemspec +23 -0
- data/lib/imeister.rb +18 -0
- data/lib/imeister/constants.rb +7 -0
- data/lib/imeister/version.rb +3 -0
- data/lib/imeister/warranty_status.rb +42 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0705f93892df055b5276d395c227eea200211290
|
4
|
+
data.tar.gz: 917a645cc413b119624b6cf4c55b9ed1dbeeb8c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 998ebe6416aaac45aec5f39d792f297b7a15f859bd94260ab6083874f29e50246a97fd29591e5495ac249e8d8464d5c8df6a6bcc6feb64b4facaa983ff015333
|
7
|
+
data.tar.gz: 22d27d251da578e0004c6a9f9512b152cf3e73274b113712dc4238c4b7d6f6409582e13ed0d87d2d582f93a901ecdcacda7a8e3ffac1c8bf5d0c18d2aed21171
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Imeister
|
2
|
+
|
3
|
+
Tiny gem for fetching information about Apple Phones' warranty by imei
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'imeister'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install imeister
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
```ruby
|
23
|
+
imeister = Imeister.find(VALID_IMEI)
|
24
|
+
#=> #<Imeister::WarrantyStatus:0x007fb627c18150 @expiration_date="May 18, 2099", @imei=VALID_IMEI, @warranty_status="In warranty">
|
25
|
+
```
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'imeister'
|
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
data/imeister.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 'imeister/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'imeister'
|
8
|
+
spec.version = Imeister::VERSION
|
9
|
+
spec.authors = ['Emil Shakirov']
|
10
|
+
spec.email = ['5o.smoker@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Tiny gem for fetching information about Apple Phones by imei'
|
13
|
+
spec.homepage = 'https://github.com/vaihtovirta/imeister'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = 'exe'
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
spec.add_development_dependency 'faraday', '~> 0.9.1'
|
23
|
+
end
|
data/lib/imeister.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'imeister/version'
|
2
|
+
require 'imeister/warranty_status'
|
3
|
+
|
4
|
+
module Imeister
|
5
|
+
class << self
|
6
|
+
def find(imei)
|
7
|
+
return 'Invalid IMEI number' unless imei_valid?(imei)
|
8
|
+
WarrantyStatus.new(imei)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def imei_valid?(imei)
|
14
|
+
return false if imei.nil?
|
15
|
+
imei.length > 0 && !imei.match(VALID_IMEI_REGEXP).nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module Imeister
|
2
|
+
WARRANTY_URL = 'https://selfsolve.apple.com'
|
3
|
+
RESULTS_URL = '/wcResults.do'
|
4
|
+
STATUS_REGEXP = /(?:warrantyPage\.warrantycheck\.displayHWSupportInfo\()((?:\w)+)/i
|
5
|
+
EXPIRATION_DATE_REGEXP = /(?:Estimated\ Expiration\ Date:\ )((?:[^<]*))/i
|
6
|
+
VALID_IMEI_REGEXP = /^\d{15}*$/
|
7
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require_relative 'constants'
|
3
|
+
|
4
|
+
module Imeister
|
5
|
+
class WarrantyStatus
|
6
|
+
attr_reader :warranty_status, :expiration_date
|
7
|
+
|
8
|
+
def initialize(imei = '')
|
9
|
+
@imei = imei
|
10
|
+
@warranty_status = nil
|
11
|
+
@expiration_date = nil
|
12
|
+
info
|
13
|
+
end
|
14
|
+
|
15
|
+
def info
|
16
|
+
if status == 'true'
|
17
|
+
@warranty_status = 'In warranty'
|
18
|
+
@expiration_date = response.body.match(EXPIRATION_DATE_REGEXP)[1]
|
19
|
+
else
|
20
|
+
@warranty_status = 'Out of warranty'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def status
|
27
|
+
response.body.match(STATUS_REGEXP)[1]
|
28
|
+
end
|
29
|
+
|
30
|
+
def connection
|
31
|
+
Faraday.new(url: WARRANTY_URL) do |faraday|
|
32
|
+
faraday.request :url_encoded
|
33
|
+
faraday.response :logger
|
34
|
+
faraday.adapter Faraday.default_adapter
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def response
|
39
|
+
connection.post RESULTS_URL, sn: @imei, num: rand(999_999)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: imeister
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emil Shakirov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-13 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
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.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.1
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- 5o.smoker@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- imeister.gemspec
|
70
|
+
- lib/imeister.rb
|
71
|
+
- lib/imeister/constants.rb
|
72
|
+
- lib/imeister/version.rb
|
73
|
+
- lib/imeister/warranty_status.rb
|
74
|
+
homepage: https://github.com/vaihtovirta/imeister
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.5
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Tiny gem for fetching information about Apple Phones by imei
|
97
|
+
test_files: []
|