Module: DmSvn::Svn
- Defined in:
- lib/dm-svn/svn.rb,
lib/dm-svn/svn/node.rb,
lib/dm-svn/svn/sync.rb,
lib/dm-svn/svn/changeset.rb,
lib/dm-svn/svn/categorized.rb
Defined Under Namespace
Modules: Categorized, ClassMethods Classes: Changeset, Node, Sync
Class Method Summary collapse
-
.included(klass) ⇒ Object
Set a few ‘magic’ properties.
Instance Method Summary collapse
-
#move_to(new_path) ⇒ Object
Move to a different path and save.
-
#name ⇒ Object
name
could be reasonably used for another property, but may normally be assumed to be the ‘svn_name’. -
#path ⇒ Object
The path from the svn root for the model.
-
#path=(value) ⇒ Object
Set the path.
-
#update_from_svn(node) ⇒ Object
Update properties (body and other properties) from a DmSvn::Svn::Node or similar (expects #body as a String and #properties as a Hash).
Class Method Details
.included(klass) ⇒ Object
Set a few ‘magic’ properties
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dm-svn/svn.rb', line 5 def included(klass) # Set a few 'magic' properties klass.extend(ClassMethods) # svn_name could be just a name, or a full path, always excluding # extension. If directories are stored in a model (not yet supported), # it contains the full path (from the config.uri). klass.property :svn_name, DataMapper::Property::Text, :lazy => false klass.property :svn_created_at, DateTime klass.property :svn_updated_at, DateTime klass.property :svn_created_rev, String klass.property :svn_updated_rev, String klass.property :svn_created_by, String klass.property :svn_updated_by, String # On create, set svn_created_* attrs based on svn_updated_* attrs klass.before :create do attribute_set(:svn_created_at, svn_updated_at) attribute_set(:svn_created_rev, svn_updated_rev) attribute_set(:svn_created_by, svn_updated_by) end end |
Instance Method Details
#move_to(new_path) ⇒ Object
Move to a different path and save
47 48 49 50 |
# File 'lib/dm-svn/svn.rb', line 47 def move_to(new_path) self.path = new_path self.save end |
#name ⇒ Object
name
could be reasonably used for another property, but may normally be assumed to be the ‘svn_name’.
30 31 32 |
# File 'lib/dm-svn/svn.rb', line 30 def name @svn_name end |
#path ⇒ Object
The path from the svn root for the model. For the moment, just an alias of svn_name
.
36 37 38 |
# File 'lib/dm-svn/svn.rb', line 36 def path @svn_name end |
#path=(value) ⇒ Object
Set the path. This may be responsible for moving the record to a different parent, etc.
42 43 44 |
# File 'lib/dm-svn/svn.rb', line 42 def path=(value) attribute_set(:svn_name, value) end |
#update_from_svn(node) ⇒ Object
Update properties (body and other properties) from a DmSvn::Svn::Node or similar (expects #body as a String and #properties as a Hash). This method calls #save.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/dm-svn/svn.rb', line 55 def update_from_svn(node) attribute_set(self.class.config.body_property, node.body) if node.body self.path = node.short_path node.properties.each do | attr, value | if self.respond_to?("#{attr}=") self.__send__("#{attr}=", value) end end if !valid? puts "Invalid #{node.short_path} at revision #{node.revision}" puts " - " + errors..join(".\n - ") end save end |