Class: Kettle::Jem::ChecksumMode
- Inherits:
-
Object
- Object
- Kettle::Jem::ChecksumMode
- Defined in:
- lib/kettle/jem.rb
Constant Summary collapse
- VALID_TOKENS =
%w[dest template ignore-dest ignore-template off].freeze
- DEFAULT =
"template,ignore-dest"
Instance Attribute Summary collapse
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Class Method Summary collapse
Instance Method Summary collapse
- #check_destination? ⇒ Boolean
- #check_template? ⇒ Boolean
-
#initialize(value) ⇒ ChecksumMode
constructor
A new instance of ChecksumMode.
- #off? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ ChecksumMode
Returns a new instance of ChecksumMode.
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 |
# File 'lib/kettle/jem.rb', line 1775 def initialize(value) raw_tokens = value.to_s.strip.empty? ? DEFAULT.split(",") : value.to_s.split(",") normalized = raw_tokens.map { |token| token.to_s.strip.downcase }.reject(&:empty?) normalized = DEFAULT.split(",") if normalized.empty? unknown = normalized - VALID_TOKENS raise ArgumentError, "unknown --checksums mode(s): #{unknown.join(", ")}" unless unknown.empty? if normalized.include?("off") raise ArgumentError, "--checksums=off cannot be combined with other checksum modes" if normalized.length > 1 @tokens = ["off"] return end normalized << "template" if normalized.include?("dest") && !normalized.include?("ignore-template") && !normalized.include?("template") normalized << "ignore-dest" if normalized.include?("template") && !normalized.include?("dest") && !normalized.include?("ignore-dest") if normalized.include?("dest") && normalized.include?("ignore-dest") raise ArgumentError, "--checksums cannot combine dest and ignore-dest" end if normalized.include?("template") && normalized.include?("ignore-template") raise ArgumentError, "--checksums cannot combine template and ignore-template" end if normalized.include?("ignore-dest") && normalized.include?("ignore-template") raise ArgumentError, "--checksums=ignore-dest,ignore-template is equivalent to off; use --checksums=off" end @tokens = normalized.uniq end |
Instance Attribute Details
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
1769 1770 1771 |
# File 'lib/kettle/jem.rb', line 1769 def tokens @tokens end |
Class Method Details
.parse(value) ⇒ Object
1771 1772 1773 |
# File 'lib/kettle/jem.rb', line 1771 def self.parse(value) new(value) end |
Instance Method Details
#check_destination? ⇒ Boolean
1812 1813 1814 |
# File 'lib/kettle/jem.rb', line 1812 def check_destination? !off? && tokens.include?("dest") end |
#check_template? ⇒ Boolean
1808 1809 1810 |
# File 'lib/kettle/jem.rb', line 1808 def check_template? !off? && tokens.include?("template") end |
#off? ⇒ Boolean
1804 1805 1806 |
# File 'lib/kettle/jem.rb', line 1804 def off? tokens.include?("off") end |
#to_s ⇒ Object
1816 1817 1818 |
# File 'lib/kettle/jem.rb', line 1816 def to_s tokens.join(",") end |