Class: ConfCtl::Swpins::Specs::Base
- Inherits:
-
Object
- Object
- ConfCtl::Swpins::Specs::Base
- Defined in:
- lib/confctl/swpins/specs/base.rb
Class Attribute Summary collapse
-
.type ⇒ Object
readonly
Returns the value of attribute type.
Instance Attribute Summary collapse
- #channel ⇒ String?
- #errors ⇒ Array readonly
- #info ⇒ Hash readonly
- #name ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #auto_update? ⇒ Boolean
- #can_update? ⇒ Boolean
-
#check_info(other_info) ⇒ Boolean
Check that ‘other_info` corresponds to this spec.
-
#check_opts ⇒ Boolean
Check that current nix options match those that generated json options.
- #from_channel? ⇒ Boolean
-
#initialize(name, nix_opts, json_opts) ⇒ Base
constructor
A new instance of Base.
- #prefetch_set(args) ⇒ Object
- #prefetch_update ⇒ Object
- #status ⇒ Object
-
#string_changelog_info(type, other_info, **opts) ⇒ String?
Generate changelog between revisions.
-
#string_diff_info(type, other_info, **opts) ⇒ String?
Generate diff between revisions.
- #to_json(*args) ⇒ Object
- #type ⇒ Object
- #valid? ⇒ Boolean
- #version ⇒ Object
-
#version_info(other_info) ⇒ String
Return version based on the info hash.
Constructor Details
#initialize(name, nix_opts, json_opts) ⇒ Base
Returns a new instance of Base.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/confctl/swpins/specs/base.rb', line 29 def initialize(name, nix_opts, json_opts) @name = name @nix_opts = nix_opts @json_opts = json_opts @state = nil @info = nil @fetcher = nil @fetcher_opts = nil @errors = [] parse end |
Class Attribute Details
.type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/confctl/swpins/specs/base.rb', line 4 def type @type end |
Instance Attribute Details
#channel ⇒ String?
18 19 20 |
# File 'lib/confctl/swpins/specs/base.rb', line 18 def channel @channel end |
#errors ⇒ Array (readonly)
21 22 23 |
# File 'lib/confctl/swpins/specs/base.rb', line 21 def errors @errors end |
#info ⇒ Hash
24 25 26 |
# File 'lib/confctl/swpins/specs/base.rb', line 24 def info @info end |
#name ⇒ String (readonly)
14 15 16 |
# File 'lib/confctl/swpins/specs/base.rb', line 14 def name @name end |
Class Method Details
Instance Method Details
#as_json ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/confctl/swpins/specs/base.rb', line 119 def as_json ret = {} ret['type'] = type.to_s ret['nix_options'] = nix_opts ret['state'] = state ret['info'] = info ret['fetcher'] = fetcher && { 'type' => fetcher, 'options' => fetcher_opts } ret end |
#auto_update? ⇒ Boolean
59 60 61 |
# File 'lib/confctl/swpins/specs/base.rb', line 59 def auto_update? can_update? && nix_opts['update']['auto'] end |
#can_update? ⇒ Boolean
55 56 57 |
# File 'lib/confctl/swpins/specs/base.rb', line 55 def can_update? nix_opts['update']['ref'] ? true : false end |
#check_info(other_info) ⇒ Boolean
Check that ‘other_info` corresponds to this spec
86 87 88 |
# File 'lib/confctl/swpins/specs/base.rb', line 86 def check_info(other_info) raise NotImplementedError end |
#check_opts ⇒ Boolean
Check that current nix options match those that generated json options
47 48 49 |
# File 'lib/confctl/swpins/specs/base.rb', line 47 def check_opts raise NotImplementedError end |
#from_channel? ⇒ Boolean
63 64 65 |
# File 'lib/confctl/swpins/specs/base.rb', line 63 def from_channel? !channel.nil? end |
#prefetch_set(args) ⇒ Object
75 76 77 |
# File 'lib/confctl/swpins/specs/base.rb', line 75 def prefetch_set(args) raise NotImplementedError end |
#prefetch_update ⇒ Object
79 80 81 |
# File 'lib/confctl/swpins/specs/base.rb', line 79 def prefetch_update raise NotImplementedError end |
#status ⇒ Object
67 68 69 |
# File 'lib/confctl/swpins/specs/base.rb', line 67 def status valid? ? version : 'update' end |
#string_changelog_info(type, other_info, **opts) ⇒ String?
Generate changelog between revisions
105 106 107 |
# File 'lib/confctl/swpins/specs/base.rb', line 105 def string_changelog_info(type, other_info, **opts) raise NotImplementedError end |
#string_diff_info(type, other_info, **opts) ⇒ String?
Generate diff between revisions
115 116 117 |
# File 'lib/confctl/swpins/specs/base.rb', line 115 def string_diff_info(type, other_info, **opts) raise NotImplementedError end |
#to_json(*args) ⇒ Object
132 133 134 |
# File 'lib/confctl/swpins/specs/base.rb', line 132 def to_json(*args) as_json.to_json(*args) end |
#type ⇒ Object
41 42 43 |
# File 'lib/confctl/swpins/specs/base.rb', line 41 def type self.class.type end |
#valid? ⇒ Boolean
51 52 53 |
# File 'lib/confctl/swpins/specs/base.rb', line 51 def valid? errors.empty? end |
#version ⇒ Object
71 72 73 |
# File 'lib/confctl/swpins/specs/base.rb', line 71 def version raise NotImplementedError end |
#version_info(other_info) ⇒ String
Return version based on the info hash
93 94 95 |
# File 'lib/confctl/swpins/specs/base.rb', line 93 def version_info(other_info) raise NotImplementedError end |