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.
1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 |
# File 'lib/kettle/jem.rb', line 1871 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.
1865 1866 1867 |
# File 'lib/kettle/jem.rb', line 1865 def tokens @tokens end |
Class Method Details
.parse(value) ⇒ Object
1867 1868 1869 |
# File 'lib/kettle/jem.rb', line 1867 def self.parse(value) new(value) end |
Instance Method Details
#check_destination? ⇒ Boolean
1908 1909 1910 |
# File 'lib/kettle/jem.rb', line 1908 def check_destination? !off? && tokens.include?("dest") end |
#check_template? ⇒ Boolean
1904 1905 1906 |
# File 'lib/kettle/jem.rb', line 1904 def check_template? !off? && tokens.include?("template") end |
#off? ⇒ Boolean
1900 1901 1902 |
# File 'lib/kettle/jem.rb', line 1900 def off? tokens.include?("off") end |
#to_s ⇒ Object
1912 1913 1914 |
# File 'lib/kettle/jem.rb', line 1912 def to_s tokens.join(",") end |