radiospiel-app 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -9,7 +9,7 @@ class Hash
9
9
 
10
10
  def symbolize_keys
11
11
  r = []
12
- each { |k,v| r << k.to_sym << v }
12
+ each { |k,v| r << (k.respond_to?(:to_sym) ? k.to_sym : k) << v }
13
13
  Hash[*r]
14
14
  end
15
15
  end
@@ -9,10 +9,22 @@ module Http
9
9
  extend self
10
10
 
11
11
  # the default expiration time for get requests.
12
- attr :max_age
12
+ module MaxAge
13
+ def self.config
14
+ @config ||= (App.config["cache-max-age"] || {}).to_a
15
+ end
16
+
17
+ def self.for(url)
18
+ config.each do |pattern, max_age|
19
+ return max_age if url.index(pattern)
20
+ end
21
+ nil
22
+ end
23
+ end
13
24
 
14
- def get(url, max_age = self.max_age)
25
+ def get(url, max_age = MaxAge.for(url))
15
26
  App.logger.benchmark("[GET] #{url}", :minimum => 20) do
27
+ App.logger.debug "[GET] #{url}"
16
28
  App.cached(url, max_age) do get_(url) end
17
29
  end
18
30
  end
@@ -6,7 +6,8 @@ require "micro_sql"
6
6
  module Geocoder
7
7
  extend self
8
8
 
9
- TIME_TO_LIVE = 3600
9
+ # 30 days
10
+ TIME_TO_LIVE = 30 * 24 * 3600
10
11
 
11
12
  def geocode(address)
12
13
  Geocoder.cached(address) { __geocode__(address) }
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "radiospiel-app"
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["radiospiel"]
@@ -52,7 +52,10 @@ Gem::Specification.new do |s|
52
52
  "test/cgi_ext_test.rb",
53
53
  "test/config.yml",
54
54
  "test/config_test.rb",
55
+ "test/fixtures-vcr/geocoder.yml",
55
56
  "test/fixtures-vcr/http_test.yml",
57
+ "test/geocoder_test.rb",
58
+ "test/hash_ext_test.rb",
56
59
  "test/helper.rb",
57
60
  "test/http_test.rb",
58
61
  "test/string_ext_test.rb",
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://maps.google.com/maps/geo?oe=utf-8&output=json&q=Berlin
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Content-Type:
20
+ - !binary |-
21
+ dGV4dC9qYXZhc2NyaXB0OyBjaGFyc2V0PVVURi04
22
+ !binary "VmFyeQ==":
23
+ - !binary |-
24
+ QWNjZXB0LUxhbmd1YWdl
25
+ !binary "RGF0ZQ==":
26
+ - !binary |-
27
+ V2VkLCAwNCBBcHIgMjAxMiAxNToxMTo0MyBHTVQ=
28
+ !binary "U2VydmVy":
29
+ - !binary |-
30
+ bWFmZQ==
31
+ Cache-Control:
32
+ - !binary |-
33
+ cHJpdmF0ZQ==
34
+ X-Xss-Protection:
35
+ - !binary |-
36
+ MTsgbW9kZT1ibG9jaw==
37
+ X-Frame-Options:
38
+ - !binary |-
39
+ U0FNRU9SSUdJTg==
40
+ Transfer-Encoding:
41
+ - !binary |-
42
+ Y2h1bmtlZA==
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ! "{\n \"name\": \"Berlin\",\n \"Status\": {\n \"code\": 200,\n
46
+ \ \"request\": \"geocode\"\n },\n \"Placemark\": [ {\n \"id\": \"p1\",\n
47
+ \ \"address\": \"Berlin, Germany\",\n \"AddressDetails\": {\n \"Accuracy\"
48
+ : 4,\n \"Country\" : {\n \"AdministrativeArea\" : {\n \"AdministrativeAreaName\"
49
+ : \"Berlin\",\n \"Locality\" : {\n \"LocalityName\" : \"Berlin\"\n
50
+ \ }\n },\n \"CountryName\" : \"Deutschland\",\n \"CountryNameCode\"
51
+ : \"DE\"\n }\n},\n \"ExtendedData\": {\n \"LatLonBox\": {\n \"north\":
52
+ 52.7409729,\n \"south\": 52.3064887,\n \"east\": 13.9185276,\n
53
+ \ \"west\": 12.8940524\n }\n },\n \"Point\": {\n \"coordinates\":
54
+ [ 13.4062900, 52.5242680, 0 ]\n }\n } ]\n}\n"
55
+ http_version:
56
+ recorded_at: Wed, 04 Apr 2012 15:11:44 GMT
57
+ recorded_with: VCR 2.0.1
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = "#{File.dirname(__FILE__)}/fixtures-vcr"
8
+ c.hook_into :webmock
9
+ end
10
+
11
+ class GeocoderTest < Test::Unit::TestCase
12
+ def test_geocoder
13
+ VCR.use_cassette('geocoder') do
14
+ expected = [13.40629, 52.524268, 0]
15
+ assert_equal(expected, Geocoder.geocode("Berlin"))
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+
5
+ class HashExtTest < Test::Unit::TestCase
6
+ def test_stringify
7
+ assert_equal({}, {}.stringify_keys)
8
+ assert_equal({ "a" => "a", "b" => "b", "1" => 1 }, { :a => "a", "b" => "b", 1 => 1 }.stringify_keys)
9
+ end
10
+
11
+ def test_symbolize
12
+ assert_equal({}, {}.symbolize_keys)
13
+ assert_equal({ :a => "a", :b => "b", 1 => 1 }, { :a => "a", "b" => "b", 1 => 1 }.symbolize_keys)
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiospiel-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg
16
- requirement: &70142794674320 !ruby/object:Gem::Requirement
16
+ requirement: &70217957037640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70142794674320
24
+ version_requirements: *70217957037640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &70142794673660 !ruby/object:Gem::Requirement
27
+ requirement: &70217957036420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70142794673660
35
+ version_requirements: *70217957036420
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: redis
38
- requirement: &70142794673040 !ruby/object:Gem::Requirement
38
+ requirement: &70217957035480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70142794673040
46
+ version_requirements: *70217957035480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: micro_sql
49
- requirement: &70142794672460 !ruby/object:Gem::Requirement
49
+ requirement: &70217957034820 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70142794672460
57
+ version_requirements: *70217957034820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: htmlentities
60
- requirement: &70142794671900 !ruby/object:Gem::Requirement
60
+ requirement: &70217957034200 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70142794671900
68
+ version_requirements: *70217957034200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70142794671100 !ruby/object:Gem::Requirement
71
+ requirement: &70217957033440 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70142794671100
79
+ version_requirements: *70217957033440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70142794670440 !ruby/object:Gem::Requirement
82
+ requirement: &70217957032620 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70142794670440
90
+ version_requirements: *70217957032620
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: vcr
93
- requirement: &70142794669380 !ruby/object:Gem::Requirement
93
+ requirement: &70217957031760 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70142794669380
101
+ version_requirements: *70217957031760
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: webmock
104
- requirement: &70142794668780 !ruby/object:Gem::Requirement
104
+ requirement: &70217957030980 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70142794668780
112
+ version_requirements: *70217957030980
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: psych
115
- requirement: &70142794668260 !ruby/object:Gem::Requirement
115
+ requirement: &70217957029440 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70142794668260
123
+ version_requirements: *70217957029440
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: simplecov
126
- requirement: &70142794667460 !ruby/object:Gem::Requirement
126
+ requirement: &70217957028300 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70142794667460
134
+ version_requirements: *70217957028300
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: ruby-debug19
137
- requirement: &70142794666640 !ruby/object:Gem::Requirement
137
+ requirement: &70217957027160 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70142794666640
145
+ version_requirements: *70217957027160
146
146
  description: Some basics that your application could benefit from.
147
147
  email: eno@open-lab.org
148
148
  executables: []
@@ -186,7 +186,10 @@ files:
186
186
  - test/cgi_ext_test.rb
187
187
  - test/config.yml
188
188
  - test/config_test.rb
189
+ - test/fixtures-vcr/geocoder.yml
189
190
  - test/fixtures-vcr/http_test.yml
191
+ - test/geocoder_test.rb
192
+ - test/hash_ext_test.rb
190
193
  - test/helper.rb
191
194
  - test/http_test.rb
192
195
  - test/string_ext_test.rb
@@ -207,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
210
  version: '0'
208
211
  segments:
209
212
  - 0
210
- hash: -342124506213546758
213
+ hash: -2234513131889917525
211
214
  required_rubygems_version: !ruby/object:Gem::Requirement
212
215
  none: false
213
216
  requirements: