ruby-ext 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/.git/COMMIT_EDITMSG CHANGED
@@ -1 +1 @@
1
- fix
1
+ upd cache
data/.git/index CHANGED
Binary file
data/.git/logs/HEAD CHANGED
@@ -17,3 +17,4 @@ edf084d86f4c5aa17fce73a22a44c2dda49c7cab 76d8411ad8aa53f568f378bd48dee0cfbd107a1
17
17
  76d8411ad8aa53f568f378bd48dee0cfbd107a16 5564bf7edfff421a8a139bc630311a999e9187df alex <alex@amac.local> 1268680901 +0300 commit: upd should
18
18
  5564bf7edfff421a8a139bc630311a999e9187df 3756676bcca271d513748813326b9d1cb06289b6 alex <alex@amac.local> 1268706445 +0300 commit: upd
19
19
  3756676bcca271d513748813326b9d1cb06289b6 6be005ea42b15826dc18f25290a98ece86ec5847 alex <alex@amac.local> 1269314659 +0300 commit: fix
20
+ 6be005ea42b15826dc18f25290a98ece86ec5847 a691900cb5b7378b173ce55a29de35c18b26cd6e alex <alex@amac.local> 1270054026 +0400 commit: upd cache
@@ -17,3 +17,4 @@ edf084d86f4c5aa17fce73a22a44c2dda49c7cab 76d8411ad8aa53f568f378bd48dee0cfbd107a1
17
17
  76d8411ad8aa53f568f378bd48dee0cfbd107a16 5564bf7edfff421a8a139bc630311a999e9187df alex <alex@amac.local> 1268680901 +0300 commit: upd should
18
18
  5564bf7edfff421a8a139bc630311a999e9187df 3756676bcca271d513748813326b9d1cb06289b6 alex <alex@amac.local> 1268706445 +0300 commit: upd
19
19
  3756676bcca271d513748813326b9d1cb06289b6 6be005ea42b15826dc18f25290a98ece86ec5847 alex <alex@amac.local> 1269314659 +0300 commit: fix
20
+ 6be005ea42b15826dc18f25290a98ece86ec5847 a691900cb5b7378b173ce55a29de35c18b26cd6e alex <alex@amac.local> 1270054026 +0400 commit: upd cache
@@ -15,3 +15,4 @@ ee69f9fad83c5b0668b62622037094e989d3c394 493774d80093f4ec3c6c3bfad21e1c8c9eaf41e
15
15
  edf084d86f4c5aa17fce73a22a44c2dda49c7cab 76d8411ad8aa53f568f378bd48dee0cfbd107a16 alex <alex@amac.local> 1268137352 +0300 update by push
16
16
  76d8411ad8aa53f568f378bd48dee0cfbd107a16 3756676bcca271d513748813326b9d1cb06289b6 alex <alex@amac.local> 1268706452 +0300 update by push
17
17
  3756676bcca271d513748813326b9d1cb06289b6 6be005ea42b15826dc18f25290a98ece86ec5847 alex <alex@amac.local> 1269314668 +0300 update by push
18
+ 6be005ea42b15826dc18f25290a98ece86ec5847 a691900cb5b7378b173ce55a29de35c18b26cd6e alex <alex@amac.local> 1270054037 +0400 update by push
@@ -0,0 +1,3 @@
1
+ x}�OK1Žn?��^ZXO���A��
2
+ �HH���h6)I�V�~w'K�Ń��a��̏��vW�gR �����ƤPb�J�՗����T�ʇz�:�p
3
+ K���Ɵ��O��N��7u�`
@@ -1 +1 @@
1
- 6be005ea42b15826dc18f25290a98ece86ec5847
1
+ a691900cb5b7378b173ce55a29de35c18b26cd6e
@@ -1 +1 @@
1
- 6be005ea42b15826dc18f25290a98ece86ec5847
1
+ a691900cb5b7378b173ce55a29de35c18b26cd6e
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ require 'fileutils'
18
18
 
19
19
  spec = Gem::Specification.new do |s|
20
20
  s.name = "ruby-ext"
21
- s.version = "0.2.8"
21
+ s.version = "0.2.9"
22
22
  s.summary = "Set of common Ruby language extensions"
23
23
  s.description = "Set of common Ruby language extensions"
24
24
  s.author = "Alexey Petrushin"
@@ -1,20 +1,20 @@
1
1
  require 'monitor'
2
2
 
3
+ class Class
4
+ def cache! *methods
5
+ DeclarativeCache.cache! self, *methods
6
+ end
7
+
8
+ def cache_with_params! *methods
9
+ DeclarativeCache.cache_with_params! self, *methods
10
+ end
11
+ end
12
+
3
13
  module DeclarativeCache
4
14
  DISABLED = false
5
15
 
6
16
  warn "CASHE DISABLED" if DISABLED
7
17
 
8
- # It's not a good idea to mix Business Logic and Performance optimization,
9
- # so i think these methods should be never used.
10
- # def cached *methods
11
- # DeclarativeCache.cached self, *methods
12
- # end
13
- #
14
- # def cached_with_params *methods
15
- # DeclarativeCache.cached_with_params self, *methods
16
- # end
17
-
18
18
  @versions, @alias_counter, @monitor = Hash.new{should! :be_never_called}, 0, Monitor.new
19
19
  class << self
20
20
 
@@ -23,7 +23,7 @@ module DeclarativeCache
23
23
  return :"m#{@alias_counter}"
24
24
  end
25
25
 
26
- def cached *arg
26
+ def cache! *arg
27
27
  vnames, klass, methods = parse_and_check_arguments *arg
28
28
 
29
29
  return if DISABLED
@@ -43,7 +43,7 @@ module DeclarativeCache
43
43
  end
44
44
  end
45
45
 
46
- def cached_with_params *arg
46
+ def cache_with_params! *arg
47
47
  vnames, klass, methods = parse_and_check_arguments *arg
48
48
 
49
49
  return if DISABLED
@@ -79,20 +79,25 @@ module DeclarativeCache
79
79
 
80
80
  protected
81
81
  def parse_and_check_arguments *arg
82
- arg.size.should! :>=, 3
83
-
84
- version_names = arg[0]
85
- if version_names.is_a? Array
86
- version_names.size.should! :>, 0
87
- version_names = version_names.collect{|n| n.to_s}
88
- else
89
- version_names = version_names.to_s
90
- end
91
-
92
- klass = arg[1]
82
+ arg.size.should! :>=, 2
83
+
84
+ if arg.size == 3
85
+ version_names = arg.shift
86
+ if version_names.is_a? Array
87
+ version_names.size.should! :>, 0
88
+ version_names = version_names.collect{|n| n.to_s}
89
+ else
90
+ version_names = version_names.to_s
91
+ end
92
+
93
+ klass = arg.shift
94
+ else
95
+ version_names = klass = arg.shift
96
+ end
97
+
93
98
  klass.class.should! :be, [Class, Module]
94
99
 
95
- methods = arg[2..arg.size]
100
+ methods = Array(arg.first)
96
101
  defined = klass.instance_methods
97
102
  methods.each do |m|
98
103
  raise "Invalid method_name '#{m}'!" unless defined.include? m.to_s
@@ -11,11 +11,11 @@ String.class_eval do
11
11
  "@#{self}"
12
12
  end
13
13
 
14
- # def interpolate binding
15
- # binding.should! :be_a, Binding
16
- # return gsub(/\#\{.+?\}/) do |term|
17
- # identifier = term.slice(2 .. term.size-2)
18
- # binding.eval identifier
19
- # end
20
- # end
14
+ def interpolate binding
15
+ binding.should! :be_a, Binding
16
+ return gsub(/\#\{.+?\}/) do |term|
17
+ identifier = term.slice(2 .. term.size-2)
18
+ binding.eval identifier
19
+ end
20
+ end
21
21
  end
data/lib/ruby_ext.rb CHANGED
@@ -20,6 +20,7 @@ more = [
20
20
  (core + more).each{|f| require f}
21
21
 
22
22
  %w{
23
+ file
23
24
  kernel
24
25
  module
25
26
  not_defined
@@ -9,4 +9,4 @@ class Module
9
9
  return list.reverse.inject(:merge)
10
10
  end
11
11
  end
12
- DeclarativeCache.cached_with_params :class, Module, :localization
12
+ DeclarativeCache.cache_with_params! :class, Module, :localization
@@ -9,6 +9,7 @@ describe 'DeclarativeCache' do
9
9
  class CachedClass
10
10
  attr_accessor :value
11
11
  def value_get; @value end
12
+ cache! :value_get
12
13
 
13
14
  attr_accessor :value2
14
15
  def value2_get; @value2 end
@@ -17,9 +18,9 @@ describe 'DeclarativeCache' do
17
18
  def params_get param; @params[param] end
18
19
  end
19
20
 
20
- DeclarativeCache.cached CachedClass, CachedClass, :value_get
21
- DeclarativeCache.cached :cache_version_name, CachedClass, :value2_get
22
- DeclarativeCache.cached_with_params CachedClass, CachedClass, :params_get
21
+ # DeclarativeCache.cache! CachedClass, :value_get
22
+ DeclarativeCache.cache! :cache_version_name, CachedClass, :value2_get
23
+ DeclarativeCache.cache_with_params! CachedClass, CachedClass, :params_get
23
24
 
24
25
  it "Simple Cache" do
25
26
  o = CachedClass.new
@@ -56,7 +57,7 @@ describe 'DeclarativeCache' do
56
57
  end
57
58
  end
58
59
 
59
- DeclarativeCache.cached CachedClass2, CachedClass2.singleton_class, :value_get
60
+ DeclarativeCache.cache! CachedClass2, CachedClass2.singleton_class, :value_get
60
61
 
61
62
  it "Simple Cache" do
62
63
  CachedClass2.value = 0
@@ -75,8 +76,8 @@ describe 'DeclarativeCache' do
75
76
  def value2_get params; @value2 end
76
77
  end
77
78
 
78
- DeclarativeCache.cached [:class, :resource_update, :security_update], MultipleCacheVersions, :value_get
79
- DeclarativeCache.cached_with_params [:class, :resource_update, :security_update], MultipleCacheVersions, :value2_get
79
+ DeclarativeCache.cache! [:class, :resource_update, :security_update], MultipleCacheVersions, :value_get
80
+ DeclarativeCache.cache_with_params! [:class, :resource_update, :security_update], MultipleCacheVersions, :value2_get
80
81
 
81
82
  it "Multiple cache versions" do
82
83
  o = MultipleCacheVersions.new
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 8
9
- version: 0.2.8
8
+ - 9
9
+ version: 0.2.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alexey Petrushin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-23 00:00:00 +03:00
17
+ date: 2010-03-31 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -167,10 +167,12 @@ files:
167
167
  - .git/objects/18/4a49936babbbd306a9d34846959d4a901d0014
168
168
  - .git/objects/18/fa4a1fd6a6e5293c34c6eebefaff644c553a97
169
169
  - .git/objects/19/342d43c2e91b7bca75f329bf758d69818c827e
170
+ - .git/objects/1a/a213d5a0e14f06205df279affdd619dc4cd007
170
171
  - .git/objects/20/c2ee1bb9f6749181e464a4ce444092fc1a1ecb
171
172
  - .git/objects/22/442fd63bedf426d8039bd36db647f4343a7c0c
172
173
  - .git/objects/26/4d70a16bbad0c5b3b16fb7a92bcc6178f2cca2
173
174
  - .git/objects/27/eb5694d78540b1a489a1aff5415d4713d5fca9
175
+ - .git/objects/28/8b4f34ef24874a90b8e4ffd94d0135364eff69
174
176
  - .git/objects/29/88f150ee1623b97d234b2742b30caad382775b
175
177
  - .git/objects/29/8cb590f97362cc7a326815dac3289a88b69153
176
178
  - .git/objects/29/b721d4f9ccdd3e4ed3f58778a0ab9d660fc7b1
@@ -185,11 +187,14 @@ files:
185
187
  - .git/objects/38/bf6dbb2520b448e08ac9cb353523bbc72118db
186
188
  - .git/objects/3a/5fe0dc6aaa6e41eb8dd865fa7d7100f4e68ced
187
189
  - .git/objects/3b/203741a23f9eb3df39a0444c4c5a4469a89c51
190
+ - .git/objects/40/36a1a67f1217086c5d1519ecd6bc6c85172513
188
191
  - .git/objects/44/73d59f32a2806eca098ba6bf10cdc2e6453542
189
192
  - .git/objects/44/e92f51b4c9a44497c7f170598fae64564052eb
190
193
  - .git/objects/49/3774d80093f4ec3c6c3bfad21e1c8c9eaf41ec
191
194
  - .git/objects/4b/2ac3de91e560277749f749ed47230ef080d36c
192
195
  - .git/objects/4e/0a70ecd04d25a3c9c572224bab6eeae899b238
196
+ - .git/objects/4f/9369ec9f1e545a8a9886e72d35c5d50619e5ad
197
+ - .git/objects/50/feaf03811afe046b8b26352ea4df398e758e69
193
198
  - .git/objects/52/94913c6107b381d1378279e58551fa2be7cecb
194
199
  - .git/objects/54/4fb213faf0c1b4cc459ada84120823d204ae3a
195
200
  - .git/objects/55/64bf7edfff421a8a139bc630311a999e9187df
@@ -206,6 +211,7 @@ files:
206
211
  - .git/objects/5d/281b39340e5d448c63c8f439c9ca4035ccaf66
207
212
  - .git/objects/5d/37379f1b929c7b82f96382fc256895a50e97fd
208
213
  - .git/objects/60/a681e873ca0ae0b7da3f37dbc5701f6e42b970
214
+ - .git/objects/60/af5e032ebef4d6c67d6ebc78f197887ead048b
209
215
  - .git/objects/61/beeaa4bc6790a469babafbdc7395e9e19dcb5d
210
216
  - .git/objects/61/d4509b8fc63e53b8e5d417ace33919e8a7a8f2
211
217
  - .git/objects/62/3a67b104c04e24316da21f3e229e1bc2ba9d31
@@ -224,6 +230,9 @@ files:
224
230
  - .git/objects/76/d8411ad8aa53f568f378bd48dee0cfbd107a16
225
231
  - .git/objects/77/141a7a91a61baff283e5f16e55a720d0bc65e0
226
232
  - .git/objects/7b/1a120eb8491f04c4a0d16fe3571dcb57e98ca0
233
+ - .git/objects/7d/20db5c3d8464243e317b69493492508c58f69c
234
+ - .git/objects/7e/edd3522e4b8581039bbdc867ccfbc77c0ea004
235
+ - .git/objects/7f/12d75e489e7ee9f3e5f5e4dd886263e32f2acd
227
236
  - .git/objects/7f/2c583d1fdcc5313140c57778be8b0d45824be9
228
237
  - .git/objects/81/6bb8c35fe2169fa9ecbcd40941c440e5d032e1
229
238
  - .git/objects/81/a5373f6837b02ace55c07cebf4a60fb6d4b084
@@ -240,8 +249,10 @@ files:
240
249
  - .git/objects/9f/9a4ebb6d3b4f75ebebc57119b2cf61606d4685
241
250
  - .git/objects/9f/e2acc9bded3dc0d29b1dfc7dc1b3bed5d72c8f
242
251
  - .git/objects/a2/86e70b44656d702c655b0c470327b15463698d
252
+ - .git/objects/a4/45fcc1f4c5646c1fbd51d5fda9a69ccceeca76
243
253
  - .git/objects/a4/ab487fcb12cfb831b09c525544f52d60a98598
244
254
  - .git/objects/a4/d0f078375c5b39cee3083ad428912698777c7b
255
+ - .git/objects/a6/91900cb5b7378b173ce55a29de35c18b26cd6e
245
256
  - .git/objects/a7/eab1d126c7e7e7d24c3a4159abe4e15a5c02fe
246
257
  - .git/objects/a9/2112f979b22837fa6d3d39829eff7c3fd34947
247
258
  - .git/objects/ab/daaab37771475482389bdfcb2021b1651ba399
@@ -253,6 +264,7 @@ files:
253
264
  - .git/objects/b4/cbb05893636d6b7314fbc4df7e3a8dcaeb0de1
254
265
  - .git/objects/b6/17a8cc2ae7f6ea496051db493aa56edc178073
255
266
  - .git/objects/b6/863b5d4c0a4d87b81a9bbc29e786fcf7ef0df2
267
+ - .git/objects/b8/1e6cbe2f79fbff9a49c14390b47ac86a361cd6
256
268
  - .git/objects/b8/919f6b8ea7306a4e75c38cf9743e5fb276516b
257
269
  - .git/objects/b8/c374e1a9042d9c4a478bee2c2b5b469aba55d6
258
270
  - .git/objects/bc/ee5c51061bdb9ab5a5aea4f00245a8ab3689b2
@@ -264,6 +276,8 @@ files:
264
276
  - .git/objects/c5/23a701b0f4d7b69ec9744b4cd5fcd6dd7cbb50
265
277
  - .git/objects/c9/c39c710d4de2a46c0ed97985641c2b8e4533a2
266
278
  - .git/objects/ca/9716fd518aac44d4acaa94a86838cde6030f6a
279
+ - .git/objects/d0/4df35cc5f148c409cf89ecf56aaec49b232731
280
+ - .git/objects/d0/96982b098278550168750565c9db623fdf8670
267
281
  - .git/objects/d0/b6eae8243889753a5a3e9a801b4dd5bcd09d91
268
282
  - .git/objects/d2/366fe2df53e14c3069d23cad37fe21a8f1c129
269
283
  - .git/objects/d4/8b935ca7e38d2434ceb1711544293f4baf8203
@@ -275,6 +289,7 @@ files:
275
289
  - .git/objects/e1/a14b4ea58a788a7c7917ca6ca8162e51a8971d
276
290
  - .git/objects/e9/03ba4c283cd16c7291500d4f80da24c8f5f4df
277
291
  - .git/objects/e9/d385c1913656b7ce15a1ac1424361d2e065a6c
292
+ - .git/objects/eb/47a6d6eadcdb78b8e9f4c8901d9ff60a1eb3f6
278
293
  - .git/objects/ed/f084d86f4c5aa17fce73a22a44c2dda49c7cab
279
294
  - .git/objects/ee/69f9fad83c5b0668b62622037094e989d3c394
280
295
  - .git/objects/ef/877695fc5c02b534ed53fcd877149e21d1534d