Class: JsDependency::CliUtils::Yaml

Inherits:
Object
  • Object
show all
Defined in:
lib/js_dependency/cli_utils/yaml.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir_path: nil, path: nil) ⇒ Yaml

Returns a new instance of Yaml.

Parameters:

  • dir_path (String, nil) (defaults to: nil)
  • path (String, nil) (defaults to: nil)


11
12
13
14
# File 'lib/js_dependency/cli_utils/yaml.rb', line 11

def initialize(dir_path: nil, path: nil)
  @dir_path = present?(dir_path) ? dir_path : Dir.pwd
  @path = path
end

Instance Attribute Details

#dir_pathObject (readonly)

Returns the value of attribute dir_path.



6
7
8
# File 'lib/js_dependency/cli_utils/yaml.rb', line 6

def dir_path
  @dir_path
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/js_dependency/cli_utils/yaml.rb', line 6

def path
  @path
end

Instance Method Details

#argsHash

Returns:

  • (Hash)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/js_dependency/cli_utils/yaml.rb', line 17

def args
  pathname = if present?(@path)
               Pathname.new(@path)
             else
               config_pathname
             end

  if pathname.nil?
    {}
  else
    symbolize_keys(YAML.safe_load(pathname.read))
  end
end