Class: Vcs4sql::Changelog
- Inherits:
-
Object
- Object
- Vcs4sql::Changelog
- Defined in:
- lib/vcs4sql/changelog.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#md5sum ⇒ Object
readonly
Returns the value of attribute md5sum.
-
#sql ⇒ Object
readonly
Returns the value of attribute sql.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #apply(conn) ⇒ Object
-
#initialize(file, applied, version, md5sum, sql, id: 0) ⇒ Changelog
constructor
A new instance of Changelog.
- #matches(exist) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, applied, version, md5sum, sql, id: 0) ⇒ Changelog
Returns a new instance of Changelog.
30 31 32 33 34 35 36 37 |
# File 'lib/vcs4sql/changelog.rb', line 30 def initialize(file, applied, version, md5sum, sql, id: 0) @file = file @applied = applied @version = version @md5sum = md5sum @sql = sql @id = id end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
28 29 30 |
# File 'lib/vcs4sql/changelog.rb', line 28 def file @file end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/vcs4sql/changelog.rb', line 28 def id @id end |
#md5sum ⇒ Object (readonly)
Returns the value of attribute md5sum.
28 29 30 |
# File 'lib/vcs4sql/changelog.rb', line 28 def md5sum @md5sum end |
#sql ⇒ Object (readonly)
Returns the value of attribute sql.
28 29 30 |
# File 'lib/vcs4sql/changelog.rb', line 28 def sql @sql end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
28 29 30 |
# File 'lib/vcs4sql/changelog.rb', line 28 def version @version end |
Instance Method Details
#apply(conn) ⇒ Object
TODO:
#/DEV Raise the exception in case if
-
this.* are empty or null
-
conn is empty or null
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vcs4sql/changelog.rb', line 42 def apply(conn) # @todo #/DEV Wrap the sql's execution to separate blocks which will: # - catch the error # - provide the detailed description # - populate the error code conn.execute_batch @sql conn.execute "insert /* ll.sqlid:#{__FILE__}:#{__method__} */ into changelog(file,version,md5sum,applied,sql) values(?,?,?,?,?)", @file, @version, @md5sum, @applied, @sql end |
#matches(exist) ⇒ Object
58 59 60 |
# File 'lib/vcs4sql/changelog.rb', line 58 def matches(exist) @md5sum == exist.md5sum end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/vcs4sql/changelog.rb', line 54 def to_s "#{@version}: #{@file} #{@md5sum}" end |