Class: Skiima::Dependency::Script
- Inherits:
-
Object
- Object
- Skiima::Dependency::Script
- Defined in:
- lib/skiima/dependency/script.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#attr ⇒ Object
Returns the value of attribute attr.
-
#content ⇒ Object
Returns the value of attribute content.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#group ⇒ Object
Returns the value of attribute group.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sql ⇒ Object
Returns the value of attribute sql.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #down_filename ⇒ Object
- #full_down_filename(root) ⇒ Object
- #full_filename(root) ⇒ Object
-
#initialize(group, adapter, version, scriptname) ⇒ Script
constructor
A new instance of Script.
- #interpolate_sql(char, vars = {}) ⇒ Object
- #read_content(direction, root) ⇒ Object
- #read_downfile(root) ⇒ Object
- #read_upfile(root) ⇒ Object
Constructor Details
#initialize(group, adapter, version, scriptname) ⇒ Script
Returns a new instance of Script.
9 10 11 12 |
# File 'lib/skiima/dependency/script.rb', line 9 def initialize(group, adapter, version, scriptname) @group, @adapter, @version = group.to_s, adapter.to_s, version.to_s set_attr(scriptname) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/skiima/dependency/script.rb', line 5 def adapter @adapter end |
#attr ⇒ Object
Returns the value of attribute attr.
6 7 8 |
# File 'lib/skiima/dependency/script.rb', line 6 def attr @attr end |
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/skiima/dependency/script.rb', line 7 def content @content end |
#filename ⇒ Object
Returns the value of attribute filename.
7 8 9 |
# File 'lib/skiima/dependency/script.rb', line 7 def filename @filename end |
#group ⇒ Object
Returns the value of attribute group.
5 6 7 |
# File 'lib/skiima/dependency/script.rb', line 5 def group @group end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/skiima/dependency/script.rb', line 6 def name @name end |
#sql ⇒ Object
Returns the value of attribute sql.
7 8 9 |
# File 'lib/skiima/dependency/script.rb', line 7 def sql @sql end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/skiima/dependency/script.rb', line 6 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/skiima/dependency/script.rb', line 5 def version @version end |
Instance Method Details
#down_filename ⇒ Object
29 30 31 |
# File 'lib/skiima/dependency/script.rb', line 29 def down_filename filename.sub('.sql', '.drop.sql') end |
#full_down_filename(root) ⇒ Object
45 46 47 |
# File 'lib/skiima/dependency/script.rb', line 45 def full_down_filename(root) File.join(root, group, down_filename) end |
#full_filename(root) ⇒ Object
41 42 43 |
# File 'lib/skiima/dependency/script.rb', line 41 def full_filename(root) File.join(root, group, filename) end |
#interpolate_sql(char, vars = {}) ⇒ Object
25 26 27 |
# File 'lib/skiima/dependency/script.rb', line 25 def interpolate_sql(char, vars = {}) @sql = Skiima.interpolate_sql(char, @content, vars) end |
#read_content(direction, root) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/skiima/dependency/script.rb', line 18 def read_content(direction, root) @content = case when (direction == :up) then read_upfile(root) when (direction == :down && down_script?(root)) then read_downfile(root) end end |
#read_downfile(root) ⇒ Object
37 38 39 |
# File 'lib/skiima/dependency/script.rb', line 37 def read_downfile(root) File.open(full_down_filename(root)).read end |
#read_upfile(root) ⇒ Object
33 34 35 |
# File 'lib/skiima/dependency/script.rb', line 33 def read_upfile(root) File.open(full_filename(root)).read end |