glue 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ProjectInfo +2 -2
- data/README +1 -1
- data/Rakefile +1 -1
- data/doc/RELEASES +8 -0
- data/lib/glue.rb +1 -1
- data/lib/glue/aspects.rb +2 -2
- data/lib/glue/autoreload.rb +3 -3
- data/lib/glue/cache.rb +5 -0
- data/lib/glue/cache/drb.rb +11 -6
- data/lib/glue/cache/file.rb +25 -6
- data/lib/glue/cache/memcached.rb +68 -0
- data/lib/glue/configuration.rb +0 -3
- data/lib/glue/fixture.rb +2 -2
- data/lib/glue/mailer/outgoing.rb +1 -1
- data/lib/glue/property.rb +2 -2
- data/lib/glue/template.rb +3 -3
- data/lib/glue/uri.rb +2 -2
- data/lib/glue/validation.rb +8 -0
- data/test/glue/builder/tc_xml.rb +7 -7
- data/test/glue/tc_aspects.rb +3 -3
- data/test/glue/tc_stores.rb +17 -0
- data/test/glue/tc_template.rb +1 -1
- data/test/glue/tc_uri.rb +20 -20
- metadata +7 -7
- data/lib/glue/cache/memcache.rb +0 -2
- data/test/glue/multi_validations_model.rb +0 -5
data/ProjectInfo
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
TITLE : &title Glue
|
4
4
|
NAME : &pkg glue
|
5
|
-
VERSION : '0.
|
5
|
+
VERSION : '0.29.0'
|
6
6
|
STATUS : beta
|
7
7
|
|
8
8
|
AUTHOR : George Moschovitis
|
@@ -15,7 +15,7 @@ DESCRIPTION: >
|
|
15
15
|
Utility methods and classes for Nitro.
|
16
16
|
|
17
17
|
DEPENDENCIES:
|
18
|
-
- [ facets, '= 1.0.
|
18
|
+
- [ facets, '= 1.0.3' ]
|
19
19
|
- [ cmdparse, '= 2.0.0' ]
|
20
20
|
|
21
21
|
DISTRIBUTE: [ gem, tgz, zip ]
|
data/README
CHANGED
data/Rakefile
CHANGED
data/doc/RELEASES
CHANGED
data/lib/glue.rb
CHANGED
data/lib/glue/aspects.rb
CHANGED
@@ -7,7 +7,7 @@ module Glue
|
|
7
7
|
class Aspect
|
8
8
|
class << self
|
9
9
|
def wrap(target, methods = target.instance_methods, pre = :pre, post = :post)
|
10
|
-
target.send(:include, Aspects) unless target.ancestors.include?(Aspects)
|
10
|
+
target.send(:include, Glue::Aspects) unless target.ancestors.include?(Glue::Aspects)
|
11
11
|
target.wrap(self, :pre => pre, :post => post)
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ class Aspect
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def wrap(target, methods = target.instance_methods, pre = :pre, post = :post)
|
18
|
-
target.send(:include, Aspects) unless target.ancestors.include?(Aspects)
|
18
|
+
target.send(:include, Glue::Aspects) unless target.ancestors.include?(Glue::Aspects)
|
19
19
|
target.wrap(self, :pre => pre, :post => post)
|
20
20
|
end
|
21
21
|
alias_method :observe, :wrap
|
data/lib/glue/autoreload.rb
CHANGED
@@ -33,11 +33,11 @@ module Kernel
|
|
33
33
|
$autoreload_dirty = true
|
34
34
|
need_reload.each_pair do |file,mtime|
|
35
35
|
file_mtime[file] = mtime
|
36
|
-
|
36
|
+
Logger.debug "File '#{ file }' reloaded"
|
37
37
|
begin
|
38
38
|
load(file)
|
39
39
|
rescue Exception => e
|
40
|
-
|
40
|
+
Logger.info e.inspect
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -48,7 +48,7 @@ module Kernel
|
|
48
48
|
if File.exists?(file) and (mtime = File.stat(file).mtime) > (file_mtime[file] || start_time)
|
49
49
|
$autoreload_dirty = true
|
50
50
|
file_mtime[file] = mtime
|
51
|
-
|
51
|
+
Logger.debug "File '#{ file }' changed"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
data/lib/glue/cache.rb
CHANGED
data/lib/glue/cache/drb.rb
CHANGED
@@ -33,13 +33,18 @@ class DrbCache < MemoryCache
|
|
33
33
|
# :address = The address of the DRb cache object.
|
34
34
|
# :port = The port of the DRb cache object.
|
35
35
|
|
36
|
-
def initialize(options = {})
|
37
|
-
c = {
|
38
|
-
:address => '127.0.0.1',
|
39
|
-
:port => 9080,
|
40
|
-
}.update(options)
|
41
36
|
|
42
|
-
|
37
|
+
# The address of the Session cache / store (if distibuted).
|
38
|
+
|
39
|
+
setting :address, :default => '127.0.0.1', :doc => 'The address of the Session cache'
|
40
|
+
|
41
|
+
# The port of the Session DRb cache / store (if distributed).
|
42
|
+
|
43
|
+
setting :port, :default => 9069, :doc => 'The port of the Session cache'
|
44
|
+
|
45
|
+
|
46
|
+
def initialize
|
47
|
+
@hash = DRbObject.new(nil, "druby://#{DrbCache.address}:#{DrbCache.port}")
|
43
48
|
end
|
44
49
|
|
45
50
|
end
|
data/lib/glue/cache/file.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
+
require 'uri'
|
1
2
|
require 'fileutils'
|
2
3
|
require 'tmpdir'
|
3
4
|
|
4
5
|
module Glue
|
5
6
|
|
6
|
-
# TODO: safe locking of files, because Nitro can be multiprocess
|
7
|
-
|
8
7
|
class FileCache
|
9
8
|
|
10
9
|
setting :basedir, :default => "#{Dir.tmpdir}/nitro_file_cache", :doc => 'The directory to store files'
|
11
10
|
|
12
|
-
def initialize(name, keepalive = nil)
|
11
|
+
def initialize(name = "cache", keepalive = nil)
|
13
12
|
@path = File.join(FileCache.basedir, name)
|
14
13
|
@keepalive = keepalive
|
15
14
|
|
@@ -17,16 +16,23 @@ module Glue
|
|
17
16
|
end
|
18
17
|
|
19
18
|
def []=(k,v)
|
20
|
-
fn = File.join(@path, k.to_s)
|
19
|
+
fn = File.join(@path, escape_filename(k.to_s) )
|
21
20
|
encode_file(fn, v)
|
22
21
|
end
|
22
|
+
alias :set :[]=
|
23
23
|
|
24
24
|
def [](k)
|
25
|
-
fn = File.join(@path, k.to_s)
|
25
|
+
fn = File.join(@path, escape_filename(k.to_s) )
|
26
26
|
return nil unless File.exists?(fn)
|
27
27
|
decode_file(fn)
|
28
28
|
end
|
29
|
+
alias :get :[]
|
29
30
|
|
31
|
+
def delete(k)
|
32
|
+
f = File.join(@path, escape_filename(k.to_s))
|
33
|
+
File.delete(f) if File.exists?(f)
|
34
|
+
end
|
35
|
+
|
30
36
|
def gc!
|
31
37
|
return unless @keepalive
|
32
38
|
|
@@ -44,16 +50,29 @@ module Glue
|
|
44
50
|
private
|
45
51
|
|
46
52
|
def decode_file(fn)
|
47
|
-
|
53
|
+
val = nil
|
54
|
+
File.open(fn,"r") do |f|
|
55
|
+
f.flock(File::LOCK_EX)
|
56
|
+
val = Marshal.load( File.read(fn) )
|
57
|
+
f.flock(File::LOCK_UN)
|
58
|
+
end
|
59
|
+
return val
|
48
60
|
end
|
49
61
|
|
50
62
|
def encode_file(fn, value)
|
51
63
|
File.open(fn, "w") do |f|
|
64
|
+
f.flock(File::LOCK_EX)
|
52
65
|
f.chmod(0600)
|
53
66
|
f.write(Marshal.dump(value))
|
67
|
+
f.flock(File::LOCK_UN)
|
54
68
|
end
|
55
69
|
end
|
56
70
|
|
71
|
+
# need this for fat filesystems
|
72
|
+
def escape_filename(fn)
|
73
|
+
URI.escape(fn, /["\/:;|=,\[\]]/)
|
74
|
+
end
|
75
|
+
|
57
76
|
end
|
58
77
|
end
|
59
78
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# specifications:
|
2
|
+
# http://cvs.danga.com/browse.cgi/wcmtools/memcached/doc/protocol.txt?rev=HEAD&content-type=text/plain
|
3
|
+
#
|
4
|
+
# very simple (= very fast) client for memcached
|
5
|
+
#
|
6
|
+
# i found the Ruby-MemCache library a little bit buggy and complicated, so i made my own before
|
7
|
+
# fixing it ;)
|
8
|
+
#
|
9
|
+
# TODO socket disconnection handling
|
10
|
+
# TODO error handling
|
11
|
+
# TODO multiple servers connections
|
12
|
+
|
13
|
+
require "socket"
|
14
|
+
|
15
|
+
module Glue
|
16
|
+
|
17
|
+
class MemCached
|
18
|
+
|
19
|
+
setting :address, :default => 'localhost', :doc => 'Server address'
|
20
|
+
setting :port, :default => 11211, :doc => 'Server port'
|
21
|
+
|
22
|
+
def initialize(name = "cache", keepalive = nil)
|
23
|
+
@sock = TCPSocket.new(MemCached.address, MemCached.port)
|
24
|
+
@name = name
|
25
|
+
@keepalive = keepalive
|
26
|
+
end
|
27
|
+
|
28
|
+
def []=(k,v)
|
29
|
+
if @keepalive
|
30
|
+
exptime = (Time.now + @keepalive).to_i
|
31
|
+
else
|
32
|
+
exptime = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
data = Marshal.dump(v)
|
36
|
+
@sock.print("set #{@name}:#{k} 0 #{exptime} #{data.size}\r\n#{data}\r\n")
|
37
|
+
response = @sock.gets # "STORED\r\n"
|
38
|
+
v
|
39
|
+
end
|
40
|
+
alias :set :[]=
|
41
|
+
|
42
|
+
def [](k)
|
43
|
+
@sock.print("get #{@name}:#{k}\r\n")
|
44
|
+
resp = @sock.gets
|
45
|
+
if resp == "END\r\n"
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
#dummy, key, flags, size
|
50
|
+
size = resp.split(/ /).last.to_i
|
51
|
+
raw_data = @sock.read(size)
|
52
|
+
@sock.gets # \r\n
|
53
|
+
@sock.gets # END\r\n
|
54
|
+
Marshal.load( raw_data )
|
55
|
+
end
|
56
|
+
alias :get :[]
|
57
|
+
|
58
|
+
def delete(k)
|
59
|
+
@sock.print("delete #{@name}:#{k}\r\n")
|
60
|
+
@sock.gets # "DELETED\r\n"
|
61
|
+
end
|
62
|
+
|
63
|
+
def gc!
|
64
|
+
# garbage collection is handled by the memcache server
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
data/lib/glue/configuration.rb
CHANGED
data/lib/glue/fixture.rb
CHANGED
@@ -93,7 +93,7 @@ class Fixture < Hash
|
|
93
93
|
def parse_yaml(path)
|
94
94
|
require 'yaml'
|
95
95
|
|
96
|
-
str = Template.new.render(File.read(path))
|
96
|
+
str = Glue::Template.new.render(File.read(path))
|
97
97
|
|
98
98
|
if yaml = YAML::load(str)
|
99
99
|
for name, data in yaml
|
@@ -115,7 +115,7 @@ class Fixture < Hash
|
|
115
115
|
def parse_csv(path)
|
116
116
|
require 'csv'
|
117
117
|
|
118
|
-
str = Template.new.render(File.read(path))
|
118
|
+
str = Glue::Template.new.render(File.read(path))
|
119
119
|
|
120
120
|
reader = CSV::Reader.create(str)
|
121
121
|
header = reader.shift
|
data/lib/glue/mailer/outgoing.rb
CHANGED
@@ -9,7 +9,7 @@ module OutgoingMailer
|
|
9
9
|
|
10
10
|
on_included %{ base.extend ClassMethods }
|
11
11
|
|
12
|
-
def initialize(from = nil, to = nil, subject = nil, body = FileTemplate.new)
|
12
|
+
def initialize(from = nil, to = nil, subject = nil, body = Glue::FileTemplate.new)
|
13
13
|
super
|
14
14
|
@charset = Mailer.default_charset.dup
|
15
15
|
@encode_subject = Mailer.encode_subject
|
data/lib/glue/property.rb
CHANGED
@@ -164,7 +164,7 @@ class Property
|
|
164
164
|
if prop_or_rel.on_populate && obj.respond_to?(prop_or_rel.on_populate.to_sym)
|
165
165
|
return obj.send(prop_or_rel.on_populate.to_sym, value)
|
166
166
|
elsif Object.const_defined? :Nitro
|
167
|
-
if control = Nitro::Control.fetch(obj, prop_or_rel, :default => nil) and control.respond_to?(:on_populate)
|
167
|
+
if control = Nitro::Form::Control.fetch(obj, prop_or_rel, :default => nil) and control.respond_to?(:on_populate)
|
168
168
|
return control.on_populate(value)
|
169
169
|
end
|
170
170
|
else
|
@@ -181,7 +181,7 @@ class Property
|
|
181
181
|
self.#{sym} = force_#{sym}(val)
|
182
182
|
else
|
183
183
|
self.#{sym}=(} << case klass.name
|
184
|
-
when Fixnum.name: 'val.
|
184
|
+
when Fixnum.name: 'val.to_s.empty? ? nil : val.to_i'
|
185
185
|
when String.name: 'val.to_s'
|
186
186
|
when Float.name: 'val.to_f'
|
187
187
|
when Time.name: 'val.is_a?(Hash) ? Time.local(val["year"],val["month"],val["day"],val["hour"],val["min"]) : Time.parse(val.to_s)'
|
data/lib/glue/template.rb
CHANGED
@@ -164,14 +164,14 @@ class Template
|
|
164
164
|
setting :strip_xml_comments, :default => false, :doc => 'Strip xml comments from templates?'
|
165
165
|
|
166
166
|
class << self
|
167
|
-
include TemplateMixin
|
167
|
+
include Glue::TemplateMixin
|
168
168
|
alias_method :compile, :compile_template
|
169
169
|
alias_method :transform, :compile_template
|
170
170
|
alias_method :evaluate, :evaluate_template
|
171
171
|
alias_method :process, :process_template
|
172
172
|
end
|
173
173
|
|
174
|
-
include TemplateMixin
|
174
|
+
include Glue::TemplateMixin
|
175
175
|
|
176
176
|
# Helper.
|
177
177
|
|
@@ -188,7 +188,7 @@ end
|
|
188
188
|
# expansion environment.
|
189
189
|
|
190
190
|
class FileTemplate < Flexob
|
191
|
-
include TemplateMixin
|
191
|
+
include Glue::TemplateMixin
|
192
192
|
|
193
193
|
@@compiled_template_cache = {}
|
194
194
|
|
data/lib/glue/uri.rb
CHANGED
@@ -37,7 +37,7 @@ module UriUtils
|
|
37
37
|
|
38
38
|
# real_path = "#{$root_dir}/#{path}"
|
39
39
|
|
40
|
-
parameters = UriUtils.query_string_to_hash(query_string)
|
40
|
+
parameters = Glue::UriUtils.query_string_to_hash(query_string)
|
41
41
|
path.gsub!(/\+/, " ")
|
42
42
|
|
43
43
|
return [path, type, parameters, query_string]
|
@@ -97,7 +97,7 @@ module UriUtils
|
|
97
97
|
# only encode simple classes !
|
98
98
|
|
99
99
|
if value.is_a?(Numeric) or value.is_a?(String)
|
100
|
-
pairs << "#{param}=#{value}"
|
100
|
+
pairs << "#{param}=#{CGI.escape(value.to_s)}"
|
101
101
|
end
|
102
102
|
}
|
103
103
|
return pairs.join(";")
|
data/lib/glue/validation.rb
CHANGED
data/test/glue/builder/tc_xml.rb
CHANGED
@@ -7,7 +7,7 @@ class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all
|
|
7
7
|
include Glue
|
8
8
|
|
9
9
|
def test_string
|
10
|
-
x = XmlBuilder.new
|
10
|
+
x = Glue::XmlBuilder.new
|
11
11
|
|
12
12
|
x.start_tag!('html').
|
13
13
|
start_tag!('title').text!('hello').end_tag!('title').
|
@@ -17,34 +17,34 @@ class TC_BuildersXml < Test::Unit::TestCase # :nodoc: all
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_missing
|
20
|
-
x = XmlBuilder.new
|
20
|
+
x = Glue::XmlBuilder.new
|
21
21
|
x.b('This is bold')
|
22
22
|
assert_equal '<b>This is bold</b>', x.buffer
|
23
23
|
|
24
|
-
x = XmlBuilder.new
|
24
|
+
x = Glue::XmlBuilder.new
|
25
25
|
x.a('Navel', :href => 'http://www.navel.gr')
|
26
26
|
assert_equal '<a href="http://www.navel.gr">Navel</a>', x.buffer
|
27
27
|
|
28
28
|
|
29
|
-
x = XmlBuilder.new
|
29
|
+
x = Glue::XmlBuilder.new
|
30
30
|
x.b {
|
31
31
|
x.i 'Hello', :class =>'new'
|
32
32
|
x.p 'Paragraph'
|
33
33
|
}
|
34
34
|
assert_equal '<b><i class="new">Hello</i><p>Paragraph</p></b>', x.buffer
|
35
35
|
|
36
|
-
x = XmlBuilder.new
|
36
|
+
x = Glue::XmlBuilder.new
|
37
37
|
x.hr
|
38
38
|
assert_equal '<hr />', x.buffer
|
39
39
|
|
40
|
-
x = XmlBuilder.new
|
40
|
+
x = Glue::XmlBuilder.new
|
41
41
|
x.hr(:style => 'height: 1px')
|
42
42
|
assert_equal '<hr style="height: 1px" />', x.buffer
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_xml_builder
|
46
46
|
buffer = ''
|
47
|
-
x = XmlBuilder.new(buffer)
|
47
|
+
x = Glue::XmlBuilder.new(buffer)
|
48
48
|
|
49
49
|
x.start_tag!('html').
|
50
50
|
start_tag!('title').text!('hello').end_tag!('title').
|
data/test/glue/tc_aspects.rb
CHANGED
@@ -24,14 +24,14 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
|
24
24
|
end
|
25
25
|
|
26
26
|
module Tester
|
27
|
-
include Aspects
|
27
|
+
include Glue::Aspects
|
28
28
|
|
29
29
|
attr_accessor :ta
|
30
30
|
pre { |this| this.ta = 5 }
|
31
31
|
end
|
32
32
|
|
33
33
|
class Dummy
|
34
|
-
include Aspects
|
34
|
+
include Glue::Aspects
|
35
35
|
include Tester
|
36
36
|
|
37
37
|
attr_accessor :a, :b, :c
|
@@ -82,7 +82,7 @@ class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
|
|
82
82
|
def test_all
|
83
83
|
Observer.wrap(Dummy, :hello)
|
84
84
|
Epilogue.new.wrap(Dummy, :hello)
|
85
|
-
Aspects.wrap(Dummy, :hello)
|
85
|
+
Glue::Aspects.wrap(Dummy, :hello)
|
86
86
|
|
87
87
|
d = Dummy.new
|
88
88
|
d.hello(3)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require 'glue/cache/memory'
|
6
|
+
|
7
|
+
class TC_CachingStores < Test::Unit::TestCase # :nodoc: all
|
8
|
+
|
9
|
+
def test_memory
|
10
|
+
s = Glue::Cache::MemoryCache.new
|
11
|
+
s.write('test', 'hello', { :none => 1})
|
12
|
+
s.read('test')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
# * George Moschovitis <gm@navel.gr>
|
data/test/glue/tc_template.rb
CHANGED
@@ -23,7 +23,7 @@ class TestTemplate < Test::Unit::TestCase # :nodoc: all
|
|
23
23
|
items = %w{ nitro is really great }
|
24
24
|
out = ''
|
25
25
|
|
26
|
-
Template.process(template, :out, binding)
|
26
|
+
Glue::Template.process(template, :out, binding)
|
27
27
|
|
28
28
|
assert_match %r{\<li\>nitro\</li\>}, out
|
29
29
|
assert_match %r{\<li\>really\</li\>}, out
|
data/test/glue/tc_uri.rb
CHANGED
@@ -11,22 +11,22 @@ class TC_Uri < Test::Unit::TestCase # :nodoc: all
|
|
11
11
|
def test_query_string_to_hash
|
12
12
|
# bad query string
|
13
13
|
|
14
|
-
assert_equal(0, UriUtils.query_string_to_hash("").length)
|
15
|
-
assert_equal(0, UriUtils.query_string_to_hash(nil).length)
|
14
|
+
assert_equal(0, Glue::UriUtils.query_string_to_hash("").length)
|
15
|
+
assert_equal(0, Glue::UriUtils.query_string_to_hash(nil).length)
|
16
16
|
|
17
17
|
# single valued
|
18
18
|
|
19
|
-
parameters = UriUtils.query_string_to_hash("koko=2&lala=3")
|
19
|
+
parameters = Glue::UriUtils.query_string_to_hash("koko=2&lala=3")
|
20
20
|
assert_equal("2", parameters["koko"])
|
21
21
|
assert_equal("3", parameters["lala"])
|
22
22
|
|
23
|
-
parameters = UriUtils.query_string_to_hash("koko=2;lala=3")
|
23
|
+
parameters = Glue::UriUtils.query_string_to_hash("koko=2;lala=3")
|
24
24
|
assert_equal("2", parameters["koko"])
|
25
25
|
assert_equal("3", parameters["lala"])
|
26
26
|
|
27
27
|
# multivalued
|
28
28
|
|
29
|
-
parameters = UriUtils.query_string_to_hash("koko=2;lala=3&koko=5")
|
29
|
+
parameters = Glue::UriUtils.query_string_to_hash("koko=2;lala=3&koko=5")
|
30
30
|
assert_equal(2, parameters["koko"].length)
|
31
31
|
assert_equal("2", parameters["koko"][0])
|
32
32
|
assert_equal("3", parameters["lala"])
|
@@ -39,59 +39,59 @@ class TC_Uri < Test::Unit::TestCase # :nodoc: all
|
|
39
39
|
def test_hash_to_query_string
|
40
40
|
hash = { "koko" => 1, "lala" => 2}
|
41
41
|
qs = "koko=1;lala=2"
|
42
|
-
assert_equal(qs, UriUtils.hash_to_query_string(hash))
|
42
|
+
assert_equal(qs, Glue::UriUtils.hash_to_query_string(hash))
|
43
43
|
|
44
|
-
assert_equal(nil, UriUtils.hash_to_query_string(nil))
|
44
|
+
assert_equal(nil, Glue::UriUtils.hash_to_query_string(nil))
|
45
45
|
|
46
46
|
# bug: dont encode complex objects
|
47
47
|
hash = { "a" => 2, "b" => 3, "c" => Dummy.new }
|
48
48
|
qs = "a=2;b=3"
|
49
|
-
assert_equal(qs, UriUtils.hash_to_query_string(hash))
|
49
|
+
assert_equal(qs, Glue::UriUtils.hash_to_query_string(hash))
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_get_query_string
|
53
53
|
uri = "people/gmosx.sx?koko=1;lala=2"
|
54
|
-
assert_equal("koko=1;lala=2", UriUtils.get_query_string(uri))
|
54
|
+
assert_equal("koko=1;lala=2", Glue::UriUtils.get_query_string(uri))
|
55
55
|
|
56
56
|
uri = "http://www.navel.gr/people/gmosx.sx?koko=1&lala=2"
|
57
|
-
assert_equal("koko=1&lala=2", UriUtils.get_query_string(uri))
|
57
|
+
assert_equal("koko=1&lala=2", Glue::UriUtils.get_query_string(uri))
|
58
58
|
|
59
59
|
uri = "http://www.navel.gr:8080/people/gmosx.sx?koko=1;lala=2"
|
60
|
-
assert_equal("koko=1;lala=2", UriUtils.get_query_string(uri))
|
60
|
+
assert_equal("koko=1;lala=2", Glue::UriUtils.get_query_string(uri))
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_chomp_query_string
|
64
64
|
uri = "people/gmosx.sx"
|
65
|
-
assert_equal("people/gmosx.sx", UriUtils.chomp_query_string(uri))
|
65
|
+
assert_equal("people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
66
66
|
|
67
67
|
uri = "people/gmosx.sx?koko=1;lala=2"
|
68
|
-
assert_equal("people/gmosx.sx", UriUtils.chomp_query_string(uri))
|
68
|
+
assert_equal("people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
69
69
|
|
70
70
|
uri = "http://www.navel.gr/people/gmosx.sx?koko=1&lala=2"
|
71
|
-
assert_equal("http://www.navel.gr/people/gmosx.sx", UriUtils.chomp_query_string(uri))
|
71
|
+
assert_equal("http://www.navel.gr/people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
72
72
|
|
73
73
|
uri = "http://www.navel.gr:8080/people/gmosx.sx?koko=1;lala=2"
|
74
|
-
assert_equal("http://www.navel.gr:8080/people/gmosx.sx", UriUtils.chomp_query_string(uri))
|
74
|
+
assert_equal("http://www.navel.gr:8080/people/gmosx.sx", Glue::UriUtils.chomp_query_string(uri))
|
75
75
|
|
76
|
-
assert_equal(nil, UriUtils.chomp_query_string(nil))
|
76
|
+
assert_equal(nil, Glue::UriUtils.chomp_query_string(nil))
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_update_query_string
|
80
80
|
uri = "ko/index.sx?koko=1"
|
81
81
|
hash = {"lala" => 2, "kaka" => 3}
|
82
|
-
assert_equal("ko/index.sx?koko=1;lala=2;kaka=3", UriUtils.update_query_string(uri, hash))
|
82
|
+
assert_equal("ko/index.sx?koko=1;lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
83
83
|
|
84
84
|
uri = "http://www.navel.gr:8080/ko/index.sx?koko=1"
|
85
85
|
hash = {"lala" => 2, "kaka" => 3}
|
86
|
-
assert_equal("http://www.navel.gr:8080/ko/index.sx?koko=1;lala=2;kaka=3", UriUtils.update_query_string(uri, hash))
|
86
|
+
assert_equal("http://www.navel.gr:8080/ko/index.sx?koko=1;lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
87
87
|
|
88
88
|
uri = "http://www.navel.gr"
|
89
89
|
hash = {"lala" => 2, "kaka" => 3}
|
90
|
-
assert_equal("http://www.navel.gr?lala=2;kaka=3", UriUtils.update_query_string(uri, hash))
|
90
|
+
assert_equal("http://www.navel.gr?lala=2;kaka=3", Glue::UriUtils.update_query_string(uri, hash))
|
91
91
|
|
92
92
|
# bug: no ? when passed an empty hash
|
93
93
|
uri = "http://www.navel.gr"
|
94
|
-
assert_equal("http://www.navel.gr", UriUtils.update_query_string(uri, {}))
|
94
|
+
assert_equal("http://www.navel.gr", Glue::UriUtils.update_query_string(uri, {}))
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: glue
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.29.0
|
7
|
+
date: 2006-03-07 00:00:00 +02:00
|
8
8
|
summary: Utility methods and classes for Nitro.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -15,7 +15,7 @@ description:
|
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
|
-
has_rdoc:
|
18
|
+
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
21
|
- - ">"
|
@@ -59,7 +59,6 @@ files:
|
|
59
59
|
- lib/glue/mail.rb
|
60
60
|
- lib/glue/logger.rb
|
61
61
|
- lib/glue/attribute.rb
|
62
|
-
- lib/glue/paramix.rb
|
63
62
|
- lib/glue/flexob.rb
|
64
63
|
- lib/glue/fixture.rb
|
65
64
|
- lib/glue/builder.rb
|
@@ -68,6 +67,7 @@ files:
|
|
68
67
|
- lib/glue/cache.rb
|
69
68
|
- lib/glue/aspects.rb
|
70
69
|
- lib/glue/markup.rb
|
70
|
+
- lib/glue/paramix.rb
|
71
71
|
- lib/glue/accumulate.rb
|
72
72
|
- lib/glue/autoreload.rb
|
73
73
|
- lib/glue/builder/xml.rb
|
@@ -75,7 +75,7 @@ files:
|
|
75
75
|
- lib/glue/mailer/incoming.rb
|
76
76
|
- lib/glue/cache/file.rb
|
77
77
|
- lib/glue/cache/og.rb
|
78
|
-
- lib/glue/cache/
|
78
|
+
- lib/glue/cache/memcached.rb
|
79
79
|
- lib/glue/cache/memory.rb
|
80
80
|
- lib/glue/cache/drb.rb
|
81
81
|
- lib/html/tokenizer.rb
|
@@ -105,7 +105,7 @@ files:
|
|
105
105
|
- test/glue/tc_builder.rb
|
106
106
|
- test/glue/tc_accumulate.rb
|
107
107
|
- test/glue/tc_aspects.rb
|
108
|
-
- test/glue/
|
108
|
+
- test/glue/tc_stores.rb
|
109
109
|
- test/glue/builder/tc_xml.rb
|
110
110
|
- test/public/dummy_mailer
|
111
111
|
- test/public/dummy_mailer/registration.xhtml
|
@@ -129,7 +129,7 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: 1.0.
|
132
|
+
version: 1.0.3
|
133
133
|
version:
|
134
134
|
- !ruby/object:Gem::Dependency
|
135
135
|
name: cmdparse
|
data/lib/glue/cache/memcache.rb
DELETED