rufus-doric 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ {
2
+ "_id": "users",
3
+ "users": {
4
+ "jami":{
5
+ "_id": "jami",
6
+ "password": "$2a$10$KdnI66AMv.icKaDqDcpy/uf8gMpuZRZNoYZA0txXftsU/MQDJA2.u"
7
+ },
8
+ "john":{
9
+ "_id": "john",
10
+ "password": "$2a$10$t8hGTRTPKU1sm2hhDxqFa.moEBrvH2O3ZQazoq4YsC/AKvoTJSIwy"
11
+ },
12
+ "justin":{
13
+ "_id": "justin",
14
+ "password": "$2a$10$iXQONFk5WsrtD69YqtWO1.oWfDFjJ37AjNIuA7yGwe/YbGhR./eRq",
15
+ "locale": "ja"
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "_id": "wi!0_1!!20100224-alfafa",
3
+ "fei": {
4
+ "engine_id": "engine",
5
+ "expid": "0_1",
6
+ "wfid": "20100224-alfafa"
7
+ },
8
+ "fields": {
9
+ "user": null,
10
+ "misc": "hello",
11
+ "params": {
12
+ "ref": "tester",
13
+ "task": "test board"
14
+ }
15
+ },
16
+ "participant_name": "testers"
17
+ }
data/test/test.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ Dir[File.join(File.dirname(__FILE__), 'ut_*.rb')].each { |pa| load(pa) }
3
+
@@ -0,0 +1,63 @@
1
+
2
+ #
3
+ # testing rufus-doric
4
+ #
5
+ # Wed Mar 17 10:34:05 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+ require 'rufus/doric/fixtures'
11
+
12
+
13
+ class UtFixturesTest < Test::Unit::TestCase
14
+
15
+ #def setup
16
+ #end
17
+ def teardown
18
+ couch = Rufus::Jig::Couch.new(Rufus::Doric::Couch.url)
19
+ couch.delete('doric_test')
20
+ couch.delete('doric_nada')
21
+ couch.delete('doric')
22
+ couch.close
23
+ end
24
+
25
+ def test_load
26
+
27
+ Rufus::Doric::Fixtures.load(
28
+ Rufus::Doric::Couch.url, 'test/fixtures/test',
29
+ :purge => true,
30
+ :verbose => false)
31
+
32
+ img = Rufus::Doric::Couch.db('doric').get('users/john.jpg')
33
+
34
+ assert_not_nil img
35
+ end
36
+
37
+ def test_env_option
38
+
39
+ Rufus::Doric::Fixtures.load(
40
+ Rufus::Doric::Couch.url, 'test/fixtures/test',
41
+ :env => 'nada',
42
+ :purge => true,
43
+ :verbose => false)
44
+
45
+ img = Rufus::Doric::Couch.db('doric', :env => 'nada').get('users/john.jpg')
46
+
47
+ assert_not_nil img
48
+ end
49
+
50
+ def test_absolute_option
51
+
52
+ Rufus::Doric::Fixtures.load(
53
+ Rufus::Doric::Couch.url, 'test/fixtures/test',
54
+ :db => 'doric',
55
+ :purge => true,
56
+ :verbose => false)
57
+
58
+ img = Rufus::Doric::Couch.db('doric', :absolute => true).get('users/john.jpg')
59
+
60
+ assert_not_nil img
61
+ end
62
+ end
63
+
@@ -0,0 +1,133 @@
1
+
2
+ #
3
+ # testing rufus-doric
4
+ #
5
+ # Wed Mar 17 12:21:18 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+ require 'rufus/doric'
11
+
12
+
13
+ class Thing < Rufus::Doric::Model
14
+
15
+ db :doric
16
+
17
+ doric_type :things
18
+ _id_field :name
19
+ h_accessor :name
20
+ end
21
+
22
+ class Item < Rufus::Doric::Model
23
+
24
+ db :doric
25
+
26
+ doric_type :items
27
+
28
+ _id_field :name
29
+ h_accessor :name
30
+ h_accessor :supplier
31
+
32
+ validates :supplier, :presence => true
33
+ end
34
+
35
+
36
+ class UtModelTest < Test::Unit::TestCase
37
+
38
+ def setup
39
+ Rufus::Doric::Couch.db('doric').delete('.')
40
+ Rufus::Doric::Couch.db('doric').put('.')
41
+ end
42
+ #def teardown
43
+ #end
44
+
45
+ def test_save
46
+
47
+ Thing.new(
48
+ 'name' => 'toto'
49
+ ).save!
50
+
51
+ assert_equal 1, Thing.all.size
52
+ assert_equal 'toto', Thing.all.first._id
53
+ end
54
+
55
+ def test_failing_save
56
+
57
+ Thing.new(
58
+ 'name' => 'toto'
59
+ ).save!
60
+
61
+ assert_raise Rufus::Doric::SaveFailed do
62
+ Thing.new(
63
+ 'name' => 'toto'
64
+ ).save!
65
+ end
66
+ end
67
+
68
+ def test_copy
69
+
70
+ Thing.new(
71
+ 'name' => 'toto'
72
+ ).save!
73
+
74
+ t = Thing.all.first
75
+
76
+ assert_not_nil t._id
77
+
78
+ c = t.copy
79
+
80
+ assert_nil c._id
81
+ assert_nil c._rev
82
+ assert_equal Thing, c.class
83
+ end
84
+
85
+ def test_validation
86
+
87
+ assert_raise ActiveRecord::RecordInvalid do
88
+ Item.new('name' => 'pasokon').save!
89
+ end
90
+ end
91
+
92
+ def test_delete
93
+
94
+ Thing.new('name' => 'song_celine').save!
95
+
96
+ assert_equal 1, Thing.all.size
97
+
98
+ t = Thing.all.first
99
+
100
+ t.delete
101
+
102
+ assert_equal 0, Thing.all.size
103
+ assert_equal true, t.destroyed?
104
+ end
105
+
106
+ def test_not_found
107
+
108
+ assert_raise Rufus::Doric::NotFound do
109
+ Thing.find('nada')
110
+ end
111
+ end
112
+
113
+ def test_destroy_all
114
+
115
+ Thing.new('name' => 'flamenco').save!
116
+
117
+ assert_equal 1, Thing.all.size
118
+
119
+ Thing.destroy_all
120
+
121
+ assert_equal 0, Thing.all.size
122
+ end
123
+
124
+ def test_putting_in_missing_db
125
+
126
+ Rufus::Doric::Couch.db('doric').delete('.')
127
+
128
+ assert_raise Rufus::Doric::SaveFailed do
129
+ Thing.new('name' => 'flamenco').save!
130
+ end
131
+ end
132
+ end
133
+
@@ -0,0 +1,59 @@
1
+
2
+ #
3
+ # testing rufus-doric
4
+ #
5
+ # Wed Mar 17 14:27:30 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+ require 'rufus/doric'
11
+
12
+
13
+ module Nada
14
+ class Thing < Rufus::Doric::Model
15
+
16
+ db :doric
17
+ doric_type :things
18
+
19
+ _id_field :name
20
+ h_accessor :name
21
+ h_accessor :colour
22
+
23
+ view_by :colour
24
+ end
25
+ end
26
+
27
+
28
+ class UtModelTest < Test::Unit::TestCase
29
+
30
+ def setup
31
+ Rufus::Doric::Couch.db('doric').delete('.')
32
+ Rufus::Doric::Couch.db('doric').put('.')
33
+ end
34
+ #def teardown
35
+ #end
36
+
37
+ def test_view_by_colour
38
+
39
+ Nada::Thing.new(
40
+ 'name' => 'toto',
41
+ 'colour' => 'blue'
42
+ ).save!
43
+ Nada::Thing.new(
44
+ 'name' => 'alfred',
45
+ 'colour' => 'red'
46
+ ).save!
47
+ Nada::Thing.new(
48
+ 'name' => 'ivan',
49
+ 'colour' => 'red'
50
+ ).save!
51
+
52
+ assert_equal 3, Nada::Thing.all.size
53
+ assert_equal 1, Nada::Thing.by_colour('blue').size
54
+ assert_equal 2, Nada::Thing.by_colour('red').size
55
+
56
+ assert_not_nil Nada::Thing.db.get('_design/doric_nada__thing')
57
+ end
58
+ end
59
+
@@ -0,0 +1,27 @@
1
+
2
+ #
3
+ # testing rufus-doric
4
+ #
5
+ # Wed Mar 17 15:14:33 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+
11
+ class Item < Rufus::Doric::Model
12
+ doric_type :items
13
+ _id_field :name
14
+ h_accessor :name
15
+ end
16
+
17
+
18
+ class UtLintModelTest < Test::Unit::TestCase
19
+ include ActiveModel::Lint::Tests
20
+
21
+ def setup
22
+ @model = Item.new
23
+ end
24
+ #def teardown
25
+ #end
26
+ end
27
+
@@ -0,0 +1,86 @@
1
+
2
+ #
3
+ # testing rufus-doric
4
+ #
5
+ # Wed Mar 17 15:53:49 JST 2010
6
+ #
7
+
8
+ require File.join(File.dirname(__FILE__), 'base')
9
+
10
+ require 'rufus/doric'
11
+
12
+
13
+ class User < Rufus::Doric::OneDocModel
14
+
15
+ doc_id :users
16
+ db :doric
17
+
18
+ h_accessor :password
19
+ h_accessor :roles
20
+ h_accessor :locale
21
+
22
+ validates :password, :presence => true
23
+ end
24
+
25
+
26
+ class UtOneDocModelTest < Test::Unit::TestCase
27
+
28
+ def setup
29
+
30
+ Rufus::Doric::Couch.db('doric').delete('.')
31
+ Rufus::Doric::Couch.db('doric').put('.')
32
+
33
+ users = Rufus::Json.decode(File.read(File.join(
34
+ File.dirname(__FILE__), 'fixtures', 'test', 'doric', 'users.json')))
35
+
36
+ Rufus::Doric::Couch.db('doric').put(users)
37
+ end
38
+
39
+ #def teardown
40
+ #end
41
+
42
+ def test_all
43
+
44
+ assert_equal %w[ jami john justin ], User.all.collect { |u| u._id }.sort
45
+ end
46
+
47
+ def test_find
48
+
49
+ assert_equal(
50
+ { "_id" => "john", "password" => "$2a$10$t8hGTRTPKU1sm2hhDxqFa.moEBrvH2O3ZQazoq4YsC/AKvoTJSIwy" },
51
+ User.find('john').h)
52
+ end
53
+
54
+ def test_save
55
+
56
+ assert_equal 3, User.all.size
57
+
58
+ User.new('_id' => 'james', 'password' => 'nada').save!
59
+
60
+ assert_equal(
61
+ %w[ james jami john justin ],
62
+ User.all.collect { |u| u._id }.sort)
63
+ end
64
+
65
+ def test_validation
66
+
67
+ assert_raise ActiveRecord::RecordInvalid do
68
+ User.new('_id' => 'jeff').save!
69
+ end
70
+ end
71
+
72
+ def test_delete
73
+
74
+ User.find('john').delete
75
+
76
+ assert_equal %w[ jami justin ], User.all.collect { |u| u._id }.sort
77
+ end
78
+
79
+ def test_destroy_all
80
+
81
+ User.destroy_all
82
+
83
+ assert_equal [], User.all
84
+ end
85
+ end
86
+
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rufus-doric
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - John Mettraux
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-17 00:00:00 +09:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: activerecord
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 0
30
+ - 0
31
+ - beta
32
+ version: 3.0.0.beta
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rufus-jig
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 1
45
+ - 16
46
+ version: 0.1.16
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: mime-types
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 16
59
+ version: "1.16"
60
+ type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ type: :development
73
+ version_requirements: *id004
74
+ - !ruby/object:Gem::Dependency
75
+ name: yard
76
+ prerelease: false
77
+ requirement: &id005 !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ type: :development
85
+ version_requirements: *id005
86
+ - !ruby/object:Gem::Dependency
87
+ name: jeweler
88
+ prerelease: false
89
+ requirement: &id006 !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ type: :development
97
+ version_requirements: *id006
98
+ description: "\n\
99
+ something at the intersection of Rails3, CouchDB and rufus-jig\n "
100
+ email: jmettraux@gmail.com
101
+ executables: []
102
+
103
+ extensions: []
104
+
105
+ extra_rdoc_files:
106
+ - LICENSE.txt
107
+ - README.rdoc
108
+ files:
109
+ - CHANGELOG.txt
110
+ - LICENSE.txt
111
+ - README.rdoc
112
+ - Rakefile
113
+ - TODO.txt
114
+ - lib/rufus-doric.rb
115
+ - lib/rufus/doric.rb
116
+ - lib/rufus/doric/couch.rb
117
+ - lib/rufus/doric/fixtures.rb
118
+ - lib/rufus/doric/model.rb
119
+ - lib/rufus/doric/models.rb
120
+ - lib/rufus/doric/one_doc_model.rb
121
+ - lib/rufus/doric/version.rb
122
+ - rufus-doric.gemspec
123
+ - test/base.rb
124
+ - test/fixtures/test/doric/69247b__picture.jpg
125
+ - test/fixtures/test/doric/69249__picture.jpg
126
+ - test/fixtures/test/doric/product0.json
127
+ - test/fixtures/test/doric/product1.json
128
+ - test/fixtures/test/doric/users.json
129
+ - test/fixtures/test/doric/users__jami.png
130
+ - test/fixtures/test/doric/users__john.jpg
131
+ - test/fixtures/test/doric_ENV_workitems/workitem0.json
132
+ - test/test.rb
133
+ - test/ut_0_fixtures.rb
134
+ - test/ut_1_model.rb
135
+ - test/ut_2_model_view.rb
136
+ - test/ut_3_model_lint.rb
137
+ - test/ut_4_one_doc_model.rb
138
+ has_rdoc: true
139
+ homepage: http://github.com/jmettraux/rufus-doric/
140
+ licenses: []
141
+
142
+ post_install_message:
143
+ rdoc_options:
144
+ - --charset=UTF-8
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ segments:
159
+ - 0
160
+ version: "0"
161
+ requirements: []
162
+
163
+ rubyforge_project: rufus
164
+ rubygems_version: 1.3.6
165
+ signing_key:
166
+ specification_version: 3
167
+ summary: something at the intersection of Rails3, CouchDB and rufus-jig
168
+ test_files:
169
+ - test/test.rb