mack-data_mapper 0.7.0.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/doc/classes/Mack.html +8 -0
  2. data/doc/classes/Mack/{Testing/Helpers.html → DataMapper/Session.html} +24 -18
  3. data/doc/classes/Mack/Database.html +35 -35
  4. data/doc/classes/Mack/Database/Generators.html +6 -6
  5. data/doc/classes/Mack/Database/Migrations.html +24 -24
  6. data/doc/classes/Mack/SessionStore/DataMapper.html +262 -0
  7. data/doc/classes/Mack/Testing/DataMapperHelpers.html +21 -21
  8. data/doc/classes/Mack/ViewHelpers/DataMapperHelpers.html +1 -1
  9. data/doc/created.rid +1 -1
  10. data/doc/files/README.html +1 -1
  11. data/doc/files/lib/mack-data_mapper/database_migrations_rb.html +1 -1
  12. data/doc/files/lib/mack-data_mapper/database_rb.html +1 -1
  13. data/doc/files/lib/mack-data_mapper/dm_patches/dm-timestamps_rb.html +16 -1
  14. data/doc/files/lib/mack-data_mapper/dm_patches/migrations_rb.html +1 -1
  15. data/doc/files/lib/mack-data_mapper/dm_patches/model_rb.html +58 -1
  16. data/doc/files/lib/mack-data_mapper/dm_patches/property_set_rb.html +25 -1
  17. data/doc/files/lib/mack-data_mapper/dm_patches/validations_rb.html +25 -1
  18. data/doc/files/lib/mack-data_mapper/generators_rb.html +1 -1
  19. data/doc/files/lib/mack-data_mapper/helpers/orm_helpers_rb.html +1 -1
  20. data/doc/files/lib/mack-data_mapper/migration_generator/migration_generator_rb.html +1 -1
  21. data/doc/files/lib/mack-data_mapper/model_generator/model_generator_rb.html +1 -1
  22. data/doc/files/lib/mack-data_mapper/resource_rb.html +1 -1
  23. data/doc/files/lib/mack-data_mapper/runner_rb.html +1 -1
  24. data/doc/files/lib/mack-data_mapper/sessions/data_mapper_session_store_rb.html +101 -0
  25. data/doc/files/lib/mack-data_mapper/sessions/session_rb.html +101 -0
  26. data/doc/files/lib/mack-data_mapper/test_extensions_rb.html +1 -1
  27. data/doc/files/lib/mack-data_mapper_rb.html +1 -1
  28. data/doc/files/lib/mack-data_mapper_tasks_rb.html +1 -1
  29. data/doc/fr_class_index.html +2 -1
  30. data/doc/fr_file_index.html +2 -0
  31. data/doc/fr_method_index.html +14 -10
  32. data/lib/mack-data_mapper.rb +11 -7
  33. data/lib/mack-data_mapper/database.rb +8 -8
  34. data/lib/mack-data_mapper/database_migrations.rb +6 -6
  35. data/lib/mack-data_mapper/dm_patches/dm-timestamps.rb +6 -6
  36. data/lib/mack-data_mapper/dm_patches/model.rb +48 -48
  37. data/lib/mack-data_mapper/dm_patches/property_set.rb +15 -15
  38. data/lib/mack-data_mapper/dm_patches/validations.rb +15 -15
  39. data/lib/mack-data_mapper/helpers/orm_helpers.rb +1 -1
  40. data/lib/mack-data_mapper/sessions/data_mapper_session_store.rb +62 -0
  41. data/lib/mack-data_mapper/sessions/session.rb +14 -0
  42. data/lib/mack-data_mapper/test_extensions.rb +0 -9
  43. metadata +17 -22
@@ -1,15 +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
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
@@ -36,7 +36,7 @@ module Mack
36
36
  app_errors.flatten!
37
37
  unless app_errors.empty?
38
38
  if view_partial.nil?
39
- if File.exist?(File.join(Mack.root, "app", "views", "application", "_error_messages.html.erb"))
39
+ if File.exist?(Mack::Paths.views("application", "_error_messages.html.erb"))
40
40
  render(:partial, "application/error_messages", :locals => {:errors => app_errors})
41
41
  else
42
42
  render(:inline, DEFAULT_PARTIAL, :locals => {:errors => app_errors})
@@ -0,0 +1,62 @@
1
+ module Mack
2
+ module SessionStore # :nodoc:
3
+ # Stores session information in the database.
4
+ # To set the expiry time for this session store use the following app_config setting:
5
+ # data_mapper_session_store::expiry_time: <%= 4.hours %>
6
+ class DataMapper < Mack::SessionStore::Base
7
+
8
+ class << self
9
+
10
+ # Gets the session from the db, using the specified id.
11
+ # If the session has 'expired' then it's deleted from the db.
12
+ def get(id, *args)
13
+ create_storage_if_non_existent
14
+ sess = Mack::DataMapper::Session.first(:id => id)
15
+ return nil if sess.nil?
16
+ expire_date = DateTime.now.minus_seconds(app_config.data_mapper_session_store.expiry_time)
17
+ if sess.updated_at.to_s < expire_date.to_s
18
+ sess.destroy
19
+ return nil
20
+ end
21
+ return sess.data
22
+ end
23
+
24
+ # Creates or updates the session in the db.
25
+ def set(id, request, *args)
26
+ create_storage_if_non_existent
27
+ sess = Mack::DataMapper::Session.get(id)
28
+ if sess.nil?
29
+ sess = Mack::DataMapper::Session.new(:id => id, :data => request.session)
30
+ raise sess.errors.full_messages.inspect unless sess.valid?
31
+ sess.save
32
+ else
33
+ sess.data = request.session
34
+ sess.save
35
+ end
36
+ end
37
+
38
+ # Deletes the session from the db, if it exists.
39
+ def expire(id, *args)
40
+ create_storage_if_non_existent
41
+ sess = Mack::DataMapper::Session.get(id)
42
+ sess.destroy unless sess.nil?
43
+ end
44
+
45
+ # Deletes all the sessions from the db.
46
+ def expire_all(*args)
47
+ create_storage_if_non_existent
48
+ Mack::DataMapper::Session.all.destroy!
49
+ end
50
+
51
+ private
52
+ def create_storage_if_non_existent
53
+ unless Mack::DataMapper::Session.storage_exists?
54
+ Mack::DataMapper::Session.auto_migrate!
55
+ end
56
+ end
57
+
58
+ end
59
+
60
+ end # DataMapper
61
+ end # SessionStore
62
+ end # Mack
@@ -0,0 +1,14 @@
1
+ module Mack
2
+ module DataMapper # :nodoc:
3
+
4
+ # Used to store the Mack::Session object in the db.
5
+ class Session
6
+ include ::DataMapper::Resource
7
+
8
+ property :id, String, :key => true
9
+ property :data, Yaml, :nullable => false, :lazy => false
10
+ property :updated_at, DateTime
11
+ end # Session
12
+
13
+ end # DataMapper
14
+ end # Mack
@@ -12,15 +12,6 @@ if Mack.env == "test"
12
12
 
13
13
  module Mack
14
14
  module Testing
15
- module Helpers
16
- alias_method :mack_rake_task, :rake_task
17
-
18
- def rake_task(name, env = {}) # :nodoc:
19
- DataMapper::MigrationRunner.reset!
20
- mack_rake_task(name, env, [File.join(File.dirname(__FILE__), "tasks", "db_create_drop_tasks.rake"),
21
- File.join(File.dirname(__FILE__), "tasks", "db_migration_tasks.rake")])
22
- end
23
- end # Helpers
24
15
 
25
16
  class DmTestTransactionWrapper # :nodoc:
26
17
  include DataMapper::Resource
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.7.0.1
4
+ version: 0.7.1
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-09-08 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.4
23
+ version: 0.9.5
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.4
33
+ version: 0.9.5
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.4
43
+ version: 0.9.5
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.4
53
+ version: 0.9.5
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.4
63
+ version: 0.9.5
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.4
73
+ version: 0.9.5
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.4
83
+ version: 0.9.5
84
84
  version:
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: dm-types
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - "="
92
92
  - !ruby/object:Gem::Version
93
- version: 0.9.4
93
+ version: 0.9.5
94
94
  version:
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: mack-orm
@@ -100,17 +100,7 @@ dependencies:
100
100
  requirements:
101
101
  - - "="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.7.0.1
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
103
+ version: 0.7.1
114
104
  version:
115
105
  description: "mack-data_mapper was developed by: markbates"
116
106
  email: mark@mackframework.com
@@ -140,6 +130,8 @@ files:
140
130
  - lib/mack-data_mapper/resource.rb
141
131
  - lib/mack-data_mapper/runner.rb
142
132
  - lib/mack-data_mapper/scaffold_generator/templates/app/controllers/controller.rb.template
133
+ - lib/mack-data_mapper/sessions/data_mapper_session_store.rb
134
+ - lib/mack-data_mapper/sessions/session.rb
143
135
  - lib/mack-data_mapper/test_extensions.rb
144
136
  - lib/mack-data_mapper.rb
145
137
  - lib/mack-data_mapper_tasks.rb
@@ -148,8 +140,9 @@ files:
148
140
  - doc/classes/Mack/Database/Generators.html
149
141
  - doc/classes/Mack/Database/Migrations.html
150
142
  - doc/classes/Mack/Database.html
143
+ - doc/classes/Mack/DataMapper/Session.html
144
+ - doc/classes/Mack/SessionStore/DataMapper.html
151
145
  - doc/classes/Mack/Testing/DataMapperHelpers.html
152
- - doc/classes/Mack/Testing/Helpers.html
153
146
  - doc/classes/Mack/ViewHelpers/DataMapperHelpers.html
154
147
  - doc/classes/Mack.html
155
148
  - doc/classes/MigrationGenerator.html
@@ -168,6 +161,8 @@ files:
168
161
  - doc/files/lib/mack-data_mapper/model_generator/model_generator_rb.html
169
162
  - doc/files/lib/mack-data_mapper/resource_rb.html
170
163
  - doc/files/lib/mack-data_mapper/runner_rb.html
164
+ - doc/files/lib/mack-data_mapper/sessions/data_mapper_session_store_rb.html
165
+ - doc/files/lib/mack-data_mapper/sessions/session_rb.html
171
166
  - doc/files/lib/mack-data_mapper/test_extensions_rb.html
172
167
  - doc/files/lib/mack-data_mapper_rb.html
173
168
  - doc/files/lib/mack-data_mapper_tasks_rb.html