Class: FPM::Cookery::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/cookery/source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = nil) ⇒ Source

Returns a new instance of Source.



9
10
11
12
13
14
15
16
17
18
# File 'lib/fpm/cookery/source.rb', line 9

def initialize(url, options = nil)
  options ||= {}
  begin
    @url = Addressable::URI.parse(url.to_s)
  rescue Addressable::URI::InvalidURIError
    @url = URI::SshGit.parse(url.to_s)
  end
  @provider = options[:with]
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/fpm/cookery/source.rb', line 7

def options
  @options
end

#providerObject (readonly)

Returns the value of attribute provider.



7
8
9
# File 'lib/fpm/cookery/source.rb', line 7

def provider
  @provider
end

Instance Method Details

#fetchable?Boolean

If the Addressable::URI is empty, there’s nothing to fetch

Returns:

  • (Boolean)


29
30
31
# File 'lib/fpm/cookery/source.rb', line 29

def fetchable?
  !@url.to_s.empty?
end

#local?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/fpm/cookery/source.rb', line 24

def local?
  @url.scheme.to_s.downcase == 'file'
end

#pathObject



38
39
40
# File 'lib/fpm/cookery/source.rb', line 38

def path
  @url.path
end

#provider?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/fpm/cookery/source.rb', line 20

def provider?
  !!@provider
end

#urlObject



33
34
35
# File 'lib/fpm/cookery/source.rb', line 33

def url
  @url.to_s
end