Class: Sideload::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sideload/config.rb

Constant Summary collapse

ALLOWED =
i[path github redis]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



7
8
9
10
11
# File 'lib/sideload/config.rb', line 7

def initialize
  @sources = []
  @packer = ->(f) { f }
  @unpacker = ->(f) { f }
end

Instance Attribute Details

#packerObject (readonly)

Returns the value of attribute packer.



5
6
7
# File 'lib/sideload/config.rb', line 5

def packer
  @packer
end

#sourcesObject (readonly)

Returns the value of attribute sources.



5
6
7
# File 'lib/sideload/config.rb', line 5

def sources
  @sources
end

#unpackerObject (readonly)

Returns the value of attribute unpacker.



5
6
7
# File 'lib/sideload/config.rb', line 5

def unpacker
  @unpacker
end

Instance Method Details

#packObject



13
14
15
# File 'lib/sideload/config.rb', line 13

def pack
  @packer = Proc.new
end

#source(scope, arg, **config) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sideload/config.rb', line 25

def source(scope, arg, **config)
  if !ALLOWED.include?(scope)
    raise "scope #{scope.inspect} not in #{ALLOWED.inspect}"
  end
  @sources << [
    scope,
    arg,
    config,
    (block_given? ? Proc.new : nil) || @validate
  ]
end

#unpackObject



17
18
19
# File 'lib/sideload/config.rb', line 17

def unpack
  @unpacker = Proc.new
end

#update!Object



37
38
39
# File 'lib/sideload/config.rb', line 37

def update!
  Sideload.update!(@sources.dup, &(block_given? ? Proc.new : nil))
end

#validateObject



21
22
23
# File 'lib/sideload/config.rb', line 21

def validate
  @validate = Proc.new
end