wurfl-lite 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2
data/lib/wurfl-lite.rb CHANGED
@@ -30,6 +30,7 @@ class WURFL
30
30
 
31
31
  def clear!
32
32
  @devices = Hash.new
33
+ @devices_cached = Hash.new
33
34
  @devices_by_id = {}
34
35
  @files = []
35
36
  end
@@ -83,9 +84,13 @@ class WURFL
83
84
  end
84
85
 
85
86
  def []( user_agent )
87
+ if @devices_cached.has_key?( user_agent )
88
+ return @devices_cached[ user_agent ]
89
+ end
86
90
  device = @devices[ user_agent ]
87
91
  if device
88
92
  device[ :wurfl_match ] = { :distance => 0, :distance_normalized => 0 }
93
+ @devices_cached[ user_agent ] = device
89
94
  return device
90
95
  end
91
96
  match = Amatch::Sellers.new( user_agent )
@@ -100,15 +105,16 @@ class WURFL
100
105
  distance = sorted_list.first.last
101
106
  distance_normalised = distance/(user_agent.length+1)
102
107
 
103
- if distance_normalised > @match_threshold
104
- nil
105
- else
106
- device[ :wurfl_match ] = {
107
- :distance => distance,
108
- :distance_normalised => distance_normalised
109
- }
110
- @devices[ user_agent ] = device
111
- end
108
+ @devices_cached[ user_agent ] =
109
+ if distance_normalised > @match_threshold
110
+ nil
111
+ else
112
+ device[ :wurfl_match ] = {
113
+ :distance => distance,
114
+ :distance_normalised => distance_normalised
115
+ }
116
+ @devices[ user_agent ] = device
117
+ end
112
118
  end
113
119
 
114
120
  end
@@ -1,3 +1,3 @@
1
1
  class WURFL
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,138 +1,99 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wurfl-lite
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 1
8
- - 2
9
- version: 1.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Clive Crous
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-12-26 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: hpricot
22
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &74871410 !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 8
30
- - 2
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
31
21
  version: 0.8.2
32
- - - "!="
33
- - !ruby/object:Gem::Version
34
- segments:
35
- - 0
36
- - 8
37
- - 3
22
+ - - ! '!='
23
+ - !ruby/object:Gem::Version
38
24
  version: 0.8.3
39
25
  type: :runtime
40
26
  prerelease: false
41
- version_requirements: *id001
42
- - !ruby/object:Gem::Dependency
27
+ version_requirements: *74871410
28
+ - !ruby/object:Gem::Dependency
43
29
  name: amatch
44
- requirement: &id002 !ruby/object:Gem::Requirement
30
+ requirement: &74871030 !ruby/object:Gem::Requirement
45
31
  none: false
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- segments:
50
- - 0
51
- - 2
52
- - 5
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
53
35
  version: 0.2.5
54
36
  type: :runtime
55
37
  prerelease: false
56
- version_requirements: *id002
57
- - !ruby/object:Gem::Dependency
38
+ version_requirements: *74871030
39
+ - !ruby/object:Gem::Dependency
58
40
  name: bundler
59
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ requirement: &74870800 !ruby/object:Gem::Requirement
60
42
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- segments:
65
- - 1
66
- - 0
67
- - 0
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
68
46
  version: 1.0.0
69
47
  type: :development
70
48
  prerelease: false
71
- version_requirements: *id003
72
- - !ruby/object:Gem::Dependency
49
+ version_requirements: *74870800
50
+ - !ruby/object:Gem::Dependency
73
51
  name: rake
74
- requirement: &id004 !ruby/object:Gem::Requirement
52
+ requirement: &74870570 !ruby/object:Gem::Requirement
75
53
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
- - 8
82
- - 7
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
83
57
  version: 0.8.7
84
58
  type: :development
85
59
  prerelease: false
86
- version_requirements: *id004
60
+ version_requirements: *74870570
87
61
  description: Simple Ruby usage of the WURFL device capabilities and features database
88
- email:
62
+ email:
89
63
  - clive@crous.co.za
90
64
  executables: []
91
-
92
65
  extensions: []
93
-
94
66
  extra_rdoc_files: []
95
-
96
- files:
67
+ files:
97
68
  - .gitignore
69
+ - .rvmrc
98
70
  - Gemfile
99
71
  - Rakefile
100
72
  - lib/wurfl-lite.rb
101
73
  - lib/wurfl-lite/version.rb
102
74
  - wurfl-lite.gemspec
103
- has_rdoc: true
104
75
  homepage: http://www.darkarts.co.za/wurfl-lite
105
76
  licenses: []
106
-
107
77
  post_install_message:
108
78
  rdoc_options: []
109
-
110
- require_paths:
79
+ require_paths:
111
80
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
81
+ required_ruby_version: !ruby/object:Gem::Requirement
113
82
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: -3153059578555577550
118
- segments:
119
- - 0
120
- version: "0"
121
- required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
88
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: -3153059578555577550
127
- segments:
128
- - 0
129
- version: "0"
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
130
93
  requirements: []
131
-
132
94
  rubyforge_project:
133
- rubygems_version: 1.3.7
95
+ rubygems_version: 1.8.17
134
96
  signing_key:
135
97
  specification_version: 3
136
98
  summary: Simple Ruby usage of the WURFL device capabilities and features database
137
99
  test_files: []
138
-