radiospieler 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,12 +3,8 @@ source "http://rubygems.org"
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
- gem "pg"
7
- gem "sqlite3"
8
- gem "redis"
9
- gem "micro_sql"
10
- gem "simple_cache"
11
6
  gem "htmlentities"
7
+ gem "simple_cache_rs"
12
8
 
13
9
  # Add dependencies to develop your gem here.
14
10
  # Include everything needed to run rake, tests, features, etc.
data/Gemfile.lock CHANGED
@@ -15,16 +15,11 @@ GEM
15
15
  json (1.6.6)
16
16
  linecache19 (0.5.12)
17
17
  ruby_core_source (>= 0.1.4)
18
- micro_sql (0.3.2)
19
- pg
20
- sqlite3
21
18
  multi_json (1.2.0)
22
- pg (0.13.2)
23
- psych (1.3.1)
19
+ psych (1.3.2)
24
20
  rake (0.9.2.2)
25
21
  rdoc (3.12)
26
22
  json (~> 1.4)
27
- redis (2.2.2)
28
23
  ruby-debug-base19 (0.11.25)
29
24
  columnize (>= 0.3.1)
30
25
  linecache19 (>= 0.5.11)
@@ -35,7 +30,7 @@ GEM
35
30
  ruby-debug-base19 (>= 0.11.19)
36
31
  ruby_core_source (0.1.5)
37
32
  archive-tar-minitar (>= 0.5.2)
38
- simple_cache (0.8.1)
33
+ simple_cache_rs (0.9.2)
39
34
  sqlite3
40
35
  simplecov (0.6.1)
41
36
  multi_json (~> 1.0)
@@ -54,13 +49,9 @@ DEPENDENCIES
54
49
  bundler
55
50
  htmlentities
56
51
  jeweler
57
- micro_sql
58
- pg
59
52
  psych
60
- redis
61
53
  ruby-debug19
62
- simple_cache
54
+ simple_cache_rs
63
55
  simplecov
64
- sqlite3
65
56
  vcr
66
57
  webmock
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
data/config/app.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  default:
2
- cache: redis://localhost:6379/0
2
+ no-cache: redis://localhost:6379/0
3
3
  bitly:
4
4
  user: "bitlyapidemo"
5
5
  key: "R_0da49e0a9118ff35f52f629d2d71bf07"
@@ -1,4 +1,5 @@
1
1
  require 'net/http'
2
+ require 'simple_cache'
2
3
 
3
4
  # The Http module defines a
4
5
  #
@@ -24,7 +25,7 @@ module Http
24
25
 
25
26
  def get(url, max_age = MaxAge.for(url))
26
27
  App.logger.benchmark("[GET] #{url}", :minimum => 20) do
27
- App.cached(url, max_age) do
28
+ SimpleCache.cached(url, max_age) do
28
29
  App.logger.debug "[GET] #{url}"
29
30
  get_(url)
30
31
  end
@@ -0,0 +1,11 @@
1
+ require "simple_cache"
2
+
3
+ module SimpleCache
4
+ def self.fallback_url
5
+ "#{File.basename(App.root)}/a#{App.root.uid64}".tap { |name|
6
+ App.logger.warn "No, invalid, or unsupported :cache configuration, fallback to #{name}"
7
+ }
8
+ end
9
+ end
10
+
11
+ SimpleCache.url = App.config[:cache] || SimpleCache.fallback_url
data/radiospieler.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "radiospieler"
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["radiospiel"]
12
- s.date = "2012-04-08"
12
+ s.date = "2012-04-09"
13
13
  s.description = "Some basics that your application could benefit from."
14
14
  s.email = "eno@open-lab.org"
15
15
  s.extra_rdoc_files = [
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
24
24
  "README.rdoc",
25
25
  "Rakefile",
26
26
  "VERSION",
27
- "app.tmproj",
28
27
  "config/app.yml",
29
28
  "lib/core-extensions/array_ext.rb",
30
29
  "lib/core-extensions/benchmark-logger.rb",
@@ -39,15 +38,15 @@ Gem::Specification.new do |s|
39
38
  "lib/extensions/http.rb",
40
39
  "lib/radiospieler.rb",
41
40
  "lib/radiospieler/radiospieler.rb",
42
- "lib/radiospieler/radiospieler/cache.rb",
43
41
  "lib/radiospieler/radiospieler/config.rb",
44
42
  "lib/radiospieler/radiospieler/logger.rb",
45
43
  "lib/radiospieler/radiospieler/root.rb",
44
+ "lib/radiospieler/radiospieler/zz_initialise.rb",
46
45
  "radiospieler.gemspec",
46
+ "radiospieler.tmproj",
47
47
  "script/watchr",
48
48
  "test/app_test.rb",
49
49
  "test/array_ext_test.rb",
50
- "test/cache_test.rb",
51
50
  "test/cgi_ext_test.rb",
52
51
  "test/config.yml",
53
52
  "test/config_test.rb",
@@ -62,19 +61,15 @@ Gem::Specification.new do |s|
62
61
  s.homepage = "http://github.com/radiospiel/radiospieler"
63
62
  s.licenses = ["MIT"]
64
63
  s.require_paths = ["lib"]
65
- s.rubygems_version = "1.8.17"
64
+ s.rubygems_version = "1.8.10"
66
65
  s.summary = "Application base code"
67
66
 
68
67
  if s.respond_to? :specification_version then
69
68
  s.specification_version = 3
70
69
 
71
70
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
- s.add_runtime_dependency(%q<pg>, [">= 0"])
73
- s.add_runtime_dependency(%q<sqlite3>, [">= 0"])
74
- s.add_runtime_dependency(%q<redis>, [">= 0"])
75
- s.add_runtime_dependency(%q<micro_sql>, [">= 0"])
76
- s.add_runtime_dependency(%q<simple_cache>, [">= 0"])
77
71
  s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
72
+ s.add_runtime_dependency(%q<simple_cache_rs>, [">= 0"])
78
73
  s.add_development_dependency(%q<bundler>, [">= 0"])
79
74
  s.add_development_dependency(%q<jeweler>, [">= 0"])
80
75
  s.add_development_dependency(%q<vcr>, [">= 0"])
@@ -83,12 +78,8 @@ Gem::Specification.new do |s|
83
78
  s.add_development_dependency(%q<simplecov>, [">= 0"])
84
79
  s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
85
80
  else
86
- s.add_dependency(%q<pg>, [">= 0"])
87
- s.add_dependency(%q<sqlite3>, [">= 0"])
88
- s.add_dependency(%q<redis>, [">= 0"])
89
- s.add_dependency(%q<micro_sql>, [">= 0"])
90
- s.add_dependency(%q<simple_cache>, [">= 0"])
91
81
  s.add_dependency(%q<htmlentities>, [">= 0"])
82
+ s.add_dependency(%q<simple_cache_rs>, [">= 0"])
92
83
  s.add_dependency(%q<bundler>, [">= 0"])
93
84
  s.add_dependency(%q<jeweler>, [">= 0"])
94
85
  s.add_dependency(%q<vcr>, [">= 0"])
@@ -98,12 +89,8 @@ Gem::Specification.new do |s|
98
89
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
99
90
  end
100
91
  else
101
- s.add_dependency(%q<pg>, [">= 0"])
102
- s.add_dependency(%q<sqlite3>, [">= 0"])
103
- s.add_dependency(%q<redis>, [">= 0"])
104
- s.add_dependency(%q<micro_sql>, [">= 0"])
105
- s.add_dependency(%q<simple_cache>, [">= 0"])
106
92
  s.add_dependency(%q<htmlentities>, [">= 0"])
93
+ s.add_dependency(%q<simple_cache_rs>, [">= 0"])
107
94
  s.add_dependency(%q<bundler>, [">= 0"])
108
95
  s.add_dependency(%q<jeweler>, [">= 0"])
109
96
  s.add_dependency(%q<vcr>, [">= 0"])
File without changes
data/test/test_helper.rb CHANGED
@@ -19,11 +19,11 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
19
19
  $LOAD_PATH.unshift(File.dirname(__FILE__))
20
20
 
21
21
  require 'radiospieler'
22
- require 'micro_sql'
22
+ # require 'micro_sql'
23
23
  App.env = "test"
24
24
 
25
25
  App.logger.level = Logger::ERROR
26
- MicroSql.logger = App.logger
26
+ # MicroSql.logger = App.logger
27
27
 
28
28
  class Test::Unit::TestCase
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiospieler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,55 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-08 00:00:00.000000000 Z
12
+ date: 2012-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: pg
16
- requirement: &70259610997200 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70259610997200
25
- - !ruby/object:Gem::Dependency
26
- name: sqlite3
27
- requirement: &70259610996400 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70259610996400
36
- - !ruby/object:Gem::Dependency
37
- name: redis
38
- requirement: &70259610995780 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70259610995780
47
- - !ruby/object:Gem::Dependency
48
- name: micro_sql
49
- requirement: &70259610995000 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: *70259610995000
58
- - !ruby/object:Gem::Dependency
59
- name: simple_cache
60
- requirement: &70259610994380 !ruby/object:Gem::Requirement
15
+ name: htmlentities
16
+ requirement: &70249433956660 !ruby/object:Gem::Requirement
61
17
  none: false
62
18
  requirements:
63
19
  - - ! '>='
@@ -65,10 +21,10 @@ dependencies:
65
21
  version: '0'
66
22
  type: :runtime
67
23
  prerelease: false
68
- version_requirements: *70259610994380
24
+ version_requirements: *70249433956660
69
25
  - !ruby/object:Gem::Dependency
70
- name: htmlentities
71
- requirement: &70259610993720 !ruby/object:Gem::Requirement
26
+ name: simple_cache_rs
27
+ requirement: &70249433955880 !ruby/object:Gem::Requirement
72
28
  none: false
73
29
  requirements:
74
30
  - - ! '>='
@@ -76,10 +32,10 @@ dependencies:
76
32
  version: '0'
77
33
  type: :runtime
78
34
  prerelease: false
79
- version_requirements: *70259610993720
35
+ version_requirements: *70249433955880
80
36
  - !ruby/object:Gem::Dependency
81
37
  name: bundler
82
- requirement: &70259610993100 !ruby/object:Gem::Requirement
38
+ requirement: &70249433955060 !ruby/object:Gem::Requirement
83
39
  none: false
84
40
  requirements:
85
41
  - - ! '>='
@@ -87,10 +43,10 @@ dependencies:
87
43
  version: '0'
88
44
  type: :development
89
45
  prerelease: false
90
- version_requirements: *70259610993100
46
+ version_requirements: *70249433955060
91
47
  - !ruby/object:Gem::Dependency
92
48
  name: jeweler
93
- requirement: &70259610992200 !ruby/object:Gem::Requirement
49
+ requirement: &70249433953760 !ruby/object:Gem::Requirement
94
50
  none: false
95
51
  requirements:
96
52
  - - ! '>='
@@ -98,10 +54,10 @@ dependencies:
98
54
  version: '0'
99
55
  type: :development
100
56
  prerelease: false
101
- version_requirements: *70259610992200
57
+ version_requirements: *70249433953760
102
58
  - !ruby/object:Gem::Dependency
103
59
  name: vcr
104
- requirement: &70259610991420 !ruby/object:Gem::Requirement
60
+ requirement: &70249433951800 !ruby/object:Gem::Requirement
105
61
  none: false
106
62
  requirements:
107
63
  - - ! '>='
@@ -109,10 +65,10 @@ dependencies:
109
65
  version: '0'
110
66
  type: :development
111
67
  prerelease: false
112
- version_requirements: *70259610991420
68
+ version_requirements: *70249433951800
113
69
  - !ruby/object:Gem::Dependency
114
70
  name: webmock
115
- requirement: &70259610989620 !ruby/object:Gem::Requirement
71
+ requirement: &70249433950840 !ruby/object:Gem::Requirement
116
72
  none: false
117
73
  requirements:
118
74
  - - ! '>='
@@ -120,10 +76,10 @@ dependencies:
120
76
  version: '0'
121
77
  type: :development
122
78
  prerelease: false
123
- version_requirements: *70259610989620
79
+ version_requirements: *70249433950840
124
80
  - !ruby/object:Gem::Dependency
125
81
  name: psych
126
- requirement: &70259610988560 !ruby/object:Gem::Requirement
82
+ requirement: &70249433949900 !ruby/object:Gem::Requirement
127
83
  none: false
128
84
  requirements:
129
85
  - - ! '>='
@@ -131,10 +87,10 @@ dependencies:
131
87
  version: '0'
132
88
  type: :development
133
89
  prerelease: false
134
- version_requirements: *70259610988560
90
+ version_requirements: *70249433949900
135
91
  - !ruby/object:Gem::Dependency
136
92
  name: simplecov
137
- requirement: &70259610987980 !ruby/object:Gem::Requirement
93
+ requirement: &70249433949220 !ruby/object:Gem::Requirement
138
94
  none: false
139
95
  requirements:
140
96
  - - ! '>='
@@ -142,10 +98,10 @@ dependencies:
142
98
  version: '0'
143
99
  type: :development
144
100
  prerelease: false
145
- version_requirements: *70259610987980
101
+ version_requirements: *70249433949220
146
102
  - !ruby/object:Gem::Dependency
147
103
  name: ruby-debug19
148
- requirement: &70259610987120 !ruby/object:Gem::Requirement
104
+ requirement: &70249433948560 !ruby/object:Gem::Requirement
149
105
  none: false
150
106
  requirements:
151
107
  - - ! '>='
@@ -153,7 +109,7 @@ dependencies:
153
109
  version: '0'
154
110
  type: :development
155
111
  prerelease: false
156
- version_requirements: *70259610987120
112
+ version_requirements: *70249433948560
157
113
  description: Some basics that your application could benefit from.
158
114
  email: eno@open-lab.org
159
115
  executables: []
@@ -169,7 +125,6 @@ files:
169
125
  - README.rdoc
170
126
  - Rakefile
171
127
  - VERSION
172
- - app.tmproj
173
128
  - config/app.yml
174
129
  - lib/core-extensions/array_ext.rb
175
130
  - lib/core-extensions/benchmark-logger.rb
@@ -184,15 +139,15 @@ files:
184
139
  - lib/extensions/http.rb
185
140
  - lib/radiospieler.rb
186
141
  - lib/radiospieler/radiospieler.rb
187
- - lib/radiospieler/radiospieler/cache.rb
188
142
  - lib/radiospieler/radiospieler/config.rb
189
143
  - lib/radiospieler/radiospieler/logger.rb
190
144
  - lib/radiospieler/radiospieler/root.rb
145
+ - lib/radiospieler/radiospieler/zz_initialise.rb
191
146
  - radiospieler.gemspec
147
+ - radiospieler.tmproj
192
148
  - script/watchr
193
149
  - test/app_test.rb
194
150
  - test/array_ext_test.rb
195
- - test/cache_test.rb
196
151
  - test/cgi_ext_test.rb
197
152
  - test/config.yml
198
153
  - test/config_test.rb
@@ -218,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
173
  version: '0'
219
174
  segments:
220
175
  - 0
221
- hash: -3553112263519257702
176
+ hash: 884600040953440403
222
177
  required_rubygems_version: !ruby/object:Gem::Requirement
223
178
  none: false
224
179
  requirements:
@@ -227,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
182
  version: '0'
228
183
  requirements: []
229
184
  rubyforge_project:
230
- rubygems_version: 1.8.17
185
+ rubygems_version: 1.8.10
231
186
  signing_key:
232
187
  specification_version: 3
233
188
  summary: Application base code
@@ -1,86 +0,0 @@
1
- require_relative "config"
2
- require "simple_cache"
3
-
4
- # This is a cache module, which keeps entries for a certain time period (or forever).
5
- #
6
- # Entries are packed via Marshal.
7
- module App
8
- module Cache
9
- DEFAULT_MAX_AGE = 4 * 3600 # 4 hours.
10
-
11
- def self.store
12
- @store ||= Store.create(App.config[:cache]) || Store.fallback
13
- end
14
-
15
- def self.store=(store)
16
- @store = store
17
- end
18
-
19
- def self.clear
20
- store.clear
21
- end
22
-
23
- module Store
24
- def self.create(url)
25
- return unless url
26
-
27
- uri = URI.parse(url)
28
- case uri.scheme
29
- when "redis" then RedisStore.new(url)
30
- when nil then ::SimpleCache.new(uri.path)
31
- end
32
- end
33
-
34
- def self.fallback
35
- name = "#{File.basename(App.root)}/a#{App.root.uid64}"
36
- SimpleCache.new(name).tap do |store|
37
- App.logger.warn "No, invalid, or unsupported :cache configuration, fallback to #{store.path}"
38
- end
39
- end
40
- end
41
-
42
- class Store::RedisStore
43
- def initialize(url)
44
- require "redis"
45
- @redis = Redis.connect(:url => url)
46
- end
47
-
48
- include SimpleCache::Marshal
49
-
50
- def keys
51
- @redis.keys
52
- end
53
-
54
- def clear
55
- @redis.flushdb
56
- #debugger
57
- 1
58
- end
59
-
60
- def store(key, value, max_age = DEFAULT_MAX_AGE)
61
- cache_id = uid(key)
62
- if value
63
- @redis.set cache_id, marshal(value)
64
- @redis.expire cache_id, max_age if max_age
65
- else
66
- @redis.del cache_id
67
- end
68
- value
69
- end
70
-
71
- def fetch(key, &block)
72
- marshalled = @redis.get(uid(key))
73
- marshalled ? unmarshal(marshalled) : yield
74
- end
75
- end
76
- end
77
-
78
- def cached(key, max_age = Cache::DEFAULT_MAX_AGE, &block)
79
- return yield if !max_age
80
-
81
- cache_store = Cache.store
82
- cache_store.fetch(key) do
83
- cache_store.store(key, yield, max_age)
84
- end
85
- end
86
- end
data/test/cache_test.rb DELETED
@@ -1,15 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class CacheTest < Test::Unit::TestCase
4
- def test_caching
5
- App::Cache.clear
6
-
7
- done = 0
8
-
9
- r = App.cached("six") { done += 1; 2 * 3 }
10
- assert_equal([1, 6], [done, r])
11
-
12
- r = App.cached("six") { done += 1; 2 * 3 }
13
- assert_equal([1, 6], [done, r])
14
- end
15
- end