Class: GitVersion::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/git_version/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ Parser

Returns a new instance of Parser.



9
10
11
# File 'lib/git_version/parser.rb', line 9

def initialize(args = [])
  @args = args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/git_version/parser.rb', line 13

def method_missing(symbol, *args)
  keys = [symbol.to_s, pascal_case(symbol.to_s)]

  found_key = keys.find { |key| json.has_key?(key) }
  return json[found_key] if found_key

  super
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/git_version/parser.rb', line 6

def args
  @args
end

#gitversion_exeObject

Returns the value of attribute gitversion_exe.



7
8
9
# File 'lib/git_version/parser.rb', line 7

def gitversion_exe
  @gitversion_exe
end

Instance Method Details

#inspectObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/git_version/parser.rb', line 30

def inspect
  unless @json

    return <<EOF
#{to_s}
Will invoke #{cmd_string} when first used.
EOF

  else

    return <<EOF
#{to_s}
Invoked #{cmd_string} and parsed its output:
#{json.inspect}
EOF

  end
end

#jsonObject



22
23
24
# File 'lib/git_version/parser.rb', line 22

def json
  @json ||= run_gitversion
end