ios-devices 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/ios-devices.gemspec +28 -0
- data/lib/ios/devices.rb +100 -0
- data/lib/ios/devices/model.rb +15 -0
- data/lib/ios/devices/version.rb +5 -0
- data/spec/ios_devices_spec.rb +24 -0
- data/spec/spec_helper.rb +6 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e04fbdf8191acd8089c049ccc014ddd9498036f5
|
4
|
+
data.tar.gz: d803901f620d619c8ec0e8baea2584b312eecf52
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c2c567db2026a50eaf92261140e8d6d2fd33a9efa225efa4800eca4a5231df477ad20afcd02774b221702581a10123f53f4508a4196c0350782ff044e50b951b
|
7
|
+
data.tar.gz: 2f5bec7a6c20e8bc191c577894a4ea4b98d1fe244fc10491d06542d973bbc9243c0367924290b7e7e4cc45c7c0fff59f284d21e779df78c7b3d3e65a3dbe527b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ios-devices
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ricardo Otero
|
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,44 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/rikas/iosdevices.svg)](https://travis-ci.org/rikas/iosdevices)
|
2
|
+
|
3
|
+
# Ios::Devices
|
4
|
+
|
5
|
+
This is a little Gem used to translate Apple iOS device types (like "iPhone6,1") to proper device
|
6
|
+
names that you can use.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'ios-devices'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install ios-devices
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Just use the `Ios::Devices.search` method with the Apple string and you should get a
|
27
|
+
`Ios::Devices::Model` object. This object has an `extra` attribute for things like internet
|
28
|
+
connection, revision model, etc.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Ios::Devices.search('iPhone6,1')
|
32
|
+
=> #<Ios::Devices::Model:0x007fa55ba1a948 @extra=nil, @name="iPhone 5s", @device_type="iPhone6,1">
|
33
|
+
|
34
|
+
Ios::Devices.search('iPad2,2')
|
35
|
+
=> #<Ios::Devices::Model:0x007fa55b957308 @extra="GSM", @name="iPad 2", @device_type="iPad2,2">
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/rikas/ios-devices/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/ios-devices.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'ios/devices'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'ios-devices'
|
10
|
+
spec.version = Ios::Devices::VERSION
|
11
|
+
spec.authors = ['Ricardo Otero']
|
12
|
+
spec.email = ['oterosantos@gmail.com']
|
13
|
+
spec.summary = %q{iOS device model translation from Apple device types.}
|
14
|
+
spec.description = %q{With this gem you can read the device type that every iOS device can send
|
15
|
+
and translate it to a proper model name.}
|
16
|
+
spec.homepage = 'http://github.com/rikas/ios-devices'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0")
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'rspec'
|
28
|
+
end
|
data/lib/ios/devices.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'ios/devices/version'
|
2
|
+
require 'ios/devices/model'
|
3
|
+
|
4
|
+
module Ios
|
5
|
+
module Devices
|
6
|
+
# Gets the official device for the given device type from the iOS devices.
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
#
|
10
|
+
# Ios::Devices.search('iPhone6,1')
|
11
|
+
# => #<Ios::Devices::Model:0x007fa55ba1a948 @extra=nil, @name="iPhone 5s", @name="iPhone6,1">
|
12
|
+
#
|
13
|
+
# Ios::Devices.search('iPad2,2')
|
14
|
+
# => #<Ios::Devices::Model:0x007fa55b957308 @extra="GSM", @name="iPad 2", @name="iPad2,2">
|
15
|
+
def self.search(device_type)
|
16
|
+
# This list was taken from here:
|
17
|
+
# http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/ios-device-types
|
18
|
+
case device_type
|
19
|
+
when 'iPhone1,1'
|
20
|
+
Model.new(device_type, 'iPhone')
|
21
|
+
when 'iPhone1,2'
|
22
|
+
Model.new(device_type, 'iPhone 3G')
|
23
|
+
when 'iPhone2,1'
|
24
|
+
Model.new(device_type, 'iPhone 3GS')
|
25
|
+
when 'iPhone3,1'
|
26
|
+
Model.new(device_type, 'iPhone 4', 'GSM')
|
27
|
+
when 'iPhone3,3'
|
28
|
+
Model.new(device_type, 'iPhone 4', 'CDMA')
|
29
|
+
when 'iPhone4,1'
|
30
|
+
Model.new(device_type, 'iPhone 4S')
|
31
|
+
when 'iPhone5,1', 'iPhone5,2'
|
32
|
+
Model.new(device_type, 'iPhone 5')
|
33
|
+
when 'iPhone5,3', 'iPhone5,4'
|
34
|
+
Model.new(device_type, 'iPhone 5c')
|
35
|
+
when 'iPhone6,1', 'iPhone6,2'
|
36
|
+
Model.new(device_type, 'iPhone 5s')
|
37
|
+
when 'iPhone7,1'
|
38
|
+
Model.new(device_type, 'iPhone 6 Plus')
|
39
|
+
when 'iPhone7,2'
|
40
|
+
Model.new(device_type, 'iPhone 6')
|
41
|
+
when 'iPad1,1'
|
42
|
+
Model.new(device_type, 'iPad')
|
43
|
+
when 'iPad2,1'
|
44
|
+
Model.new(device_type, 'iPad 2', 'Wi-Fi')
|
45
|
+
when 'iPad2,2'
|
46
|
+
Model.new(device_type, 'iPad 2', 'GSM')
|
47
|
+
when 'iPad2,3'
|
48
|
+
Model.new(device_type, 'iPad 2', 'CDMA')
|
49
|
+
when 'iPad2,4'
|
50
|
+
Model.new(device_type, 'iPad 2', 'Wi-Fi, revised')
|
51
|
+
when 'iPad2,5'
|
52
|
+
Model.new(device_type, 'iPad mini', 'Wi-Fi')
|
53
|
+
when 'iPad2,6', 'iPad2,7'
|
54
|
+
Model.new(device_type, 'iPad mini')
|
55
|
+
when 'iPad3,1'
|
56
|
+
Model.new(device_type, 'iPad', '3rd gen, Wi-Fi')
|
57
|
+
when 'iPad3,2'
|
58
|
+
Model.new(device_type, 'iPad', '3rd gen, Wi-Fi+LTE Verizon')
|
59
|
+
when 'iPad3,3'
|
60
|
+
Model.new(device_type, 'iPad', '3rd gen, Wi-Fi+LTE AT&T')
|
61
|
+
when 'iPad3,4'
|
62
|
+
Model.new(device_type, 'iPad', '4th gen, Wi-Fi')
|
63
|
+
when 'iPad3,5', 'iPad3,6'
|
64
|
+
Model.new(device_type, 'iPad', '4th gen')
|
65
|
+
when 'iPad4,1'
|
66
|
+
Model.new(device_type, 'iPad Air', 'Wi-Fi')
|
67
|
+
when 'iPad4,2'
|
68
|
+
Model.new(device_type, 'iPad Air', 'Wi-Fi+LTE')
|
69
|
+
when 'iPad4,3'
|
70
|
+
Model.new(device_type, 'iPad Air', 'Rev')
|
71
|
+
when 'iPad4,4'
|
72
|
+
Model.new(device_type, 'iPad mini 2', 'Wi-Fi')
|
73
|
+
when 'iPad4,5'
|
74
|
+
Model.new(device_type, 'iPad mini 2', 'Wi-Fi+LTE')
|
75
|
+
when 'iPad4,6'
|
76
|
+
Model.new(device_type, 'iPad mini 2', 'Rev')
|
77
|
+
when 'iPad4,7'
|
78
|
+
Model.new(device_type, 'iPad mini 3', 'Wi-Fi')
|
79
|
+
when 'iPad4,8', 'iPad4,9'
|
80
|
+
Model.new(device_type, 'iPad mini 3')
|
81
|
+
when 'iPad5,3'
|
82
|
+
Model.new(device_type, 'iPad Air 2', 'Wi-Fi')
|
83
|
+
when 'iPad5,4'
|
84
|
+
Model.new(device_type, 'iPad Air 2', 'Wi-Fi+LTE')
|
85
|
+
when 'iPod1,1'
|
86
|
+
Model.new(device_type, 'iPod touch')
|
87
|
+
when 'iPod2,1'
|
88
|
+
Model.new(device_type, 'iPod touch', '2nd gen')
|
89
|
+
when 'iPod3,1'
|
90
|
+
Model.new(device_type, 'iPod touch', '3rd gen')
|
91
|
+
when 'iPod4,1'
|
92
|
+
Model.new(device_type, 'iPod touch', '4th gen')
|
93
|
+
when 'iPod5,1'
|
94
|
+
Model.new(device_type, 'iPod touch', '5th gen')
|
95
|
+
else
|
96
|
+
Model.new(device_type, 'Unknown iOS device')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ios
|
2
|
+
module Devices
|
3
|
+
# Represents an iOS device model. Every device has a type and name and some of them also have
|
4
|
+
# extra information (Revision, Wi-fi, etc.)
|
5
|
+
class Model
|
6
|
+
attr_accessor :device_type, :name, :extra
|
7
|
+
|
8
|
+
def initialize(device_type, name, extra = nil)
|
9
|
+
@device_type = device_type
|
10
|
+
@name = name
|
11
|
+
@extra = extra
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Ios::Devices do
|
4
|
+
describe '.search' do
|
5
|
+
it 'returns a model object' do
|
6
|
+
model = Ios::Devices.search('iPhone6,2')
|
7
|
+
|
8
|
+
expect(model).to be_a(Ios::Devices::Model)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns the correct model' do
|
12
|
+
model = Ios::Devices.search('iPad4,3')
|
13
|
+
|
14
|
+
expect(model.name).to eq('iPad Air')
|
15
|
+
expect(model.extra).to eq('Rev')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns a model object with "Unknown iOS device" for unknown device types' do
|
19
|
+
model = Ios::Devices.search('iPad8,9')
|
20
|
+
|
21
|
+
expect(model.name).to eq('Unknown iOS device')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ios-devices
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ricardo Otero
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-06 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: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
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: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: |-
|
70
|
+
With this gem you can read the device type that every iOS device can send
|
71
|
+
and translate it to a proper model name.
|
72
|
+
email:
|
73
|
+
- oterosantos@gmail.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".ruby-gemset"
|
81
|
+
- ".ruby-version"
|
82
|
+
- ".travis.yml"
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- ios-devices.gemspec
|
88
|
+
- lib/ios/devices.rb
|
89
|
+
- lib/ios/devices/model.rb
|
90
|
+
- lib/ios/devices/version.rb
|
91
|
+
- spec/ios_devices_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
homepage: http://github.com/rikas/ios-devices
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.2.2
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: iOS device model translation from Apple device types.
|
117
|
+
test_files:
|
118
|
+
- spec/ios_devices_spec.rb
|
119
|
+
- spec/spec_helper.rb
|