rufus-doric 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +6 -0
- data/Rakefile +28 -17
- data/TODO.txt +2 -1
- data/lib/rufus/doric/model.rb +21 -13
- data/lib/rufus/doric/models.rb +1 -1
- data/lib/rufus/doric/version.rb +1 -1
- data/rufus-doric.gemspec +10 -8
- data/test/ut_19_neutralize_id.rb +34 -0
- data/test/ut_1_model.rb +4 -3
- data/test/ut_20_model_view_by_ignore_case.rb +58 -0
- metadata +9 -7
data/CHANGELOG.txt
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
= rufus-doric CHANGELOG.txt
|
3
3
|
|
4
4
|
|
5
|
+
== rufus-doric - 0.1.15 released 2010/06/22
|
6
|
+
|
7
|
+
- view_by :name, :ignore_case => true
|
8
|
+
- hardened Rufus::Doric.neutralize_id
|
9
|
+
|
10
|
+
|
5
11
|
== rufus-doric - 0.1.14 released 2010/05/22
|
6
12
|
|
7
13
|
- map and now, map and reduce (Model.view_by)
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ require 'rake'
|
|
10
10
|
# CLEAN
|
11
11
|
|
12
12
|
require 'rake/clean'
|
13
|
-
CLEAN.include('pkg', 'tmp', 'html')
|
13
|
+
CLEAN.include('pkg', 'tmp', 'html', 'rdoc')
|
14
14
|
task :default => [ :clean ]
|
15
15
|
|
16
16
|
|
@@ -35,8 +35,8 @@ something at the intersection of Rails3, CouchDB and rufus-jig
|
|
35
35
|
|
36
36
|
gem.test_file = 'test/test.rb'
|
37
37
|
|
38
|
-
gem.add_dependency 'activerecord', '~> 3.0.0.
|
39
|
-
gem.add_dependency 'rufus-jig', '>= 0.1.
|
38
|
+
gem.add_dependency 'activerecord', '~> 3.0.0.beta4'
|
39
|
+
gem.add_dependency 'rufus-jig', '>= 0.1.20'
|
40
40
|
gem.add_dependency 'mime-types', '>= 1.16'
|
41
41
|
gem.add_development_dependency 'rake'
|
42
42
|
gem.add_development_dependency 'yard'
|
@@ -50,29 +50,40 @@ Jeweler::GemcutterTasks.new
|
|
50
50
|
#
|
51
51
|
# DOC
|
52
52
|
|
53
|
-
begin
|
54
|
-
require 'yard'
|
55
|
-
YARD::Rake::YardocTask.new do |doc|
|
56
|
-
doc.options = [
|
57
|
-
'-o', 'html/rufus-doric', '--title',
|
58
|
-
"rufus-doric #{Rufus::Doric::VERSION}"
|
59
|
-
]
|
60
|
-
end
|
61
|
-
rescue LoadError
|
62
|
-
task :yard do
|
63
|
-
abort "YARD is not available : sudo gem install yard"
|
64
|
-
end
|
53
|
+
#begin
|
54
|
+
# require 'yard'
|
55
|
+
# YARD::Rake::YardocTask.new do |doc|
|
56
|
+
# doc.options = [
|
57
|
+
# '-o', 'html/rufus-doric', '--title',
|
58
|
+
# "rufus-doric #{Rufus::Doric::VERSION}"
|
59
|
+
# ]
|
60
|
+
# end
|
61
|
+
#rescue LoadError
|
62
|
+
# task :yard do
|
63
|
+
# abort "YARD is not available : sudo gem install yard"
|
64
|
+
# end
|
65
|
+
#end
|
66
|
+
|
67
|
+
#
|
68
|
+
# make sure to have rdoc 2.5.x to run that
|
69
|
+
#
|
70
|
+
require 'rake/rdoctask'
|
71
|
+
Rake::RDocTask.new do |rd|
|
72
|
+
rd.main = 'README.rdoc'
|
73
|
+
rd.rdoc_dir = 'rdoc/rufus-doric'
|
74
|
+
rd.rdoc_files.include('README.rdoc', 'CHANGELOG.txt', 'lib/**/*.rb')
|
75
|
+
rd.title = "rufus-doric #{Rufus::Doric::VERSION}"
|
65
76
|
end
|
66
77
|
|
67
78
|
|
68
79
|
#
|
69
80
|
# TO THE WEB
|
70
81
|
|
71
|
-
task :upload_website => [ :clean, :
|
82
|
+
task :upload_website => [ :clean, :rdoc ] do
|
72
83
|
|
73
84
|
account = 'jmettraux@rubyforge.org'
|
74
85
|
webdir = '/var/www/gforge-projects/rufus'
|
75
86
|
|
76
|
-
sh "rsync -azv -e ssh
|
87
|
+
sh "rsync -azv -e ssh rdoc/rufus-doric #{account}:#{webdir}/"
|
77
88
|
end
|
78
89
|
|
data/TODO.txt
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
[o] eventually : pagination for the text index
|
9
9
|
[o] view_by 'name', %{ emit(doc.nada) }
|
10
10
|
[o] start and end key should be by_x(:start => a, :end => b)
|
11
|
+
[o] credit Claudio
|
11
12
|
|
12
13
|
[x] lsof check (jig / patron)
|
13
14
|
|
@@ -15,5 +16,5 @@
|
|
15
16
|
|
16
17
|
[ ] view_by 'x', 'emit' ==> view 'x', 'emit' ==> Model.x(key)...
|
17
18
|
|
18
|
-
[ ]
|
19
|
+
[ ] case-insentive index (Claudio)
|
19
20
|
|
data/lib/rufus/doric/model.rb
CHANGED
@@ -162,6 +162,13 @@ module Doric
|
|
162
162
|
#
|
163
163
|
def self.view_by (key, map=nil, reduce=nil)
|
164
164
|
|
165
|
+
ignore_case = false
|
166
|
+
|
167
|
+
if map && map.is_a?(Hash)
|
168
|
+
ignore_case = map[:ignore_case]
|
169
|
+
map = nil
|
170
|
+
end
|
171
|
+
|
165
172
|
if map
|
166
173
|
|
167
174
|
k = { :view => key, :map => map, :reduce => reduce }
|
@@ -181,6 +188,7 @@ module Doric
|
|
181
188
|
|
182
189
|
instance_eval %{
|
183
190
|
def by_#{skey} (val, opts={})
|
191
|
+
opts = opts.merge(:ignore_case => #{ignore_case})
|
184
192
|
by(#{key.inspect}, val, opts)
|
185
193
|
end
|
186
194
|
}
|
@@ -560,7 +568,7 @@ module Doric
|
|
560
568
|
path = "#{design_path}/_view/text_index"
|
561
569
|
path = "#{path}?key=%22#{key}%22" if key
|
562
570
|
|
563
|
-
m = get_result(path, :text_index)
|
571
|
+
m = get_result(path, :text_index, {})
|
564
572
|
|
565
573
|
m = m['rows'].inject({}) { |h, r| (h[r['key']] ||= []) << r['id']; h }
|
566
574
|
|
@@ -599,7 +607,7 @@ module Doric
|
|
599
607
|
end
|
600
608
|
end
|
601
609
|
|
602
|
-
def self.put_design_doc (key
|
610
|
+
def self.put_design_doc (key, opts)
|
603
611
|
|
604
612
|
# the 'all' view
|
605
613
|
|
@@ -651,17 +659,17 @@ module Doric
|
|
651
659
|
keys = key.collect { |k| "doc['#{k}']" }.join(', ')
|
652
660
|
|
653
661
|
ddoc['views']["by_#{skey}"] = {
|
654
|
-
'map' => func(
|
655
|
-
emit([#{keys}], null);
|
656
|
-
})
|
662
|
+
'map' => func("emit([#{keys}], null);")
|
657
663
|
}
|
658
664
|
|
659
665
|
else
|
660
666
|
|
667
|
+
emit = opts[:ignore_case] ?
|
668
|
+
"emit(doc['#{key}'].toLowerCase(), null);" :
|
669
|
+
"emit(doc['#{key}'], null);"
|
670
|
+
|
661
671
|
ddoc['views']["by_#{key}"] = {
|
662
|
-
'map' => func(
|
663
|
-
emit(doc['#{key}'], null);
|
664
|
-
})
|
672
|
+
'map' => func(emit)
|
665
673
|
}
|
666
674
|
end
|
667
675
|
|
@@ -692,7 +700,7 @@ module Doric
|
|
692
700
|
|
693
701
|
path = "_design/doric/_view/by_doric_type?#{qs.join('&')}"
|
694
702
|
|
695
|
-
result = get_result(path)
|
703
|
+
result = get_result(path, nil, opts)
|
696
704
|
|
697
705
|
result['rows'].collect { |r| r['doc'] }
|
698
706
|
end
|
@@ -739,7 +747,7 @@ module Doric
|
|
739
747
|
|
740
748
|
path = "#{design_path}/_view/by_#{skey}?#{qs.join('&')}"
|
741
749
|
|
742
|
-
result = get_result(path, key)
|
750
|
+
result = get_result(path, key, opts)
|
743
751
|
|
744
752
|
row = result['rows']
|
745
753
|
|
@@ -757,7 +765,7 @@ module Doric
|
|
757
765
|
# Will raise if the design_doc can't be inserted (probably the underlying
|
758
766
|
# db is missing).
|
759
767
|
#
|
760
|
-
def self.get_result (path, design_doc_key
|
768
|
+
def self.get_result (path, design_doc_key, opts)
|
761
769
|
|
762
770
|
result = db.get(path)
|
763
771
|
|
@@ -765,7 +773,7 @@ module Doric
|
|
765
773
|
|
766
774
|
# insert design doc
|
767
775
|
|
768
|
-
r = put_design_doc(design_doc_key)
|
776
|
+
r = put_design_doc(design_doc_key, opts)
|
769
777
|
|
770
778
|
raise(
|
771
779
|
"failed to insert 'any' design_doc in db '#{db.name}'"
|
@@ -773,7 +781,7 @@ module Doric
|
|
773
781
|
|
774
782
|
# re-get
|
775
783
|
|
776
|
-
get_result(path, design_doc_key)
|
784
|
+
get_result(path, design_doc_key, opts)
|
777
785
|
end
|
778
786
|
end
|
779
787
|
end
|
data/lib/rufus/doric/models.rb
CHANGED
data/lib/rufus/doric/version.rb
CHANGED
data/rufus-doric.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rufus-doric}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.15"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["John Mettraux"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-06-22}
|
13
13
|
s.description = %q{
|
14
14
|
something at the intersection of Rails3, CouchDB and rufus-jig
|
15
15
|
}
|
@@ -56,7 +56,9 @@ something at the intersection of Rails3, CouchDB and rufus-jig
|
|
56
56
|
"test/ut_16_model_custom_view.rb",
|
57
57
|
"test/ut_17_model_and_attachments.rb",
|
58
58
|
"test/ut_18_model_map_reduce.rb",
|
59
|
+
"test/ut_19_neutralize_id.rb",
|
59
60
|
"test/ut_1_model.rb",
|
61
|
+
"test/ut_20_model_view_by_ignore_case.rb",
|
60
62
|
"test/ut_2_model_view.rb",
|
61
63
|
"test/ut_3_model_lint.rb",
|
62
64
|
"test/ut_4_one_doc_model.rb",
|
@@ -81,23 +83,23 @@ something at the intersection of Rails3, CouchDB and rufus-jig
|
|
81
83
|
s.specification_version = 3
|
82
84
|
|
83
85
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
84
|
-
s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.0.
|
85
|
-
s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.
|
86
|
+
s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.0.beta4"])
|
87
|
+
s.add_runtime_dependency(%q<rufus-jig>, [">= 0.1.20"])
|
86
88
|
s.add_runtime_dependency(%q<mime-types>, [">= 1.16"])
|
87
89
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
88
90
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
89
91
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
90
92
|
else
|
91
|
-
s.add_dependency(%q<activerecord>, ["~> 3.0.0.
|
92
|
-
s.add_dependency(%q<rufus-jig>, [">= 0.1.
|
93
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta4"])
|
94
|
+
s.add_dependency(%q<rufus-jig>, [">= 0.1.20"])
|
93
95
|
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
94
96
|
s.add_dependency(%q<rake>, [">= 0"])
|
95
97
|
s.add_dependency(%q<yard>, [">= 0"])
|
96
98
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
97
99
|
end
|
98
100
|
else
|
99
|
-
s.add_dependency(%q<activerecord>, ["~> 3.0.0.
|
100
|
-
s.add_dependency(%q<rufus-jig>, [">= 0.1.
|
101
|
+
s.add_dependency(%q<activerecord>, ["~> 3.0.0.beta4"])
|
102
|
+
s.add_dependency(%q<rufus-jig>, [">= 0.1.20"])
|
101
103
|
s.add_dependency(%q<mime-types>, [">= 1.16"])
|
102
104
|
s.add_dependency(%q<rake>, [">= 0"])
|
103
105
|
s.add_dependency(%q<yard>, [">= 0"])
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
#
|
4
|
+
# testing rufus-doric
|
5
|
+
#
|
6
|
+
# Mon Jun 21 11:09:39 JST 2010
|
7
|
+
#
|
8
|
+
|
9
|
+
require File.join(File.dirname(__FILE__), 'base')
|
10
|
+
|
11
|
+
require 'rufus/doric'
|
12
|
+
|
13
|
+
|
14
|
+
class UtNeutralizeTest < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def test_quotes
|
17
|
+
|
18
|
+
assert_equal "_hogehoge__foo", n('"hogehoge" foo')
|
19
|
+
assert_equal "X'ian", n("X'ian")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_utf8
|
23
|
+
|
24
|
+
assert_equal "横浜", n("横浜")
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def n (s)
|
30
|
+
|
31
|
+
Rufus::Doric.neutralize_id(s)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/test/ut_1_model.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
|
2
3
|
#
|
3
4
|
# testing rufus-doric
|
@@ -210,9 +211,9 @@ class UtModelTest < Test::Unit::TestCase
|
|
210
211
|
|
211
212
|
Thing.new('name' => "Xi'an").save!
|
212
213
|
assert_not_nil Thing.find("Xi'an")
|
213
|
-
|
214
|
-
|
215
|
-
|
214
|
+
|
215
|
+
Thing.new('name' => '横浜').save!
|
216
|
+
assert_not_nil Thing.find('横浜')
|
216
217
|
end
|
217
218
|
end
|
218
219
|
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing rufus-doric
|
4
|
+
#
|
5
|
+
# Tue Jun 22 15:07:22 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
require 'rufus/doric'
|
11
|
+
|
12
|
+
|
13
|
+
class Handkerchief < Rufus::Doric::Model
|
14
|
+
|
15
|
+
db :doric
|
16
|
+
doric_type :handkerchief
|
17
|
+
|
18
|
+
_id_field { [ brand, colour, owner ].join('_').downcase }
|
19
|
+
h_accessor :brand
|
20
|
+
h_accessor :colour
|
21
|
+
h_accessor :owner
|
22
|
+
|
23
|
+
view_by :owner, :ignore_case => true
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
class UtModelViewTest < Test::Unit::TestCase
|
28
|
+
|
29
|
+
def setup
|
30
|
+
|
31
|
+
Rufus::Doric.db('doric').delete('.')
|
32
|
+
Rufus::Doric.db('doric').put('.')
|
33
|
+
|
34
|
+
Rufus::Doric.db('doric').http.cache.clear
|
35
|
+
# CouchDB feeds the same etags for views, even after a db has
|
36
|
+
# been deleted and put back, so have to do that 'forgetting'
|
37
|
+
end
|
38
|
+
|
39
|
+
#def teardown
|
40
|
+
#end
|
41
|
+
|
42
|
+
def test_view_by_owner
|
43
|
+
|
44
|
+
Handkerchief.new(
|
45
|
+
:brand => 'valentino', :colour => 'blue', :owner => 'Pepe'
|
46
|
+
).save!
|
47
|
+
Handkerchief.new(
|
48
|
+
:brand => 'lv', :colour => 'brown', :owner => 'Jefe'
|
49
|
+
).save!
|
50
|
+
Handkerchief.new(
|
51
|
+
:brand => 'chanel', :colour => 'b&w', :owner => 'jefe'
|
52
|
+
).save!
|
53
|
+
|
54
|
+
assert_equal 1, Handkerchief.by_owner('pepe').size
|
55
|
+
assert_equal 2, Handkerchief.by_owner('jefe').size
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 15
|
9
|
+
version: 0.1.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- John Mettraux
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-22 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
- 3
|
29
29
|
- 0
|
30
30
|
- 0
|
31
|
-
-
|
32
|
-
version: 3.0.0.
|
31
|
+
- beta4
|
32
|
+
version: 3.0.0.beta4
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -42,8 +42,8 @@ dependencies:
|
|
42
42
|
segments:
|
43
43
|
- 0
|
44
44
|
- 1
|
45
|
-
-
|
46
|
-
version: 0.1.
|
45
|
+
- 20
|
46
|
+
version: 0.1.20
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -143,7 +143,9 @@ files:
|
|
143
143
|
- test/ut_16_model_custom_view.rb
|
144
144
|
- test/ut_17_model_and_attachments.rb
|
145
145
|
- test/ut_18_model_map_reduce.rb
|
146
|
+
- test/ut_19_neutralize_id.rb
|
146
147
|
- test/ut_1_model.rb
|
148
|
+
- test/ut_20_model_view_by_ignore_case.rb
|
147
149
|
- test/ut_2_model_view.rb
|
148
150
|
- test/ut_3_model_lint.rb
|
149
151
|
- test/ut_4_one_doc_model.rb
|