Class: Zae::Parse
- Inherits:
-
Object
- Object
- Zae::Parse
- Defined in:
- lib/zae/parse.rb
Overview
Query for configuration files and returns matching ones
Instance Attribute Summary collapse
-
#found ⇒ Object
readonly
Returns the value of attribute found.
Class Method Summary collapse
-
.executable?(exec) ⇒ Boolean
do executable exist?.
Instance Method Summary collapse
-
#all ⇒ Object
List all configuration files.
-
#executable ⇒ Object
package manager's executable location.
-
#initialize ⇒ Parse
constructor
A new instance of Parse.
-
#one(file) ⇒ Object
Load and serialize configuration file.
Constructor Details
Instance Attribute Details
#found ⇒ Object (readonly)
Returns the value of attribute found.
21 22 23 |
# File 'lib/zae/parse.rb', line 21 def found @found end |
Class Method Details
.executable?(exec) ⇒ Boolean
do executable exist?
59 60 61 |
# File 'lib/zae/parse.rb', line 59 def self.executable?(exec) File.executable? exec.to_s end |
Instance Method Details
#all ⇒ Object
List all configuration files
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/zae/parse.rb', line 38 def all raise ExceptionType, 'Not files found' if @files.nil? {}.tap do |elem| @files.each do |file| name = file.sub_ext('').basename.to_s.to_sym elem[name] = one(file) end end end |
#executable ⇒ Object
package manager's executable location
50 51 52 53 54 55 56 |
# File 'lib/zae/parse.rb', line 50 def executable # return Pathname.new(discovered[:exec]).basename.to_path.to_sym if discovered? # get all availables executables exec = all.each_value.find { |config| Parse.executable?(config[:exec]) } Pathname.new(exec[:exec]).basename.to_path.to_sym end |
#one(file) ⇒ Object
Load and serialize configuration file
33 34 35 |
# File 'lib/zae/parse.rb', line 33 def one(file) JSON.load_file(file, symbolize_names: true) end |