mack-data_mapper 0.6.1.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/doc/classes/Mack.html +6 -6
  2. data/doc/classes/Mack/Database.html +119 -18
  3. data/doc/classes/Mack/Database/Generators.html +140 -0
  4. data/doc/classes/Mack/Database/Migrations.html +206 -0
  5. data/doc/classes/Mack/Testing/DataMapperHelpers.html +6 -6
  6. data/doc/classes/Mack/ViewHelpers/DataMapperHelpers.html +30 -124
  7. data/doc/created.rid +1 -1
  8. data/doc/files/lib/mack-data_mapper/database_migrations_rb.html +115 -0
  9. data/doc/files/lib/mack-data_mapper/database_rb.html +1 -1
  10. data/doc/files/lib/mack-data_mapper/dm_patches/dm-timestamps_rb.html +1 -1
  11. data/doc/files/lib/mack-data_mapper/dm_patches/migrations_rb.html +1 -1
  12. data/doc/files/lib/mack-data_mapper/{genosaurus_helpers_rb.html → dm_patches/model_rb.html} +5 -5
  13. data/doc/files/lib/mack-data_mapper/{scaffold_generator/scaffold_generator_rb.html → dm_patches/property_set_rb.html} +4 -17
  14. data/doc/{classes/DataMapper/Timestamp.html → files/lib/mack-data_mapper/dm_patches/validations_rb.html} +16 -20
  15. data/doc/files/lib/mack-data_mapper/{model_column_rb.html → generators_rb.html} +4 -4
  16. data/doc/files/lib/mack-data_mapper/helpers/orm_helpers_rb.html +1 -1
  17. data/doc/files/lib/mack-data_mapper/migration_generator/migration_generator_rb.html +1 -1
  18. data/doc/files/lib/mack-data_mapper/model_generator/model_generator_rb.html +1 -1
  19. data/doc/files/lib/mack-data_mapper_rb.html +2 -1
  20. data/doc/files/lib/mack-data_mapper_tasks_rb.html +8 -1
  21. data/doc/fr_class_index.html +2 -2
  22. data/doc/fr_file_index.html +5 -3
  23. data/doc/fr_method_index.html +10 -7
  24. data/lib/mack-data_mapper.rb +4 -5
  25. data/lib/mack-data_mapper/database.rb +79 -38
  26. data/lib/mack-data_mapper/database_migrations.rb +35 -0
  27. data/lib/mack-data_mapper/dm_patches/dm-timestamps.rb +4 -4
  28. data/lib/mack-data_mapper/dm_patches/migrations.rb +24 -2
  29. data/lib/mack-data_mapper/dm_patches/model.rb +48 -0
  30. data/lib/mack-data_mapper/dm_patches/property_set.rb +15 -0
  31. data/lib/mack-data_mapper/dm_patches/validations.rb +15 -0
  32. data/lib/mack-data_mapper/generators.rb +11 -0
  33. data/lib/mack-data_mapper/helpers/orm_helpers.rb +8 -32
  34. data/lib/mack-data_mapper/migration_generator/migration_generator.rb +1 -1
  35. data/lib/mack-data_mapper/model_generator/manifest.yml +2 -2
  36. data/lib/mack-data_mapper/model_generator/model_generator.rb +1 -1
  37. data/lib/mack-data_mapper_tasks.rb +1 -0
  38. metadata +42 -29
  39. data/doc/classes/ScaffoldGenerator.html +0 -123
  40. data/lib/mack-data_mapper/genosaurus_helpers.rb +0 -40
  41. data/lib/mack-data_mapper/model_column.rb +0 -42
  42. data/lib/mack-data_mapper/scaffold_generator/manifest.yml +0 -35
  43. data/lib/mack-data_mapper/scaffold_generator/scaffold_generator.rb +0 -41
  44. data/lib/mack-data_mapper/scaffold_generator/templates/app/helpers/controllers/helper.rb.template +0 -7
  45. data/lib/mack-data_mapper/scaffold_generator/templates/app/views/edit.html.erb.template +0 -19
  46. data/lib/mack-data_mapper/scaffold_generator/templates/app/views/index.html.erb.template +0 -41
  47. data/lib/mack-data_mapper/scaffold_generator/templates/app/views/new.html.erb.template +0 -19
  48. data/lib/mack-data_mapper/scaffold_generator/templates/app/views/show.html.erb.template +0 -12
  49. data/lib/mack-data_mapper/scaffold_generator/templates/test/functional/rspec.rb.template +0 -47
  50. data/lib/mack-data_mapper/scaffold_generator/templates/test/functional/test_case.rb.template +0 -9
  51. data/lib/mack-data_mapper/tasks/db_create_drop_tasks.rake +0 -57
  52. data/lib/mack-data_mapper/tasks/db_migration_tasks.rake +0 -46
  53. data/lib/mack-data_mapper/tasks/test_tasks.rake +0 -12
@@ -0,0 +1,15 @@
1
+ module DataMapper # :nodoc:
2
+ class PropertySet # :nodoc:
3
+
4
+ def []=(name, property)
5
+ if existing_property = detect { |p| p.name == name }
6
+ property.hash
7
+ @entries[@entries.index(existing_property)] = property
8
+ else
9
+ add(property)
10
+ end
11
+ property
12
+ end
13
+
14
+ end # class PropertySet
15
+ end # module DataMapper
@@ -0,0 +1,15 @@
1
+ module DataMapper # :nodoc:
2
+ module Validate # :nodoc:
3
+ class GenericValidator # :nodoc:
4
+
5
+ def ==(other)
6
+ self.field_name == other.field_name &&
7
+ self.if_clause == other.if_clause &&
8
+ self.class == other.class &&
9
+ self.unless_clause == other.unless_clause &&
10
+ self.instance_variable_get(:@options) == other.instance_variable_get(:@options)
11
+ end
12
+
13
+ end # class GenericValidator
14
+ end # module Validate
15
+ end # module DataMapper
@@ -0,0 +1,11 @@
1
+ module Mack
2
+ module Database
3
+ module Generators
4
+
5
+ def self.controller_template_location
6
+ File.join(File.dirname(__FILE__), "scaffold_generator", "templates", "app", "controllers", "controller.rb.template")
7
+ end
8
+
9
+ end # Generators
10
+ end # Database
11
+ end # Mack
@@ -3,17 +3,15 @@ module Mack
3
3
  module DataMapperHelpers
4
4
 
5
5
  DEFAULT_PARTIAL = %{
6
- <div>
7
- <div class="errorExplanation" id="errorExplanation">
8
- <h2><%= pluralize_word(errors.size, "error") %> occured.</h2>
9
- <ul>
10
- <% for error in errors %>
11
- <li><%= error %></li>
12
- <% end %>
13
- </ul>
14
- </div>
6
+ <div class="errorExplanation" id="errorExplanation">
7
+ <h2><%= pluralize_word(errors.size, "error") %> occured.</h2>
8
+ <ul>
9
+ <% for error in errors %>
10
+ <li><%= error %></li>
11
+ <% end %>
12
+ </ul>
15
13
  </div>
16
- } unless Mack::ViewHelpers::DataMapperHelpers.const_defined?("DEFAULT_PARTIAL")
14
+ }.strip unless Mack::ViewHelpers::DataMapperHelpers.const_defined?("DEFAULT_PARTIAL")
17
15
 
18
16
  # Provides view level support for printing out all the errors associated with the
19
17
  # models you tell it.
@@ -51,28 +49,6 @@ module Mack
51
49
  end
52
50
  end
53
51
 
54
- # Generates a text input tag for a given model and field
55
- #
56
- # Example:
57
- # model_text_field(@user, :username) # => <input id="user_username" name="user[username]" type="text" value="<@user.username's value>" />
58
- def model_text_field(model, property, options = {})
59
- m_name = model.class.to_s.underscore
60
- non_content_tag(:input, {:type => :text, :name => "#{m_name}[#{property}]", :id => "#{m_name}_#{property}", :value => model.send(property)}.merge(options))
61
- end
62
-
63
- # Generates a password input tag for a given model and field
64
- #
65
- # Example:
66
- # model_password_field(@user, :password) # => <input id="user_username" name="user[username]" type="password" value="<@user.username's value>" />
67
- def model_password_field(model, property, options = {})
68
- model_text_field(model, property, {:type => :password}.merge(options))
69
- end
70
-
71
- def model_textarea(model, property, options = {})
72
- m_name = model.class.to_s.underscore
73
- content_tag(:textarea, {:name => "#{m_name}[#{property}]", :id => "#{m_name}_#{property}", :cols => 60, :rows => 20}.merge(options), model.send(property))
74
- end
75
-
76
52
  end # OrmHelpers
77
53
  end # ViewHelpers
78
54
  end # Mack
@@ -42,7 +42,7 @@ class MigrationGenerator < Genosaurus
42
42
  end
43
43
 
44
44
  def migration_columns # :nodoc:
45
- [Mack::Genosaurus::DataMapper::ModelColumn.new(param(:name), "id:serial"), columns].flatten
45
+ [Mack::Genosaurus::Orm::ModelColumn.new(param(:name), "id:serial"), columns].flatten
46
46
  end
47
47
 
48
48
  def get_column_type(column) # :nodoc:
@@ -9,10 +9,10 @@ model_template:
9
9
  test_template:
10
10
  type: file
11
11
  template_path: <%= File.join(templates_directory_path, "test_case.rb.template") %>
12
- output_path: <%= File.join("test", "unit", "#{param(:name).singular.underscore}_test.rb") %>
12
+ output_path: <%= File.join("test", "models", "#{param(:name).singular.underscore}_test.rb") %>
13
13
  <% elsif app_config.mack.testing_framework == "rspec" -%>
14
14
  test_template:
15
15
  type: file
16
16
  template_path: <%= File.join(templates_directory_path, "rspec.rb.template") %>
17
- output_path: <%= File.join("test", "unit", "#{param(:name).singular.underscore}_spec.rb") %>
17
+ output_path: <%= File.join("test", "models", "#{param(:name).singular.underscore}_spec.rb") %>
18
18
  <% end -%>
@@ -53,7 +53,7 @@ class ModelGenerator < Genosaurus
53
53
  end
54
54
 
55
55
  def migration_columns # :nodoc:
56
- [Mack::Genosaurus::DataMapper::ModelColumn.new(param(:name), "id:serial"), columns].flatten
56
+ [Mack::Genosaurus::Orm::ModelColumn.new(param(:name), "id:serial"), columns].flatten
57
57
  end
58
58
 
59
59
  end
@@ -1,3 +1,4 @@
1
+ require 'mack-orm_tasks'
1
2
  Dir.glob(File.join(File.dirname(__FILE__), "mack-data_mapper", "tasks", "*.rake")).each do |f|
2
3
  load(f)
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack-data_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-29 00:00:00 -04:00
12
+ date: 2008-08-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.3
23
+ version: 0.9.4
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: dm-aggregates
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - "="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.3
33
+ version: 0.9.4
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: dm-migrations
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirements:
41
41
  - - "="
42
42
  - !ruby/object:Gem::Version
43
- version: 0.9.3
43
+ version: 0.9.4
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: dm-serializer
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - "="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.9.3
53
+ version: 0.9.4
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dm-timestamps
@@ -60,7 +60,7 @@ dependencies:
60
60
  requirements:
61
61
  - - "="
62
62
  - !ruby/object:Gem::Version
63
- version: 0.9.3
63
+ version: 0.9.4
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: dm-validations
@@ -70,7 +70,7 @@ dependencies:
70
70
  requirements:
71
71
  - - "="
72
72
  - !ruby/object:Gem::Version
73
- version: 0.9.3
73
+ version: 0.9.4
74
74
  version:
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: dm-observer
@@ -80,7 +80,7 @@ dependencies:
80
80
  requirements:
81
81
  - - "="
82
82
  - !ruby/object:Gem::Version
83
- version: 0.9.3
83
+ version: 0.9.4
84
84
  version:
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: dm-types
@@ -90,7 +90,27 @@ dependencies:
90
90
  requirements:
91
91
  - - "="
92
92
  - !ruby/object:Gem::Version
93
- version: 0.9.3
93
+ version: 0.9.4
94
+ version:
95
+ - !ruby/object:Gem::Dependency
96
+ name: mack-orm
97
+ type: :runtime
98
+ version_requirement:
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "="
102
+ - !ruby/object:Gem::Version
103
+ version: 0.7.0
104
+ version:
105
+ - !ruby/object:Gem::Dependency
106
+ name: bcrypt-ruby
107
+ type: :runtime
108
+ version_requirement:
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "="
112
+ - !ruby/object:Gem::Version
113
+ version: 2.0.3
94
114
  version:
95
115
  description: "mack-data_mapper was developed by: markbates"
96
116
  email: mark@mackframework.com
@@ -102,13 +122,16 @@ extra_rdoc_files:
102
122
  - README
103
123
  files:
104
124
  - lib/mack-data_mapper/database.rb
125
+ - lib/mack-data_mapper/database_migrations.rb
105
126
  - lib/mack-data_mapper/dm_patches/dm-timestamps.rb
106
127
  - lib/mack-data_mapper/dm_patches/migrations.rb
107
- - lib/mack-data_mapper/genosaurus_helpers.rb
128
+ - lib/mack-data_mapper/dm_patches/model.rb
129
+ - lib/mack-data_mapper/dm_patches/property_set.rb
130
+ - lib/mack-data_mapper/dm_patches/validations.rb
131
+ - lib/mack-data_mapper/generators.rb
108
132
  - lib/mack-data_mapper/helpers/orm_helpers.rb
109
133
  - lib/mack-data_mapper/migration_generator/migration_generator.rb
110
134
  - lib/mack-data_mapper/migration_generator/templates/db/migrations/%=@migration_name%.rb.template
111
- - lib/mack-data_mapper/model_column.rb
112
135
  - lib/mack-data_mapper/model_generator/manifest.yml
113
136
  - lib/mack-data_mapper/model_generator/model_generator.rb
114
137
  - lib/mack-data_mapper/model_generator/templates/model.rb.template
@@ -116,25 +139,14 @@ files:
116
139
  - lib/mack-data_mapper/model_generator/templates/test_case.rb.template
117
140
  - lib/mack-data_mapper/resource.rb
118
141
  - lib/mack-data_mapper/runner.rb
119
- - lib/mack-data_mapper/scaffold_generator/manifest.yml
120
- - lib/mack-data_mapper/scaffold_generator/scaffold_generator.rb
121
142
  - lib/mack-data_mapper/scaffold_generator/templates/app/controllers/controller.rb.template
122
- - lib/mack-data_mapper/scaffold_generator/templates/app/helpers/controllers/helper.rb.template
123
- - lib/mack-data_mapper/scaffold_generator/templates/app/views/edit.html.erb.template
124
- - lib/mack-data_mapper/scaffold_generator/templates/app/views/index.html.erb.template
125
- - lib/mack-data_mapper/scaffold_generator/templates/app/views/new.html.erb.template
126
- - lib/mack-data_mapper/scaffold_generator/templates/app/views/show.html.erb.template
127
- - lib/mack-data_mapper/scaffold_generator/templates/test/functional/rspec.rb.template
128
- - lib/mack-data_mapper/scaffold_generator/templates/test/functional/test_case.rb.template
129
- - lib/mack-data_mapper/tasks/db_create_drop_tasks.rake
130
- - lib/mack-data_mapper/tasks/db_migration_tasks.rake
131
- - lib/mack-data_mapper/tasks/test_tasks.rake
132
143
  - lib/mack-data_mapper/test_extensions.rb
133
144
  - lib/mack-data_mapper.rb
134
145
  - lib/mack-data_mapper_tasks.rb
135
146
  - README
136
147
  - doc/classes/DataMapper/Resource.html
137
- - doc/classes/DataMapper/Timestamp.html
148
+ - doc/classes/Mack/Database/Generators.html
149
+ - doc/classes/Mack/Database/Migrations.html
138
150
  - doc/classes/Mack/Database.html
139
151
  - doc/classes/Mack/Testing/DataMapperHelpers.html
140
152
  - doc/classes/Mack/Testing/Helpers.html
@@ -142,19 +154,20 @@ files:
142
154
  - doc/classes/Mack.html
143
155
  - doc/classes/MigrationGenerator.html
144
156
  - doc/classes/ModelGenerator.html
145
- - doc/classes/ScaffoldGenerator.html
146
157
  - doc/created.rid
158
+ - doc/files/lib/mack-data_mapper/database_migrations_rb.html
147
159
  - doc/files/lib/mack-data_mapper/database_rb.html
148
160
  - doc/files/lib/mack-data_mapper/dm_patches/dm-timestamps_rb.html
149
161
  - doc/files/lib/mack-data_mapper/dm_patches/migrations_rb.html
150
- - doc/files/lib/mack-data_mapper/genosaurus_helpers_rb.html
162
+ - doc/files/lib/mack-data_mapper/dm_patches/model_rb.html
163
+ - doc/files/lib/mack-data_mapper/dm_patches/property_set_rb.html
164
+ - doc/files/lib/mack-data_mapper/dm_patches/validations_rb.html
165
+ - doc/files/lib/mack-data_mapper/generators_rb.html
151
166
  - doc/files/lib/mack-data_mapper/helpers/orm_helpers_rb.html
152
167
  - doc/files/lib/mack-data_mapper/migration_generator/migration_generator_rb.html
153
- - doc/files/lib/mack-data_mapper/model_column_rb.html
154
168
  - doc/files/lib/mack-data_mapper/model_generator/model_generator_rb.html
155
169
  - doc/files/lib/mack-data_mapper/resource_rb.html
156
170
  - doc/files/lib/mack-data_mapper/runner_rb.html
157
- - doc/files/lib/mack-data_mapper/scaffold_generator/scaffold_generator_rb.html
158
171
  - doc/files/lib/mack-data_mapper/test_extensions_rb.html
159
172
  - doc/files/lib/mack-data_mapper_rb.html
160
173
  - doc/files/lib/mack-data_mapper_tasks_rb.html
@@ -1,123 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>Class: ScaffoldGenerator</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="classHeader">
50
- <table class="header-table">
51
- <tr class="top-aligned-row">
52
- <td><strong>Class</strong></td>
53
- <td class="class-name-in-header">ScaffoldGenerator</td>
54
- </tr>
55
- <tr class="top-aligned-row">
56
- <td><strong>In:</strong></td>
57
- <td>
58
- <a href="../files/lib/mack-data_mapper/scaffold_generator/scaffold_generator_rb.html">
59
- lib/mack-data_mapper/scaffold_generator/scaffold_generator.rb
60
- </a>
61
- <br />
62
- </td>
63
- </tr>
64
-
65
- <tr class="top-aligned-row">
66
- <td><strong>Parent:</strong></td>
67
- <td>
68
- Genosaurus
69
- </td>
70
- </tr>
71
- </table>
72
- </div>
73
- <!-- banner header -->
74
-
75
- <div id="bodyContent">
76
-
77
-
78
-
79
- <div id="contextContent">
80
-
81
- <div id="description">
82
- <p>
83
- Generates scaffold for <a href="Mack.html">Mack</a> applications.
84
- </p>
85
- <p>
86
- Example:
87
- </p>
88
- <pre>
89
- rake generate:scaffold name=post
90
- </pre>
91
-
92
- </div>
93
-
94
-
95
- </div>
96
-
97
-
98
- </div>
99
-
100
-
101
- <!-- if includes -->
102
-
103
- <div id="section">
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
- <!-- if method_list -->
113
-
114
-
115
- </div>
116
-
117
-
118
- <div id="validator-badges">
119
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
120
- </div>
121
-
122
- </body>
123
- </html>
@@ -1,40 +0,0 @@
1
- module Mack
2
- module Genosaurus # :nodoc:
3
- module DataMapper # :nodoc:
4
- module Helpers # :nodoc:
5
-
6
- def columns(name = param(:name))
7
- ivar_cache("form_columns") do
8
- cs = []
9
- cols = (param(:cols) || param(:columns))
10
- if cols
11
- cols.split(",").each do |x|
12
- cs << Mack::Genosaurus::DataMapper::ModelColumn.new(name, x)
13
- end
14
- end
15
- cs
16
- end
17
- end
18
-
19
- def db_directory
20
- File.join(Mack.root, "db")
21
- end
22
-
23
- def migrations_directory
24
- File.join(db_directory, "migrations")
25
- end
26
-
27
- def next_migration_number
28
- last = Dir.glob(File.join(migrations_directory, "*.rb")).last
29
- if last
30
- return File.basename(last).match(/^\d+/).to_s.succ
31
- end
32
- return "001"
33
- end
34
-
35
- ::Genosaurus.send(:include, self)
36
-
37
- end # Helpers
38
- end # DataMapper
39
- end # Genosaurus
40
- end # Mack