deviceatlasapi 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -36,7 +36,7 @@ Add the following line in the file "app/controllers/application.rb"
36
36
  include DeviceAtlasApi::ControllerHelpers
37
37
 
38
38
  def index
39
- @device_info = get_device_info
39
+ @device_info = get_device_data
40
40
  end
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module DeviceAtlasApi
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -19,12 +19,26 @@ module DeviceAtlasApi
19
19
  def initialize request
20
20
  @user_agent = request.env['HTTP_USER_AGENT']
21
21
  @headers = prepare_headers request
22
+
23
+ if is_cookie_set?(request)
24
+ @headers['X-DA-Client-Properties'] = get_client_properties request
25
+ end
26
+
22
27
  @cloud_host = 'api.deviceatlascloud.com'
28
+ @cookie_name = 'DAPROPS'
23
29
  end
24
30
 
25
31
  def get_device_data
26
32
  url = prepare_url
27
- HTTParty.get(url, @headers)["properties"]
33
+ HTTParty.get(url, :headers => @headers)["properties"]
34
+ end
35
+
36
+ def is_cookie_set? request
37
+ request.cookies[@cookie_name].nil?
38
+ end
39
+
40
+ def get_client_properties request
41
+ request.cookies['DAPROPS'].gsub /^"|"$/, ''
28
42
  end
29
43
 
30
44
  private
@@ -43,7 +57,8 @@ module DeviceAtlasApi
43
57
  'HTTP_X_BOLT_PHONE_UA' => request.env['HTTP_X_BOLT_PHONE_UA'],
44
58
  'HTTP_DEVICE_STOCK_UA' => request.env['HTTP_DEVICE_STOCK_UA'],
45
59
  'HTTP_X_UCBROWSER_DEVICE_UA' => request.env['HTTP_X_UCBROWSER_DEVICE_UA'],
46
- }
60
+ 'X-DA-Version' => 'java/1.2_2'
61
+ }.reject!{|k,v| v.nil?}
47
62
  end
48
63
 
49
64
  def prepare_url
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deviceatlasapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Trevor Kimenye
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-07-16 00:00:00.000000000 Z
12
+ date: 2013-08-26 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: httparty
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -55,6 +62,7 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: railties
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
67
  - - ~>
60
68
  - !ruby/object:Gem::Version
@@ -62,6 +70,7 @@ dependencies:
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
75
  - - ~>
67
76
  - !ruby/object:Gem::Version
@@ -83,26 +92,26 @@ files:
83
92
  homepage: https://github.com/kimenye/deviceatlasapi
84
93
  licenses:
85
94
  - MIT
86
- metadata: {}
87
95
  post_install_message:
88
96
  rdoc_options: []
89
97
  require_paths:
90
98
  - lib
91
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
92
101
  requirements:
93
102
  - - ! '>='
94
103
  - !ruby/object:Gem::Version
95
104
  version: '0'
96
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
+ none: false
97
107
  requirements:
98
108
  - - ! '>='
99
109
  - !ruby/object:Gem::Version
100
110
  version: '0'
101
111
  requirements: []
102
112
  rubyforge_project:
103
- rubygems_version: 2.0.3
113
+ rubygems_version: 1.8.25
104
114
  signing_key:
105
- specification_version: 4
115
+ specification_version: 3
106
116
  summary: Ruby gem to access DeviceAtlas cloud api
107
117
  test_files: []
108
- has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzhiZTMzNmQxZDI2NTNkNzRhOWJkYWUzNDViZjA3NjRkNDNkNjU0MA==
5
- data.tar.gz: !binary |-
6
- NWYxZGI5OWFiODI3YjBjYTUxNzYxNTk2N2Y4YjBjYWE2NjBkYWZmZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YmVlNjc5MjQ5YzcyMmM2ZTgzZjhhYTZkNTMyNzIwMWQxYTZmYThmNTJjYjY1
10
- ZTgxMTNlY2I2MzE1YTA3NGYwZWUwM2U2MzZiZWU2ODhkZjJlMDI0MzU5NzBj
11
- ZGFhNGY2YWYxOWNmMWE4NDcyNjMzNTU4YzBmZDUyZjRmNzZkYjQ=
12
- data.tar.gz: !binary |-
13
- MjBiY2JiZDk2MjhiNjYwYWIxOTA3MTBkZjIzNzY1YTg4MWUwNDZiOTRmYTNj
14
- Yzg0ZmQ1OGRmMDIyOTVkZDdkZjE0M2ExMzFmZGJiMDBlOWZkOGE3YWI1YWI3
15
- MzIzNjgxOGI3Y2IwMDAwZTY2MjNjYmU0MzFlZGI4OTc3MDlmMTk=