Class: Annotate::Parser

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

Overview

Class for handling command line arguments

Constant Summary collapse

DEFAULT_OPTIONS =
{
  target_action: :do_annotations,
  exit: false
}.freeze
ANNOTATION_POSITIONS =
%w[before top after bottom].freeze
FILE_TYPE_POSITIONS =
%w[position_in_class position_in_factory position_in_fixture position_in_test position_in_routes position_in_serializer].freeze
EXCLUSION_LIST =
%w[tests fixtures factories serializers].freeze
FORMAT_TYPES =
%w[bare rdoc yard markdown].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, env) ⇒ Parser

Returns a new instance of Parser.



22
23
24
25
26
# File 'lib/annotate/parser.rb', line 22

def initialize(args, env)
  @args = args
  @options = DEFAULT_OPTIONS.dup
  @env = env
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



10
11
12
# File 'lib/annotate/parser.rb', line 10

def args
  @args
end

#envObject (readonly)

Returns the value of attribute env.



10
11
12
# File 'lib/annotate/parser.rb', line 10

def env
  @env
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/annotate/parser.rb', line 10

def options
  @options
end

Class Method Details

.parse(args, env = {}) ⇒ Object

rubocop:disable Metrics/ClassLength



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

def self.parse(args, env = {})
  new(args, env).parse
end

Instance Method Details

#parseObject



28
29
30
31
32
33
34
35
# File 'lib/annotate/parser.rb', line 28

def parse
  # To split up because right now this method parses and commits
  parser.parse!(args)

  commit

  options
end