dao 5.5.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +6 -14
  2. data/README.md +258 -0
  3. data/Rakefile +4 -5
  4. data/coerce-0.0.8/README +28 -0
  5. data/coerce-0.0.8/Rakefile +392 -0
  6. data/coerce-0.0.8/coerce.gemspec +31 -0
  7. data/coerce-0.0.8/lib/coerce.rb +210 -0
  8. data/dao.gemspec +38 -25
  9. data/lib/dao.rb +18 -81
  10. data/lib/dao/_lib.rb +42 -0
  11. data/lib/dao/active_record.rb +8 -8
  12. data/lib/dao/api/call.rb +19 -4
  13. data/lib/dao/api/dsl.rb +1 -1
  14. data/lib/dao/coerce.rb +211 -0
  15. data/lib/dao/conducer.rb +10 -14
  16. data/lib/dao/conducer/controller_support.rb +5 -0
  17. data/lib/dao/conducer/view_support.rb +0 -2
  18. data/lib/dao/db.rb +0 -1
  19. data/lib/dao/errors.rb +17 -11
  20. data/lib/dao/errors2html.rb +128 -0
  21. data/lib/dao/form.rb +13 -16
  22. data/lib/dao/messages.rb +0 -4
  23. data/lib/dao/path.rb +1 -1
  24. data/lib/dao/route.rb +2 -2
  25. data/lib/dao/status.rb +3 -4
  26. data/lib/dao/support.rb +26 -19
  27. data/lib/dao/upload.rb +0 -1
  28. data/lib/dao/validations/common.rb +6 -6
  29. data/lib/dao/validations/validator.rb +3 -3
  30. data/lib/dao/wrap.rb +259 -0
  31. data/tasks/default.rake +207 -0
  32. data/tasks/this.rb +207 -0
  33. data/test/active_model_conducer_lint_test.rb +3 -11
  34. data/test/api_test.rb +24 -35
  35. data/test/conducer_test.rb +37 -47
  36. data/test/errors_test.rb +29 -13
  37. data/test/form_test.rb +24 -34
  38. data/test/rake_rerun_reporter.rb +74 -0
  39. data/test/support_test.rb +9 -14
  40. data/test/test_helper.rb +220 -0
  41. data/test/{helper.rb → util.rb} +0 -0
  42. data/test/validations_test.rb +14 -28
  43. data/wrap-1.5.2/README +57 -0
  44. data/wrap-1.5.2/Rakefile +394 -0
  45. data/wrap-1.5.2/lib/wrap.rb +295 -0
  46. data/{test → wrap-1.5.2/test}/testing.rb +0 -1
  47. data/wrap-1.5.2/test/wrap_test.rb +397 -0
  48. data/wrap-1.5.2/wrap.gemspec +38 -0
  49. metadata +47 -103
  50. data/Gemfile +0 -16
  51. data/Gemfile.lock +0 -118
  52. data/README +0 -256
@@ -0,0 +1,38 @@
1
+ ## wrap.gemspec
2
+ #
3
+
4
+ Gem::Specification::new do |spec|
5
+ spec.name = "wrap"
6
+ spec.version = "1.5.2"
7
+ spec.platform = Gem::Platform::RUBY
8
+ spec.summary = "wrap"
9
+ spec.description = "non-sucking :before and :after filters for any ruby class"
10
+ spec.license = "same as ruby's"
11
+
12
+ spec.files =
13
+ ["README",
14
+ "Rakefile",
15
+ "lib",
16
+ "lib/wrap.rb",
17
+ "test",
18
+ "test/testing.rb",
19
+ "test/wrap_test.rb",
20
+ "wrap.gemspec"]
21
+
22
+ spec.executables = []
23
+
24
+ spec.require_path = "lib"
25
+
26
+ spec.test_files = nil
27
+
28
+
29
+ spec.add_dependency(*["map", " >= 4.7.1"])
30
+
31
+
32
+ spec.extensions.push(*[])
33
+
34
+ spec.rubyforge_project = "codeforpeople"
35
+ spec.author = "Ara T. Howard"
36
+ spec.email = "ara.t.howard@gmail.com"
37
+ spec.homepage = "https://github.com/ahoward/wrap"
38
+ end
metadata CHANGED
@@ -1,167 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dao
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 8.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2020-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: map
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.0
33
+ version: '6.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 6.0.0
40
+ version: '6.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fattr
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.2'
47
+ version: '2.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.2'
55
- - !ruby/object:Gem::Dependency
56
- name: coerce
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: 0.0.3
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: 0.0.3
54
+ version: '2.4'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: tagz
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ! '>='
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 9.9.2
61
+ version: '9.10'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ! '>='
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 9.9.2
83
- - !ruby/object:Gem::Dependency
84
- name: multi_json
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: 1.0.3
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ! '>='
95
- - !ruby/object:Gem::Version
96
- version: 1.0.3
97
- - !ruby/object:Gem::Dependency
98
- name: uuidtools
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ! '>='
102
- - !ruby/object:Gem::Version
103
- version: 2.1.2
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: 2.1.2
111
- - !ruby/object:Gem::Dependency
112
- name: wrap
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: 1.5.0
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ! '>='
123
- - !ruby/object:Gem::Version
124
- version: 1.5.0
68
+ version: '9.10'
125
69
  - !ruby/object:Gem::Dependency
126
70
  name: rails_current
127
71
  requirement: !ruby/object:Gem::Requirement
128
72
  requirements:
129
- - - ! '>='
130
- - !ruby/object:Gem::Version
131
- version: 1.8.0
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ! '>='
137
- - !ruby/object:Gem::Version
138
- version: 1.8.0
139
- - !ruby/object:Gem::Dependency
140
- name: rails_errors2html
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ! '>='
73
+ - - "~>"
144
74
  - !ruby/object:Gem::Version
145
- version: 1.3.0
75
+ version: '2.2'
146
76
  type: :runtime
147
77
  prerelease: false
148
78
  version_requirements: !ruby/object:Gem::Requirement
149
79
  requirements:
150
- - - ! '>='
80
+ - - "~>"
151
81
  - !ruby/object:Gem::Version
152
- version: 1.3.0
153
- description: presenter, conducer, api, and better form objects for you rails' pleasure
82
+ version: '2.2'
83
+ description: presenter, conductor, api, and better form objects for you rails' pleasure
154
84
  email: ara.t.howard@gmail.com
155
85
  executables: []
156
86
  extensions: []
157
87
  extra_rdoc_files: []
158
88
  files:
159
- - Gemfile
160
- - Gemfile.lock
161
- - README
89
+ - README.md
162
90
  - Rakefile
91
+ - coerce-0.0.8/README
92
+ - coerce-0.0.8/Rakefile
93
+ - coerce-0.0.8/coerce.gemspec
94
+ - coerce-0.0.8/lib/coerce.rb
163
95
  - dao.gemspec
164
96
  - lib/dao.rb
97
+ - lib/dao/_lib.rb
165
98
  - lib/dao/active_record.rb
166
99
  - lib/dao/api.rb
167
100
  - lib/dao/api/call.rb
@@ -171,6 +104,7 @@ files:
171
104
  - lib/dao/api/modes.rb
172
105
  - lib/dao/api/routes.rb
173
106
  - lib/dao/blankslate.rb
107
+ - lib/dao/coerce.rb
174
108
  - lib/dao/conducer.rb
175
109
  - lib/dao/conducer/active_model.rb
176
110
  - lib/dao/conducer/attributes.rb
@@ -184,6 +118,7 @@ files:
184
118
  - lib/dao/endpoint.rb
185
119
  - lib/dao/engine.rb
186
120
  - lib/dao/errors.rb
121
+ - lib/dao/errors2html.rb
187
122
  - lib/dao/exceptions.rb
188
123
  - lib/dao/extractor.rb
189
124
  - lib/dao/form.rb
@@ -219,20 +154,30 @@ files:
219
154
  - lib/dao/validations/common.rb
220
155
  - lib/dao/validations/instance.rb
221
156
  - lib/dao/validations/validator.rb
157
+ - lib/dao/wrap.rb
158
+ - tasks/default.rake
159
+ - tasks/this.rb
222
160
  - test/active_model_conducer_lint_test.rb
223
161
  - test/api_test.rb
224
162
  - test/conducer_test.rb
225
163
  - test/data/han-solo.jpg
226
164
  - test/errors_test.rb
227
165
  - test/form_test.rb
228
- - test/helper.rb
229
166
  - test/leak.rb
167
+ - test/rake_rerun_reporter.rb
230
168
  - test/support_test.rb
231
- - test/testing.rb
169
+ - test/test_helper.rb
170
+ - test/util.rb
232
171
  - test/validations_test.rb
172
+ - wrap-1.5.2/README
173
+ - wrap-1.5.2/Rakefile
174
+ - wrap-1.5.2/lib/wrap.rb
175
+ - wrap-1.5.2/test/testing.rb
176
+ - wrap-1.5.2/test/wrap_test.rb
177
+ - wrap-1.5.2/wrap.gemspec
233
178
  homepage: https://github.com/ahoward/dao
234
179
  licenses:
235
- - same as ruby's
180
+ - Ruby
236
181
  metadata: {}
237
182
  post_install_message:
238
183
  rdoc_options: []
@@ -240,17 +185,16 @@ require_paths:
240
185
  - lib
241
186
  required_ruby_version: !ruby/object:Gem::Requirement
242
187
  requirements:
243
- - - ! '>='
188
+ - - ">="
244
189
  - !ruby/object:Gem::Version
245
190
  version: '0'
246
191
  required_rubygems_version: !ruby/object:Gem::Requirement
247
192
  requirements:
248
- - - ! '>='
193
+ - - ">="
249
194
  - !ruby/object:Gem::Version
250
195
  version: '0'
251
196
  requirements: []
252
- rubyforge_project: codeforpeople
253
- rubygems_version: 2.0.3
197
+ rubygems_version: 3.1.2
254
198
  signing_key:
255
199
  specification_version: 4
256
200
  summary: dao
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
-
4
-
5
- gem 'rails' , ' >= 3.1'
6
- gem 'map' , ' >= 6.0.0'
7
- gem 'fattr' , ' >= 2.2'
8
- gem 'coerce' , ' >= 0.0.3'
9
- gem 'tagz' , ' >= 9.8'
10
- gem 'multi_json' , ' >= 1.0.3'
11
- gem 'uuidtools' , ' >= 2.1.2'
12
- gem 'wrap' , ' >= 1.5.0'
13
- gem 'rails_current' , ' >= 1.7.0'
14
- gem 'rails_errors2html' , ' >= 1.3.0'
15
- gem 'pry'
16
-
@@ -1,118 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- actionmailer (3.2.13)
5
- actionpack (= 3.2.13)
6
- mail (~> 2.5.3)
7
- actionpack (3.2.13)
8
- activemodel (= 3.2.13)
9
- activesupport (= 3.2.13)
10
- builder (~> 3.0.0)
11
- erubis (~> 2.7.0)
12
- journey (~> 1.0.4)
13
- rack (~> 1.4.5)
14
- rack-cache (~> 1.2)
15
- rack-test (~> 0.6.1)
16
- sprockets (~> 2.2.1)
17
- activemodel (3.2.13)
18
- activesupport (= 3.2.13)
19
- builder (~> 3.0.0)
20
- activerecord (3.2.13)
21
- activemodel (= 3.2.13)
22
- activesupport (= 3.2.13)
23
- arel (~> 3.0.2)
24
- tzinfo (~> 0.3.29)
25
- activeresource (3.2.13)
26
- activemodel (= 3.2.13)
27
- activesupport (= 3.2.13)
28
- activesupport (3.2.13)
29
- i18n (= 0.6.1)
30
- multi_json (~> 1.0)
31
- arel (3.0.2)
32
- builder (3.0.4)
33
- chronic (0.9.1)
34
- coderay (1.0.9)
35
- coerce (0.0.4)
36
- chronic (>= 0.6.2)
37
- erubis (2.7.0)
38
- fattr (2.2.1)
39
- hike (1.2.3)
40
- i18n (0.6.1)
41
- journey (1.0.4)
42
- json (1.8.0)
43
- mail (2.5.4)
44
- mime-types (~> 1.16)
45
- treetop (~> 1.4.8)
46
- map (6.5.1)
47
- method_source (0.8.1)
48
- mime-types (1.23)
49
- multi_json (1.7.6)
50
- polyglot (0.3.3)
51
- pry (0.9.12.2)
52
- coderay (~> 1.0.5)
53
- method_source (~> 0.8)
54
- slop (~> 3.4)
55
- rack (1.4.5)
56
- rack-cache (1.2)
57
- rack (>= 0.4)
58
- rack-ssl (1.3.3)
59
- rack
60
- rack-test (0.6.2)
61
- rack (>= 1.0)
62
- rails (3.2.13)
63
- actionmailer (= 3.2.13)
64
- actionpack (= 3.2.13)
65
- activerecord (= 3.2.13)
66
- activeresource (= 3.2.13)
67
- activesupport (= 3.2.13)
68
- bundler (~> 1.0)
69
- railties (= 3.2.13)
70
- rails_current (1.7.0)
71
- map (>= 6.0.1)
72
- rails_errors2html (1.4.2)
73
- fattr (>= 2.2.1)
74
- map (>= 6.2.0)
75
- rails_view (>= 1.0.1)
76
- rails_view (1.0.1)
77
- railties (3.2.13)
78
- actionpack (= 3.2.13)
79
- activesupport (= 3.2.13)
80
- rack-ssl (~> 1.3.2)
81
- rake (>= 0.8.7)
82
- rdoc (~> 3.4)
83
- thor (>= 0.14.6, < 2.0)
84
- rake (10.0.4)
85
- rdoc (3.12.2)
86
- json (~> 1.4)
87
- slop (3.4.5)
88
- sprockets (2.2.2)
89
- hike (~> 1.2)
90
- multi_json (~> 1.0)
91
- rack (~> 1.0)
92
- tilt (~> 1.1, != 1.3.0)
93
- tagz (9.9.1)
94
- thor (0.18.1)
95
- tilt (1.4.1)
96
- treetop (1.4.14)
97
- polyglot
98
- polyglot (>= 0.3.1)
99
- tzinfo (0.3.37)
100
- uuidtools (2.1.4)
101
- wrap (1.5.0)
102
- map (>= 4.7.1)
103
-
104
- PLATFORMS
105
- ruby
106
-
107
- DEPENDENCIES
108
- coerce (>= 0.0.3)
109
- fattr (>= 2.2)
110
- map (>= 6.0.0)
111
- multi_json (>= 1.0.3)
112
- pry
113
- rails (>= 3.1)
114
- rails_current (>= 1.7.0)
115
- rails_errors2html (>= 1.3.0)
116
- tagz (>= 9.8)
117
- uuidtools (>= 2.1.2)
118
- wrap (>= 1.5.0)
data/README DELETED
@@ -1,256 +0,0 @@
1
- NAME
2
- dao
3
-
4
- SYNOPSIS
5
- a sa-weet-ass library for structuring rails applications using the 'data
6
- access object' design pattern. dao consists of two main data access
7
- objects, *api* objects and *conducer* objects. conducers combine the
8
- presenter pattern with the conductor pattern.
9
-
10
-
11
- API
12
-
13
- class Api < Dao::Api
14
- call('/posts') do
15
- get do
16
- data[:posts] = Post.all.map{|post| post.attributes}
17
- end
18
-
19
- post do
20
- post = Post.new(params[:post])
21
-
22
- if post.save
23
- data[:post] = post.attributes
24
- else
25
- status 420
26
- end
27
- end
28
- end
29
- end
30
-
31
- CONDUCER
32
-
33
- # TODO
34
-
35
-
36
- wikipedia has this to say about dao in general
37
-
38
- "
39
- In computer software, a data access object (DAO) is an object that
40
- provides an abstract interface to some type of database or other
41
- persistence mechanism. By mapping application calls to the persistence
42
- layer, DAOs provide some specific data operations without exposing
43
- details of the database. This isolation supports the single
44
- responsibility principle. It separates what data accesses the
45
- application needs, in terms of domain-specific objects and data types
46
- (the public interface of the DAO), from how these needs can be satisfied
47
- with a specific DBMS, database schema, etc. (the implementation of the
48
- DAO).
49
- "
50
- - http://en.wikipedia.org/wiki/Data_access_object
51
-
52
- and this to say about the single responsibility principle
53
-
54
- "
55
- In object-oriented programming, the single responsibility principle
56
- states that every class should have a single responsibility, and that
57
- responsibility should be entirely encapsulated by the class. All its
58
- services should be narrowly aligned with that responsibility.
59
-
60
- Responsibility [is defined] as a reason to change, and [single
61
- responsibility means] that a class or module should have one, and only
62
- one, reason to change. As an example, consider a module that compiles and
63
- prints a report. Such a module can be changed for two reasons. First,
64
- the content of the report can change. Second, the format of the report
65
- can change. These two things change for very different causes; one
66
- substantive, and one cosmetic. The single responsibility principle says
67
- that these two aspects of the problem are really two separate
68
- responsibilities, and should therefore be in separate classes or
69
- modules. It would be a bad design to couple two things that change for
70
- different reasons at different times.
71
- "
72
- - http://en.wikipedia.org/wiki/Single_responsibility_principle
73
-
74
- even though rails is the sweet, its ActiveRecord class violates (or, at
75
- least, encourages a programmer to violate) the single responsibility
76
- principle
77
-
78
- this leads to obvious problems
79
-
80
- "
81
- Jim Weirich, at the end of his SOLID Ruby Talk at the 2009 Ruby
82
- Conference, asks the audience: "ActiveRecord objects implement a domain
83
- concept and a persistence concept. Does this violate the SRP (Single
84
- Responsibility Principle)?" The audience agrees that it does violate the
85
- SRP. Jim asks if this bothers them. Many members of the audience say
86
- yes. Why? It makes testing harder. It makes the persistence object a lot
87
- heavier.
88
- "
89
- - http://programmers.stackexchange.com/questions/119352/does-the-activerecord-pattern-follow-encourage-the-solid-design-principles#comment293734_119352
90
-
91
- and subtle yet sweeping consequences (as described by uncle bob)
92
-
93
- "
94
- The problem I have with ActiveRecord is that it creates confusion about
95
- ... two very different styles of programming. A database table is a
96
- data structure. It has exposed data and no behavior. But an ActiveRecord
97
- appears to be an object. It has “hidden” data, and exposed behavior. I
98
- put the word “hidden” in quotes because the data is, in fact, not
99
- hidden. Almost all ActiveRecord derivatives export the database columns
100
- through accessors and mutators. Indeed, the Active Record is meant to be
101
- used like a data structure.
102
-
103
- On the other hand, many people put business rule methods in their
104
- ActiveRecord classes; which makes them appear to be objects. This leads
105
- to a dilemma. On which side of the line does the Active Record really
106
- fall? Is it an object? Or is it a data structure?
107
-
108
- This dilemma is the basis for the oft-cited impedance mismatch between
109
- relational databases and object oriented languages. Tables are data
110
- structures, not classes. Objects are encapsulated behavior, not database
111
- rows.
112
-
113
- ...
114
-
115
- The problem is that Active Records are data structures. Putting business
116
- rule methods in them doesn’t turn them into true objects. In the end,
117
- the algorithms that employ ActiveRecords are vulnerable to changes in
118
- schema, and changes in type. They are not immune to changes in type, the
119
- way algorithms that use objects are.
120
-
121
- ...
122
-
123
- So applications built around ActiveRecord are applications built around
124
- data structures. And applications that are built around data structures
125
- are procedural—they are not object oriented. The opportunity we miss
126
- when we structure our applications around ActiveRecord is the
127
- opportunity to use object oriented design.
128
- "
129
- - https://sites.google.com/site/unclebobconsultingllc/active-record-vs-objects
130
-
131
- and a clear solution (again, uncle bob)
132
-
133
- "
134
- I am not recommending against the use of ActiveRecord. I think the
135
- pattern is very useful. What I am advocating is a separation between the
136
- application and ActiveRecord.
137
-
138
- ActiveRecord belongs in the layer that separates the database from the
139
- application. It makes a very convenient halfway-house between the hard
140
- data structures of database tables, and the behavior exposing objects in
141
- the application.
142
-
143
- Applications should be designed and structured around objects, not data
144
- structures. Those objects should expose business behaviors, and hide any
145
- vestige of the database.
146
- "
147
- - https://sites.google.com/site/unclebobconsultingllc/active-record-vs-objects
148
-
149
- welcome to the dao
150
-
151
-
152
- DESCRIPTION
153
-
154
- API
155
- applications that are written on dao look like this in ruby
156
-
157
- result = api.call('/posts/new', params)
158
-
159
- and like this in javascript
160
-
161
- result = api.call('/posts/new', params)
162
-
163
- in command-line applications they look like this
164
-
165
- result = api.call('/posts/new', params)
166
-
167
- and in tests this syntax is used
168
-
169
- result = api.call('/posts/new', params)
170
-
171
- when a developer wants to understand the interface of a dao application
172
- she does this
173
-
174
- vi app/api.rb
175
-
176
- when a developer of a dao application wants to play with a dao application
177
- interactively she does
178
-
179
- (rails console)
180
-
181
- > api = Api.new result = api.call('/posts/new', params)
182
-
183
- when a remote client wants to understand the api of a dao application she
184
- does
185
-
186
- curl --silent http://dao.app.com/api | less
187
-
188
-
189
-
190
- this kind of brutally consistent interface is made possible by structuring
191
- access to data around the finest data structure of all time - the hash.
192
- in the case of dao the hash is a well structured and slightly clever hash,
193
- but a simple hash interface is the basis of every bit of goodness dao has
194
- to offer.
195
-
196
- in dao, application developers do not bring models into controllers and,
197
- especially not into views. instead, a unified interface to application
198
- logic and data is used everywhere: in tests, in controllers, from the
199
- command-line, and also from javascript.
200
-
201
- this seperation of concerns brings with it many, many desirable qualities:
202
-
203
- - total seperation of concerns between the front and back end of a web
204
- application. when developers are using dao changes to the data model
205
- have zero effect on controllers and views.
206
-
207
- - issues related to having models in controllers and views such as
208
- difficulty reasoning about caching and n+1 queries in views killing
209
- the db simply disappear.
210
-
211
- - bad programming practices like using quasi-global variables
212
- (current_user) or decorating models with view specific attributes
213
- (password_verification) are no longer needed.
214
-
215
- - developers are able to reason over the abilities of an application by
216
- reading only a few source files.
217
-
218
- - databases can be swapped, mixed, or alternate storage/caching
219
- mechanisms added at any time without affecting the application's
220
- controllers or views.
221
-
222
- - transition from form based views to semi-ajax ones to fully-ajax ones
223
- is direct.
224
-
225
- - forms and interfaces that involve dozens of models are as easy to deal
226
- with as simple ones.
227
-
228
- - code can be optimized at the interface.
229
-
230
- READING
231
- http://blog.plataformatec.com.br/2012/03/barebone-models-to-use-with-actionpack-in-rails-4-0/
232
- http://martinfowler.com/eaaCatalog/serviceLayer.html
233
- http://blog.firsthand.ca/2011/10/rails-is-not-your-application.html
234
- http://best-practice-software-engineering.ifs.tuwien.ac.at/patterns/dao.html
235
- http://www.codefutures.com/data-access-object/
236
- http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
237
- http://www.paperplanes.de/2010/5/7/activerecord_callbacks_ruined_my_life.html
238
- http://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml
239
- http://pragdave.blogs.pragprog.com/pragdave/2007/03/the_radar_archi.html
240
- http://borisstaal.com/post/22586260753/mvc-in-a-browser-vs-reality
241
-
242
-
243
- INSTALL
244
- gem 'dao', :path => File.expand_path('..') ### Gemfile
245
- rails generate dao api
246
- vim -o app/api.rb app/controllers/api_controller.rb
247
- curl --silent http://0.0.0.0:3000/api
248
- curl --silent http://0.0.0.0:3000/api/ping
249
-
250
- HISTORY
251
- 4.0.0
252
- - dao depends has tied itself to rails, for better or worse...
253
- - drop custom form encoding. just use a rack-like approach.
254
- - dao form parameter encoding has changed slightly to 'dao[/api/path][x,y,z]=42'
255
- - dao form paramters are now preparsed in a before filter
256
-