device_map 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -11
- data/.rspec +2 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +0 -2
- data/LICENSE.txt +10 -19
- data/README.md +57 -0
- data/Rakefile +15 -0
- data/device_map.gemspec +25 -14
- data/ext/Rakefile +28 -0
- data/lib/device_map/classifier.rb +38 -0
- data/lib/device_map/device_data/builder.rb +67 -0
- data/lib/device_map/device_data/device.rb +52 -0
- data/lib/device_map/device_data/devices.rb +29 -0
- data/lib/device_map/device_data/patterns.rb +44 -0
- data/lib/device_map/keyword.rb +37 -0
- data/lib/device_map/pattern.rb +32 -0
- data/lib/device_map/properties/dsl.rb +48 -0
- data/lib/device_map/properties/property.rb +18 -0
- data/lib/device_map/properties/types.rb +27 -0
- data/lib/device_map/user_agent.rb +19 -0
- data/lib/device_map/version.rb +2 -1
- data/lib/device_map.rb +32 -2
- data/lib/resources/BuilderDataSource.xml +14992 -0
- data/lib/resources/DeviceDataSource.xml +44706 -0
- data/spec/classifier_spec.rb +44 -0
- data/spec/device_data/builder_spec.rb +65 -0
- data/spec/device_data/device_spec.rb +26 -0
- data/spec/device_data/devices_spec.rb +37 -0
- data/spec/device_data/patterns_spec.rb +52 -0
- data/spec/device_map_spec.rb +10 -0
- data/spec/keyword_spec.rb +32 -0
- data/spec/pattern_spec.rb +49 -0
- data/spec/properties/dsl_spec.rb +61 -0
- data/spec/user_agent_spec.rb +46 -0
- metadata +107 -8
data/lib/device_map.rb
CHANGED
@@ -1,5 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'nokogiri'
|
2
2
|
|
3
3
|
module DeviceMap
|
4
|
-
|
4
|
+
autoload :Classifier, 'device_map/classifier'
|
5
|
+
autoload :Keyword, 'device_map/keyword'
|
6
|
+
autoload :Pattern, 'device_map/pattern'
|
7
|
+
autoload :UserAgent, 'device_map/user_agent'
|
8
|
+
autoload :VERSION, 'device_map/version'
|
9
|
+
|
10
|
+
module DeviceData
|
11
|
+
autoload :Builder, 'device_map/device_data/builder'
|
12
|
+
autoload :Device, 'device_map/device_data/device'
|
13
|
+
autoload :Devices, 'device_map/device_data/devices'
|
14
|
+
autoload :Patterns, 'device_map/device_data/patterns'
|
15
|
+
end
|
16
|
+
|
17
|
+
module Properties
|
18
|
+
autoload :DSL, 'device_map/properties/dsl'
|
19
|
+
autoload :Property, 'device_map/properties/property'
|
20
|
+
autoload :Types, 'device_map/properties/types'
|
21
|
+
end
|
22
|
+
|
23
|
+
RESOURCES_PATH = File.expand_path('resources', __dir__)
|
24
|
+
|
25
|
+
BUILDER_DATA_SOURCE = File.join(RESOURCES_PATH, 'BuilderDataSource.xml')
|
26
|
+
DEVICE_DATA_SOURCE = File.join(RESOURCES_PATH, 'DeviceDataSource.xml')
|
27
|
+
|
28
|
+
PATTERNS_DUMP = File.join(RESOURCES_PATH, 'patterns')
|
29
|
+
DEVICES_DUMP = File.join(RESOURCES_PATH, 'devices')
|
30
|
+
|
31
|
+
def self.classify(user_agent)
|
32
|
+
classifier = Classifier.instance
|
33
|
+
classifier.find_device(user_agent)
|
34
|
+
end
|
5
35
|
end
|