Class: Bashly::LibrarySource
- Inherits:
-
Object
- Object
- Bashly::LibrarySource
- Defined in:
- lib/bashly/library_source.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #config ⇒ Object
- #config_path ⇒ Object
- #git? ⇒ Boolean
-
#initialize(uri = nil) ⇒ LibrarySource
constructor
A new instance of LibrarySource.
- #libraries ⇒ Object
Constructor Details
#initialize(uri = nil) ⇒ LibrarySource
Returns a new instance of LibrarySource.
8 9 10 11 |
# File 'lib/bashly/library_source.rb', line 8 def initialize(uri = nil) @uri = uri || File.('libraries', __dir__) transform_github_uri if /^github(:|-)/.match? @uri end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/bashly/library_source.rb', line 6 def uri @uri end |
Instance Method Details
#cleanup ⇒ Object
36 37 38 |
# File 'lib/bashly/library_source.rb', line 36 def cleanup FileUtils.rm_rf(File.join(Dir.tmpdir, 'bashly-libs-*')) end |
#config ⇒ Object
17 18 19 |
# File 'lib/bashly/library_source.rb', line 17 def config @config ||= LibrarySourceConfig.new(config_path).validated_data end |
#config_path ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bashly/library_source.rb', line 28 def config_path @config_path ||= if File.exist?("#{path}/libraries.yml") "#{path}/libraries.yml" else raise "Cannot find #{path}/libraries.yml" end end |
#git? ⇒ Boolean
13 14 15 |
# File 'lib/bashly/library_source.rb', line 13 def git? /^(git|github|github-ssh):/.match? uri end |