yeti 0.3.13 → 0.3.14
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.
- checksums.yaml +7 -0
- data/lib/yeti/editor.rb +9 -1
- data/lib/yeti/version.rb +1 -1
- data/spec/support/matchers.rb +1 -1
- data/spec/yeti/context_spec.rb +4 -4
- data/spec/yeti/editor_spec.rb +22 -22
- data/spec/yeti/search_spec.rb +9 -9
- data/spec/yeti/viewer_spec.rb +7 -7
- data/spec/yeti_spec.rb +1 -1
- metadata +20 -36
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 145a74cad12c6112a80a599647cf928007430f08
|
4
|
+
data.tar.gz: 4121ad4c8a7dbddb0f839740f9ccb0441acd0e07
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8f4c71f9d98231a3878b54db2706e258faf39a22d3d827672a60ca31b136fa55a1be879963a1bbcbe90f13a0330317b66a04003197fb009b16e0373b8bdcfe2
|
7
|
+
data.tar.gz: 433275a0ad3e8ff1ca689a49f58dbce2e7df34f93e707c4b88d5625a65d7d46b7b67e8d0c7b3c3b5173e2e349777656671889f869b9e0373774ceff3793c229d
|
data/lib/yeti/editor.rb
CHANGED
@@ -111,6 +111,14 @@ module Yeti
|
|
111
111
|
|
112
112
|
private
|
113
113
|
|
114
|
+
def self.accessor_module
|
115
|
+
unless const_defined? "AccessorMethods"
|
116
|
+
accessor_module = const_set "AccessorMethods", Module.new
|
117
|
+
include accessor_module
|
118
|
+
end
|
119
|
+
const_get "AccessorMethods"
|
120
|
+
end
|
121
|
+
|
114
122
|
def self.attribute(name, opts={})
|
115
123
|
opts[:attribute_name] = name
|
116
124
|
opts[:from] = :edited unless opts.has_key? :from
|
@@ -126,7 +134,7 @@ module Yeti
|
|
126
134
|
else
|
127
135
|
"#{opts[:from]}.#{name}"
|
128
136
|
end
|
129
|
-
|
137
|
+
accessor_module.module_eval """
|
130
138
|
def #{name}
|
131
139
|
unless defined? @#{name}
|
132
140
|
opts = self.class.attribute_options[:#{name}]
|
data/lib/yeti/version.rb
CHANGED
data/spec/support/matchers.rb
CHANGED
@@ -2,7 +2,7 @@ RSpec::Matchers.define :delegates do |delegated_method|
|
|
2
2
|
match do |subject|
|
3
3
|
stubbed = send(@delegate).stub(@delegate_method)
|
4
4
|
stubbed.with @delegate_params if @delegate_params
|
5
|
-
stubbed.and_return expected=
|
5
|
+
stubbed.and_return expected=double
|
6
6
|
subject.send(delegated_method) === expected
|
7
7
|
end
|
8
8
|
|
data/spec/yeti/context_spec.rb
CHANGED
@@ -30,16 +30,16 @@ describe Yeti::Context do
|
|
30
30
|
context "when account_id" do
|
31
31
|
subject{ Yeti::Context.new account_id: 1 }
|
32
32
|
it "uses find_account_by_id to find account" do
|
33
|
-
subject.stub(:find_account_by_id).with(1).and_return(expected =
|
33
|
+
subject.stub(:find_account_by_id).with(1).and_return(expected = double)
|
34
34
|
subject.account.should be expected
|
35
35
|
end
|
36
36
|
it "#find_account_by_id is virtual" do
|
37
|
-
|
37
|
+
expect do
|
38
38
|
subject.find_account_by_id 1
|
39
|
-
end.
|
39
|
+
end.to raise_error NotImplementedError
|
40
40
|
end
|
41
41
|
it "#account_id returns account.id" do
|
42
|
-
subject.stub(:find_account_by_id).with(1).and_return
|
42
|
+
subject.stub(:find_account_by_id).with(1).and_return double(id: 2)
|
43
43
|
subject.account_id.should be 2
|
44
44
|
end
|
45
45
|
end
|
data/spec/yeti/editor_spec.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe ::Yeti::Editor do
|
4
|
-
let(:context){
|
4
|
+
let(:context){ double :context }
|
5
5
|
subject{ described_class.new context }
|
6
6
|
it ".new_object is virtual" do
|
7
|
-
|
7
|
+
expect do
|
8
8
|
described_class.new_object context
|
9
|
-
end.
|
9
|
+
end.to raise_error NotImplementedError, "Yeti::Editor.new_object"
|
10
10
|
end
|
11
11
|
it ".find_by_id is virtual" do
|
12
|
-
|
12
|
+
expect do
|
13
13
|
described_class.find_by_id context, 1
|
14
|
-
end.
|
14
|
+
end.to raise_error NotImplementedError, "Yeti::Editor.find_by_id"
|
15
15
|
end
|
16
16
|
describe "initialization" do
|
17
|
-
let(:new_object){
|
18
|
-
let(:existing_object){
|
17
|
+
let(:new_object){ double :new_object }
|
18
|
+
let(:existing_object){ double :existing_object }
|
19
19
|
context "with context only" do
|
20
20
|
before{ described_class.stub(:new_object).with(context).and_return new_object }
|
21
21
|
it "keeps given context" do
|
22
22
|
subject.context.should be context
|
23
23
|
end
|
24
24
|
it "#persist! is virtual" do
|
25
|
-
|
25
|
+
expect do
|
26
26
|
subject.persist!
|
27
|
-
end.
|
27
|
+
end.to raise_error NotImplementedError, "Yeti::Editor#persist!"
|
28
28
|
end
|
29
29
|
it "uses .new_object to initialize edited object" do
|
30
30
|
subject.edited.should == new_object
|
@@ -52,9 +52,9 @@ describe ::Yeti::Editor do
|
|
52
52
|
subject.context.should be context
|
53
53
|
end
|
54
54
|
it "#persist! is virtual" do
|
55
|
-
|
55
|
+
expect do
|
56
56
|
subject.persist!
|
57
|
-
end.
|
57
|
+
end.to raise_error NotImplementedError, "Yeti::Editor#persist!"
|
58
58
|
end
|
59
59
|
it "delegates id to edited object" do
|
60
60
|
should delegates(:id).to :existing_object
|
@@ -68,8 +68,8 @@ describe ::Yeti::Editor do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
describe ".from_id(context, given_id)" do
|
71
|
-
let(:new_object){
|
72
|
-
let(:existing_object){
|
71
|
+
let(:new_object){ double :new_object }
|
72
|
+
let(:existing_object){ double :existing_object, id: 1 }
|
73
73
|
subject{ described_class.from_id context, given_id }
|
74
74
|
context "when given_id is nil" do
|
75
75
|
let(:given_id){ nil }
|
@@ -199,7 +199,7 @@ describe ::Yeti::Editor do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
context "existing record" do
|
202
|
-
let(:existing_object){
|
202
|
+
let(:existing_object){ double :existing_object, id: 1, name: "Anthony" }
|
203
203
|
subject{ described_class.new context, existing_object }
|
204
204
|
it("gets id from record"){ subject.id.should be 1 }
|
205
205
|
it "gets name from record" do
|
@@ -210,14 +210,14 @@ describe ::Yeti::Editor do
|
|
210
210
|
subject.stub(:format_output).with("Anthony", {
|
211
211
|
attribute_name: :name,
|
212
212
|
from: :edited,
|
213
|
-
}).and_return(expected =
|
213
|
+
}).and_return(expected = double)
|
214
214
|
subject.name.should be expected
|
215
215
|
end
|
216
216
|
it "input formatting can be customized" do
|
217
217
|
subject.stub(:format_input).with("Tony", {
|
218
218
|
attribute_name: :name,
|
219
219
|
from: :edited,
|
220
|
-
}).and_return(expected =
|
220
|
+
}).and_return(expected = double)
|
221
221
|
subject.name = "Tony"
|
222
222
|
subject.name.should be expected
|
223
223
|
end
|
@@ -272,7 +272,7 @@ describe ::Yeti::Editor do
|
|
272
272
|
subject.related_id.should == 2
|
273
273
|
end
|
274
274
|
it "attribute raises if value cannot be found in source" do
|
275
|
-
|
275
|
+
expect{ subject.invalid }.to raise_error NoMethodError
|
276
276
|
end
|
277
277
|
end
|
278
278
|
describe "#mandatory?" do
|
@@ -294,14 +294,14 @@ describe ::Yeti::Editor do
|
|
294
294
|
end
|
295
295
|
end
|
296
296
|
describe "equality" do
|
297
|
-
let(:existing){
|
298
|
-
let(:another){
|
297
|
+
let(:existing){ double :object, id: 1, persisted?: true }
|
298
|
+
let(:another){ double :object, id: 2, persisted?: true }
|
299
299
|
subject{ described_class.from_id context, 1 }
|
300
300
|
before do
|
301
301
|
described_class.stub(:find_by_id).with(context, 1).and_return existing
|
302
302
|
described_class.stub(:find_by_id).with(context, 2).and_return another
|
303
303
|
described_class.stub(:new_object).with(context).and_return do
|
304
|
-
|
304
|
+
double persisted?: false, id: nil
|
305
305
|
end
|
306
306
|
end
|
307
307
|
it "two new editors are not equal" do
|
@@ -339,7 +339,7 @@ describe ::Yeti::Editor do
|
|
339
339
|
attribute :valid_from, as: :date
|
340
340
|
end
|
341
341
|
end
|
342
|
-
let(:record){
|
342
|
+
let(:record){ double :new_record, valid_from: Date.parse("2002-09-01") }
|
343
343
|
it "when a new value is assigned" do
|
344
344
|
subject.valid_from = "2002-12-31"
|
345
345
|
subject.attributes.should == {valid_from: "2002-12-31"}
|
@@ -378,7 +378,7 @@ describe ::Yeti::Editor do
|
|
378
378
|
attribute :name
|
379
379
|
end
|
380
380
|
end
|
381
|
-
let(:record){
|
381
|
+
let(:record){ double :new_record, name: nil }
|
382
382
|
it "uses format_input_for_persist on each value" do
|
383
383
|
subject.name = "Tony"
|
384
384
|
subject.should_receive(:format_input_for_persist).with(
|
data/spec/yeti/search_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Yeti::Search do
|
4
|
-
let(:context){
|
4
|
+
let(:context){ double :context }
|
5
5
|
context "initialization" do
|
6
6
|
it "does require a context and a hash" do
|
7
7
|
message = "wrong number of arguments (1 for 2)"
|
8
|
-
|
8
|
+
expect do
|
9
9
|
Yeti::Search.new context
|
10
|
-
end.
|
10
|
+
end.to raise_error ArgumentError, message
|
11
11
|
end
|
12
12
|
end
|
13
13
|
context "given context and an empty hash" do
|
@@ -35,7 +35,7 @@ describe Yeti::Search do
|
|
35
35
|
"uncommon_filter" => "1",
|
36
36
|
}
|
37
37
|
end
|
38
|
-
let(:results){
|
38
|
+
let(:results){ double :results }
|
39
39
|
subject{ Yeti::Search.new context, search: search }
|
40
40
|
before{ subject.stub(:results).and_return results }
|
41
41
|
it "#search comes from hash" do
|
@@ -53,8 +53,8 @@ describe Yeti::Search do
|
|
53
53
|
end
|
54
54
|
it "doesn't get everything from search" do
|
55
55
|
subject.should_not respond_to(:uncommon_filter)
|
56
|
-
|
57
|
-
|
56
|
+
expect{ subject.invalid_method }.to raise_error NoMethodError
|
57
|
+
expect{ subject.uncommon_filter }.to raise_error NoMethodError
|
58
58
|
end
|
59
59
|
it "#page comes from hash" do
|
60
60
|
Yeti::Search.new(context, page: "2").page.should be 2
|
@@ -80,9 +80,9 @@ describe Yeti::Search do
|
|
80
80
|
search_class.new(context, per_page: "9999").per_page.should be 50
|
81
81
|
end
|
82
82
|
it "#paginated_results is virtual" do
|
83
|
-
|
83
|
+
expect do
|
84
84
|
subject.paginated_results
|
85
|
-
end.
|
85
|
+
end.to raise_error NotImplementedError
|
86
86
|
end
|
87
87
|
it{ should delegates(:to_ary).to :results }
|
88
88
|
it{ should delegates(:empty?).to :results }
|
@@ -91,7 +91,7 @@ describe Yeti::Search do
|
|
91
91
|
it{ should delegates(:size).to :results }
|
92
92
|
end
|
93
93
|
context "when paginated_results is defined" do
|
94
|
-
let(:paginated_results){
|
94
|
+
let(:paginated_results){ double :paginated_results }
|
95
95
|
subject{ Yeti::Search.new context, {} }
|
96
96
|
before{ subject.stub(:paginated_results).and_return paginated_results }
|
97
97
|
it{ should delegates(:page_count).to :paginated_results }
|
data/spec/yeti/viewer_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe ::Yeti::Viewer do
|
4
|
-
let(:context){
|
4
|
+
let(:context){ double :context }
|
5
5
|
it ".find_by_id is virtual" do
|
6
|
-
|
6
|
+
expect do
|
7
7
|
described_class.find_by_id context, 1
|
8
|
-
end.
|
8
|
+
end.to raise_error NotImplementedError, "Yeti::Viewer.find_by_id"
|
9
9
|
end
|
10
10
|
describe "initialization" do
|
11
|
-
let(:existing_object){
|
11
|
+
let(:existing_object){ double :existing_object }
|
12
12
|
subject{ described_class.new context, existing_object }
|
13
13
|
it "keeps given context" do
|
14
14
|
subject.context.should be context
|
@@ -27,7 +27,7 @@ describe ::Yeti::Viewer do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
describe ".from_id(context, given_id)" do
|
30
|
-
let(:existing_object){
|
30
|
+
let(:existing_object){ double :existing_object }
|
31
31
|
subject{ described_class.from_id context, "1" }
|
32
32
|
it "uses .find_by_id to find object to edit" do
|
33
33
|
described_class.should_receive(:find_by_id).with(context, "1").and_return do
|
@@ -37,8 +37,8 @@ describe ::Yeti::Viewer do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
describe "equality" do
|
40
|
-
let(:existing){
|
41
|
-
let(:another){
|
40
|
+
let(:existing){ double :object, id: 1 }
|
41
|
+
let(:another){ double :object, id: 2 }
|
42
42
|
subject{ described_class.from_id context, 1 }
|
43
43
|
before do
|
44
44
|
described_class.stub(:find_by_id).with(context, 1).and_return existing
|
data/spec/yeti_spec.rb
CHANGED
metadata
CHANGED
@@ -1,81 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yeti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.3.13
|
4
|
+
version: 0.3.14
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Joseph HALTER
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activemodel
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- -
|
17
|
+
- - '>='
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: '0'
|
21
|
-
none: false
|
22
20
|
type: :runtime
|
21
|
+
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- -
|
24
|
+
- - '>='
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: '0'
|
28
|
-
none: false
|
29
|
-
prerelease: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: string_cleaner
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
30
|
requirements:
|
34
|
-
- -
|
31
|
+
- - '>='
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '0'
|
37
|
-
none: false
|
38
34
|
type: :runtime
|
35
|
+
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- -
|
38
|
+
- - '>='
|
42
39
|
- !ruby/object:Gem::Version
|
43
40
|
version: '0'
|
44
|
-
none: false
|
45
|
-
prerelease: false
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
44
|
requirements:
|
50
|
-
- -
|
45
|
+
- - '>='
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: '0'
|
53
|
-
none: false
|
54
48
|
type: :development
|
49
|
+
prerelease: false
|
55
50
|
version_requirements: !ruby/object:Gem::Requirement
|
56
51
|
requirements:
|
57
|
-
- -
|
52
|
+
- - '>='
|
58
53
|
- !ruby/object:Gem::Version
|
59
54
|
version: '0'
|
60
|
-
none: false
|
61
|
-
prerelease: false
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
58
|
requirements:
|
66
|
-
- -
|
59
|
+
- - '>='
|
67
60
|
- !ruby/object:Gem::Version
|
68
61
|
version: '0'
|
69
|
-
none: false
|
70
62
|
type: :development
|
63
|
+
prerelease: false
|
71
64
|
version_requirements: !ruby/object:Gem::Requirement
|
72
65
|
requirements:
|
73
|
-
- -
|
66
|
+
- - '>='
|
74
67
|
- !ruby/object:Gem::Version
|
75
68
|
version: '0'
|
76
|
-
|
77
|
-
prerelease: false
|
78
|
-
description: ! 'Yeti: Context, Editor and Search patterns'
|
69
|
+
description: 'Yeti: Context, Editor and Search patterns'
|
79
70
|
email:
|
80
71
|
- joseph@openhood.com
|
81
72
|
executables: []
|
@@ -104,33 +95,26 @@ files:
|
|
104
95
|
- yeti.gemspec
|
105
96
|
homepage: ''
|
106
97
|
licenses: []
|
98
|
+
metadata: {}
|
107
99
|
post_install_message:
|
108
100
|
rdoc_options: []
|
109
101
|
require_paths:
|
110
102
|
- lib
|
111
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
104
|
requirements:
|
113
|
-
- -
|
105
|
+
- - '>='
|
114
106
|
- !ruby/object:Gem::Version
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
hash: 3458428500017664215
|
118
107
|
version: '0'
|
119
|
-
none: false
|
120
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
109
|
requirements:
|
122
|
-
- -
|
110
|
+
- - '>='
|
123
111
|
- !ruby/object:Gem::Version
|
124
|
-
segments:
|
125
|
-
- 0
|
126
|
-
hash: 3458428500017664215
|
127
112
|
version: '0'
|
128
|
-
none: false
|
129
113
|
requirements: []
|
130
114
|
rubyforge_project:
|
131
|
-
rubygems_version:
|
115
|
+
rubygems_version: 2.0.3
|
132
116
|
signing_key:
|
133
|
-
specification_version:
|
117
|
+
specification_version: 4
|
134
118
|
summary: Editor pattern simplifies edition of multiple objects at once using ActiveModel
|
135
119
|
test_files:
|
136
120
|
- spec/spec_helper.rb
|