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.
7 8 9 10 |
# File 'lib/bashly/library_source.rb', line 7 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.
5 6 7 |
# File 'lib/bashly/library_source.rb', line 5 def uri @uri end |
Instance Method Details
#cleanup ⇒ Object
35 36 37 |
# File 'lib/bashly/library_source.rb', line 35 def cleanup FileUtils.rm_rf(File.join(Dir.tmpdir, 'bashly-libs-*')) end |
#config ⇒ Object
16 17 18 |
# File 'lib/bashly/library_source.rb', line 16 def config @config ||= YAML.load_file config_path end |
#config_path ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/bashly/library_source.rb', line 27 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
12 13 14 |
# File 'lib/bashly/library_source.rb', line 12 def git? /^(git|github|github-ssh):/.match? uri end |