belafonte 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f5509c92ec5d0ddd52432d56f34702b797d9240
4
- data.tar.gz: 2b6399b51a131dda9ad8b6458da6581c4e556c01
3
+ metadata.gz: 5c66c85a46a099eb4a313ff1347bdf8878a25df6
4
+ data.tar.gz: e16f2d51e125c35b798aca92ff50d1efaf8b7c03
5
5
  SHA512:
6
- metadata.gz: 598b0bd646258d587cc43a5a8d70bcb67d55795b23243080138bf3ebe1a4a7fcfbcd190659421185e43497609eb6678c99a1136a64e413ab6c8a6808c8d20c3c
7
- data.tar.gz: 1c7c03b1c6da23bd3bb44a3dbd2686660445e60daae8d56078cf6f2bf22fe7b4c3e005f550e7c17a2d56937c859d8afc169d98f17fff0f119f248aa0f8ebdd71
6
+ metadata.gz: 3f4a71a70ffda2e6b232d280ba8e29c6e222a86c2c6cfedae90b3a66ed80921872817926b182fd579522af3e809092da7409482330dcdf9b271d24898e6e7094
7
+ data.tar.gz: 939f72806a0e9be4a1654aecf57e93f837d0834b87d870232541c40dcf7f289f798f66ce5fe700d34a3e1706603ae0c28089c88389a3529f2abca80a2fe49d99
data/belafonte.gemspec CHANGED
@@ -24,4 +24,8 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "simplecov"
25
25
  spec.add_development_dependency "yard"
26
26
  spec.add_development_dependency "toady"
27
+ spec.add_development_dependency "mutant"
28
+ spec.add_development_dependency 'mutant-rspec'
29
+ spec.add_runtime_dependency 'wrapomatic', '~> 0.1'
30
+ spec.add_runtime_dependency 'optionally'
27
31
  end
data/lib/belafonte/app.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'belafonte/dsl'
2
2
  require 'belafonte/rhythm'
3
+ require 'belafonte/validator'
3
4
 
4
5
  module Belafonte
5
6
  # An application container
@@ -18,5 +19,6 @@ module Belafonte
18
19
  @kernel = kernel
19
20
  @parent = parent
20
21
  end
22
+
21
23
  end
22
24
  end
@@ -1,4 +1,6 @@
1
1
  require 'belafonte/errors'
2
+ require 'belafonte/argument/argv_processor'
3
+ require 'belafonte/argument/occurrence_normalizer'
2
4
 
3
5
  module Belafonte
4
6
  # Represents a command line argument
@@ -12,15 +14,7 @@ module Belafonte
12
14
  end
13
15
 
14
16
  def process(argv)
15
- case times
16
- when -1
17
- argv
18
- else
19
- if argv.length < times
20
- raise Belafonte::Errors::TooFewArguments.new("Not enough arguments were given")
21
- end
22
- argv.first(times)
23
- end.clone
17
+ ARGVProcessor.process(times, argv).clone
24
18
  end
25
19
 
26
20
  def unlimited?
@@ -29,20 +23,23 @@ module Belafonte
29
23
 
30
24
  private
31
25
  def normalize
32
- raise Belafonte::Errors::NoName.new("Arguments must be named") unless name
33
-
34
- case times
35
- when nil
36
- @times = 1
37
- when :unlimited
38
- @times = -1
39
- @unlimited = true
40
- else
41
- @times = times.to_i
42
- end
43
-
44
- raise Belafonte::Errors::InvalidArgument.new("There must be at least one occurrence") unless times > 0 || unlimited?
26
+ normalize_name
27
+ normalize_times
45
28
  end
46
29
 
30
+ def normalize_times
31
+ @unlimited = times.eql?(:unlimited)
32
+ @times = OccurrenceNormalizer.normalize(times)
33
+ validate_occurrences
34
+ end
35
+
36
+ def validate_occurrences
37
+ raise Errors::InvalidArgument.new("There must be at least one occurrence") unless times > 0 || unlimited?
38
+ end
39
+
40
+ def normalize_name
41
+ raise Errors::NoName.new("Arguments must be named") unless name
42
+ @name = name.to_sym
43
+ end
47
44
  end
48
45
  end
@@ -0,0 +1,19 @@
1
+ require 'belafonte/argument/argv_processor/processor'
2
+ require 'belafonte/argument/argv_processor/unlimited'
3
+
4
+ module Belafonte
5
+ class Argument
6
+ module ARGVProcessor
7
+ DEFAULT = Processor
8
+ SPECIAL = {
9
+ -1 => Unlimited
10
+ }
11
+
12
+ def self.process(occurrences, arguments)
13
+ (SPECIAL[occurrences] || DEFAULT).
14
+ new(occurrences, arguments).
15
+ processed
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ require 'belafonte/errors'
2
+
3
+ module Belafonte
4
+ class Argument
5
+ module ARGVProcessor
6
+ class Processor
7
+ attr_reader :occurrences, :arguments
8
+
9
+ def initialize(occurrences, arguments)
10
+ @occurrences, @arguments = occurrences, arguments
11
+ end
12
+
13
+ def processed
14
+ validate_arguments
15
+ arguments.first(occurrences)
16
+ end
17
+
18
+ private
19
+ def validate_arguments
20
+ raise Errors::TooFewArguments.new("Not enough arguments were given") unless valid_arguments_length?
21
+ end
22
+
23
+ def valid_arguments_length?
24
+ arguments.length >= occurrences
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'belafonte/argument/argv_processor/processor'
2
+
3
+ module Belafonte
4
+ class Argument
5
+ module ARGVProcessor
6
+ class Unlimited < Processor
7
+ def processed
8
+ arguments
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ require 'belafonte/argument/occurrence_normalizer/normalizer'
2
+ require 'belafonte/argument/occurrence_normalizer/unlimited'
3
+ require 'belafonte/argument/occurrence_normalizer/single'
4
+
5
+ module Belafonte
6
+ class Argument
7
+ module OccurrenceNormalizer
8
+ DEFAULT = Normalizer
9
+ SPECIAL = {
10
+ :unlimited => Unlimited,
11
+ nil => Single
12
+ }
13
+
14
+ def self.normalize(occurrences)
15
+ (SPECIAL[occurrences] || DEFAULT).new(occurrences).normalized
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Belafonte
2
+ class Argument
3
+ module OccurrenceNormalizer
4
+ class Normalizer
5
+ attr_reader :occurrences
6
+
7
+ def initialize(occurrences)
8
+ @occurrences = occurrences
9
+ end
10
+
11
+ def normalized
12
+ Integer(occurrences)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'belafonte/argument/occurrence_normalizer/normalizer'
2
+
3
+ module Belafonte
4
+ class Argument
5
+ module OccurrenceNormalizer
6
+ class Single < Normalizer
7
+ def normalized
8
+ occurrences ? nil : 1
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'belafonte/argument/occurrence_normalizer/normalizer'
2
+
3
+ module Belafonte
4
+ class Argument
5
+ module OccurrenceNormalizer
6
+ class Unlimited < Normalizer
7
+ def normalized
8
+ occurrences.eql?(:unlimited) ? -1 : nil
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,12 +1,17 @@
1
1
  require 'belafonte/errors'
2
+ require 'optionally/required'
2
3
 
3
4
  module Belafonte
4
5
  # Processes command line arguments
5
6
  class ArgumentProcessor
7
+ include Optionally::Required
8
+
6
9
  def initialize(options = {})
7
- @argv = options[:argv] || []
8
- @arguments = options[:arguments] || []
9
- process!
10
+ check_required_options(options, :argv, :arguments)
11
+
12
+ @argv = options[:argv]
13
+ @arguments = options[:arguments]
14
+ process
10
15
  end
11
16
 
12
17
  def processed
@@ -14,7 +19,7 @@ module Belafonte
14
19
  end
15
20
 
16
21
  private
17
- def process!
22
+ def process
18
23
  argv = @argv.clone
19
24
  arguments.each do |arg|
20
25
  values = arg.process(argv)
@@ -25,19 +30,13 @@ module Belafonte
25
30
  argv.shift(values.length)
26
31
  end
27
32
 
28
- validate_processed_args
29
-
30
33
  if argv.length > 0
31
- raise Belafonte::Errors::TooManyArguments.new("More args provided than I can handle")
34
+ raise Errors::TooManyArguments.new("More args provided than I can handle")
32
35
  end
33
36
  end
34
37
 
35
38
  def arguments
36
39
  @arguments
37
40
  end
38
-
39
- def validate_processed_args
40
- raise Belafonte::Errors::TooFewArguments.new("You didn't provide enough arguments") if processed.values.any? {|arg| arg.empty? && !arg.unlimited?}
41
- end
42
41
  end
43
42
  end
@@ -48,14 +48,7 @@ module Belafonte
48
48
  end
49
49
 
50
50
  def arg(name, arg_options = {})
51
- if has_unlimited_arg?
52
- raise Belafonte::Errors::InvalidArgument.new("You may not add other arguments after an unlimited argument")
53
-
54
- else
55
-
56
- args.push(Belafonte::Argument.new(arg_options.merge({name: name})))
57
-
58
- end
51
+ args.push(Belafonte::Argument.new(arg_options.merge({name: name})))
59
52
  end
60
53
 
61
54
  def subcommands
@@ -21,5 +21,8 @@ module Belafonte
21
21
 
22
22
  # UnknownCommand poop
23
23
  UnknownCommand = Class.new(StandardError)
24
+
25
+ # ExitStatus
26
+ ExitStatus = Class.new(StandardError)
24
27
  end
25
28
  end
@@ -11,21 +11,21 @@ module Belafonte
11
11
  attr_reader :name, :short, :long, :description
12
12
 
13
13
  def self.shortify(option)
14
- "-#{option.to_s}"
14
+ "-#{option}"
15
15
  end
16
16
 
17
17
  def self.longify(option)
18
- "--#{option.to_s}"
18
+ "--#{option}"
19
19
  end
20
20
 
21
- def normalize_flag(flag)
21
+ def self.normalize_flag(flag)
22
22
  flag.to_s.strip.gsub(/\s+/, '-')
23
23
  end
24
24
 
25
25
  def initialize(options = {})
26
26
  options[:name].tap do |name|
27
27
  unless name
28
- raise Belafonte::Errors::NoName.new("Flag name cannot be blank")
28
+ raise Errors::NoName.new("Flag name cannot be blank")
29
29
  end
30
30
  @name = name.to_sym
31
31
  end
@@ -48,11 +48,6 @@ module Belafonte
48
48
  ].flatten
49
49
  end
50
50
 
51
- def variations
52
- short + long
53
- end
54
- alias_method :flags, :variations
55
-
56
51
  private
57
52
  def shortify(option)
58
53
  self.class.shortify(option)
@@ -62,11 +57,15 @@ module Belafonte
62
57
  self.class.longify(option)
63
58
  end
64
59
 
60
+ def normalize_flag(flag)
61
+ self.class.normalize_flag(flag)
62
+ end
63
+
65
64
  def flag_array(items)
66
65
  [items].
67
66
  flatten.
68
67
  map {|flag| normalize_flag(flag)}.
69
- reject {|flag| flag == ''}
68
+ reject {|flag| flag.eql?('')}
70
69
  end
71
70
  end
72
71
  end
@@ -2,12 +2,9 @@ module Belafonte
2
2
  module Help
3
3
  module AppExtensions
4
4
  def root
5
- if parent
6
- parent.extend(AppExtensions)
7
- parent.root
8
- else
9
- self
10
- end
5
+ return self unless parent
6
+ parent.extend(AppExtensions)
7
+ parent.root
11
8
  end
12
9
 
13
10
  def root?
@@ -33,27 +30,26 @@ module Belafonte
33
30
  end
34
31
 
35
32
  def command_arg
36
- if Belafonte::Help::Generator.target == self && has_subcommands?
37
- ' command'
38
- else
39
- ''
40
- end
33
+ return '' unless show_command_arg?
34
+ ' command'
35
+ end
36
+
37
+ def show_command_arg?
38
+ Belafonte::Help::Generator.target == self && has_subcommands?
41
39
  end
42
40
 
43
41
  def display_flags(cmd)
44
- if has_flags?
45
- " [#{cmd} options]"
46
- else
47
- ''
48
- end
42
+ return '' unless has_flags?
43
+ " [#{cmd} options]"
49
44
  end
50
45
 
51
46
  def display_args
52
- if has_args?
53
- " #{non_command_args.map(&:name).map(&:to_s).join(' ')}"
54
- else
55
- ''
56
- end
47
+ return '' unless has_args?
48
+ " #{non_command_arg_names.join(' ')}"
49
+ end
50
+
51
+ def non_command_arg_names
52
+ non_command_args.map(&:name).map(&:to_s)
57
53
  end
58
54
 
59
55
  def signature
@@ -83,11 +79,13 @@ module Belafonte
83
79
  end
84
80
 
85
81
  def sorted_flags
86
- (configured_switches + configured_options).sort {|a,b| a.name <=> b.name}
82
+ (configured_switches + configured_options).
83
+ sort {|left,right| left.name <=> right.name}
87
84
  end
88
85
 
89
86
  def sorted_commands
90
- configured_subcommands.sort {|a,b| a.name <=> b.name}
87
+ configured_subcommands.
88
+ sort {|left,right| left.name <=> right.name}
91
89
  end
92
90
  end
93
91
  end
@@ -1,4 +1,4 @@
1
- require 'belafonte/wrapomatic'
1
+ require 'wrapomatic'
2
2
  require 'belafonte/help/app_extensions'
3
3
  require 'belafonte/help/flag_extensions'
4
4
  require 'belafonte/help/command_extensions'
@@ -30,13 +30,13 @@ module Belafonte
30
30
  end
31
31
 
32
32
  def name_section
33
- "NAME\n#{Wrapomatic.wrap("#{app.display_title} - #{app.summary}", 1)}\n"
33
+ "NAME\n#{Wrapomatic.wrap("#{app.display_title} - #{app.summary}", indents: 1)}\n"
34
34
  end
35
35
 
36
36
  def synopsis
37
- synopsis = "\nSYNOPSIS\n#{Wrapomatic.wrap(app.full_path, 1)}"
37
+ synopsis = "\nSYNOPSIS\n#{Wrapomatic.wrap(app.full_path, indents: 1)}"
38
38
  if app.description
39
- synopsis += "\n\n#{Wrapomatic.wrap(app.display_description, 1)}"
39
+ synopsis += "\n\n#{Wrapomatic.wrap(app.display_description, indents: 1)}"
40
40
  end
41
41
  synopsis + "\n"
42
42
  end
@@ -45,9 +45,9 @@ module Belafonte
45
45
  options = "\nOPTIONS\n"
46
46
  app.sorted_flags.each do |flag|
47
47
  flag.extend(FlagExtensions)
48
- options += "#{Wrapomatic.wrap(flag.signature, 1)}\n"
48
+ options += "#{Wrapomatic.wrap(flag.signature, indents: 1)}\n"
49
49
  end
50
- options += "#{Wrapomatic.wrap('-h, --help - Shows this message', 1)}"
50
+ options += "#{Wrapomatic.wrap('-h, --help - Shows this message', indents: 1)}"
51
51
 
52
52
  options + "\n"
53
53
  end
@@ -58,7 +58,7 @@ module Belafonte
58
58
 
59
59
  app.sorted_commands.each do |command|
60
60
  command.extend(CommandExtensions)
61
- commands += "#{Wrapomatic.wrap("#{command.display_title} - #{command.display_summary}", 1)}\n"
61
+ commands += "#{Wrapomatic.wrap("#{command.display_title} - #{command.display_summary}", indents: 1)}\n"
62
62
  end
63
63
 
64
64
  commands + "\n"
@@ -4,11 +4,11 @@ module Belafonte
4
4
  module Helpers
5
5
  module Sharing
6
6
  def share(key, value)
7
- Belafonte::Senora.store(key, value)
7
+ Senora.store(key, value)
8
8
  end
9
9
 
10
10
  def partake(key)
11
- Belafonte::Senora.retrieve(key)
11
+ Senora.retrieve(key)
12
12
  end
13
13
  end
14
14
  end
@@ -70,31 +70,27 @@ module Belafonte
70
70
  end
71
71
 
72
72
  def switches
73
- data[:switches]
73
+ data.fetch(:switches)
74
74
  end
75
75
 
76
76
  def switch_results
77
- parsed[:switches]
77
+ parsed.fetch(:switches)
78
78
  end
79
79
 
80
80
  def option_results
81
- parsed[:options]
81
+ parsed.fetch(:options)
82
82
  end
83
83
 
84
84
  def options
85
- data[:options]
86
- end
87
-
88
- def commands
89
- data[:commands]
85
+ data.fetch(:options)
90
86
  end
91
87
 
92
88
  def arguments
93
- data[:arguments]
89
+ data.fetch(:arguments)
94
90
  end
95
91
 
96
92
  def argv
97
- data[:argv]
93
+ data.fetch(:argv)
98
94
  end
99
95
 
100
96
  def data
@@ -1,47 +1,65 @@
1
- require 'optparse'
1
+ #require 'optparse'
2
2
  require 'belafonte/errors'
3
3
  require 'belafonte/help'
4
4
  require 'belafonte/parser'
5
5
  require 'belafonte/helpers'
6
- require 'belafonte/wrapomatic'
6
+ require 'wrapomatic'
7
7
 
8
8
  module Belafonte
9
9
  module Rhythm
10
10
  def execute!
11
- (@parser = Parser.new(
12
- switches: configured_switches,
13
- options: configured_options,
14
- commands: configured_subcommands,
15
- arguments: configured_args,
16
- argv: @argv
17
- )).parsed.tap do |parsed|
18
- @switches = parsed[:switches]
19
- @options = parsed[:options]
20
- @arguments = parsed[:args]
21
- activate_help! if parsed[:help]
22
- end
23
-
11
+ parse_command_line
24
12
  @command = arg(:command).shift if arg(:command)
25
13
 
14
+ calculate_exit_status
15
+ end
16
+
17
+ private
18
+ def parent
19
+ @parent
20
+ end
21
+
22
+ def calculate_exit_status
26
23
  begin
24
+ validate_app
27
25
  run_setup
28
26
 
29
- unless dispatch || show_help || run_handle
27
+ unless (status = dispatch || show_help || run_handle || nil)
30
28
  stderr.puts "No handler for the provided command line"
31
29
  return 1
32
30
  end
31
+
32
+ rescue SystemExit => exit_requested
33
+ return exit_requested.status
33
34
  rescue => uncaught_error
34
35
  stderr.puts "The application encountered the following error:"
35
- stderr.puts Wrapomatic.wrap(uncaught_error.to_s, 1)
36
+ stderr.puts Wrapomatic.wrap(uncaught_error.to_s, indents: 1)
36
37
  return 255
37
38
  end
38
39
 
39
- 0
40
+ status
40
41
  end
41
42
 
42
- private
43
- def parent
44
- @parent
43
+ def parse_command_line
44
+ (@parser = Parser.new(
45
+ switches: configured_switches,
46
+ options: configured_options,
47
+ commands: configured_subcommands,
48
+ arguments: configured_args,
49
+ argv: @argv
50
+ )).parsed.tap do |parsed|
51
+ @switches = parsed[:switches]
52
+ @options = parsed[:options]
53
+ @arguments = parsed[:args]
54
+ activate_help! if parsed[:help]
55
+ end
56
+ end
57
+
58
+ def validate_app
59
+ validator = Belafonte::Validator.new(self.class)
60
+ unless validator.valid?
61
+ raise "The application #{validator.app_title} has the following issues: #{validator.errors}"
62
+ end
45
63
  end
46
64
 
47
65
  def subcommand_instance(command)
@@ -54,29 +72,29 @@ module Belafonte
54
72
  end
55
73
 
56
74
  def dispatch
57
- return false if @command.nil?
75
+ return nil if @command.nil?
58
76
  handler = subcommand_instance(@command)
59
77
 
60
78
  unless handler
61
79
  activate_help!
62
- return false
80
+ return nil
63
81
  end
64
82
 
65
83
  handler.activate_help! if help_active?
66
84
  handler.execute!
67
- true
85
+ 0
68
86
  end
69
87
 
70
88
  def show_help
71
- return false unless help_active?
89
+ return nil unless help_active?
72
90
  stdout.print Belafonte::Help.content_for(self)
73
- true
91
+ 0
74
92
  end
75
93
 
76
94
  def run_handle
77
- return false unless respond_to?(:handle)
95
+ return nil unless respond_to?(:handle)
78
96
  handle
79
- true
97
+ 0
80
98
  end
81
99
 
82
100
  def run_setup
@@ -11,9 +11,5 @@ module Belafonte
11
11
  def self.data
12
12
  @data ||= {}
13
13
  end
14
-
15
- def self.reset
16
- @data = {}
17
- end
18
14
  end
19
15
  end
@@ -0,0 +1,65 @@
1
+ module Belafonte
2
+ class Validator
3
+ attr_reader :errors
4
+
5
+ def initialize(app)
6
+ @app = app
7
+ @errors = {}
8
+ end
9
+
10
+ def valid?
11
+ error_if_app_lacks_title
12
+ error_if_app_has_multiple_unlimited_args
13
+ error_if_app_has_mounts_and_unlimited_args
14
+
15
+ errors.empty?
16
+ end
17
+
18
+ def app_title
19
+ app.info(:title)
20
+ end
21
+
22
+ private
23
+ def app
24
+ @app
25
+ end
26
+
27
+ def record_error(subject, message)
28
+ errors[subject] = message
29
+ end
30
+
31
+ def record_error_if(condition, subject, message)
32
+ record_error(subject, message) if condition
33
+ end
34
+
35
+ def error_if_app_lacks_title
36
+ record_error_if(
37
+ app.info(:title).nil?,
38
+ :title,
39
+ 'must be present'
40
+ )
41
+ end
42
+
43
+ def error_if_app_has_multiple_unlimited_args
44
+ record_error_if(
45
+ unlimited_args.length > 1,
46
+ :args,
47
+ "cannot have more than one unlimited arg")
48
+ end
49
+
50
+ def error_if_app_has_mounts_and_unlimited_args
51
+ if unlimited_args.length > 1 && command_arg_present?
52
+ record_error(:mounts, 'cannot mount apps if you have unlimited args')
53
+ record_error(:args, 'cannot have unlimited args if you mount apps')
54
+ end
55
+ end
56
+
57
+ def unlimited_args
58
+ app.args.select {|arg| arg.unlimited?}
59
+ end
60
+
61
+ def command_arg_present?
62
+ !unlimited_args.find {|arg| arg.name.equal?(:command)}.nil?
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Belafonte
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belafonte
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Walters
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2016-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,62 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mutant
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: mutant-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: wrapomatic
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: optionally
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
97
153
  description:
98
154
  email:
99
155
  - dwalters@engineyard.com
@@ -107,6 +163,13 @@ files:
107
163
  - lib/belafonte.rb
108
164
  - lib/belafonte/app.rb
109
165
  - lib/belafonte/argument.rb
166
+ - lib/belafonte/argument/argv_processor.rb
167
+ - lib/belafonte/argument/argv_processor/processor.rb
168
+ - lib/belafonte/argument/argv_processor/unlimited.rb
169
+ - lib/belafonte/argument/occurrence_normalizer.rb
170
+ - lib/belafonte/argument/occurrence_normalizer/normalizer.rb
171
+ - lib/belafonte/argument/occurrence_normalizer/single.rb
172
+ - lib/belafonte/argument/occurrence_normalizer/unlimited.rb
110
173
  - lib/belafonte/argument_processor.rb
111
174
  - lib/belafonte/dsl.rb
112
175
  - lib/belafonte/dsl/definition.rb
@@ -129,8 +192,8 @@ files:
129
192
  - lib/belafonte/rhythm.rb
130
193
  - lib/belafonte/senora.rb
131
194
  - lib/belafonte/switch.rb
195
+ - lib/belafonte/validator.rb
132
196
  - lib/belafonte/version.rb
133
- - lib/belafonte/wrapomatic.rb
134
197
  homepage: https://github.com/ess/belafonte
135
198
  licenses:
136
199
  - MIT
@@ -1,51 +0,0 @@
1
- module Belafonte
2
- class Wrapomatic
3
- attr_reader :text, :lines, :indents, :columns
4
-
5
- def self.wrap(text, indents = 0, columns = 80)
6
- new(text, indents, columns).wrapped
7
- end
8
-
9
- def initialize(text, indents = 0, columns = 80)
10
- @text = text.split("\n").join(' ')
11
- @indents = indents
12
- @columns = columns
13
- @lines = []
14
- indentomize
15
- end
16
-
17
- def wrapped
18
- lines.join("\n")
19
- end
20
-
21
- private
22
-
23
- def indentomize
24
- until (line = next_line).nil?
25
- @lines.push(line)
26
- end
27
- end
28
-
29
- def next_line
30
- return nil if text.length == 0
31
- offset + text_up_to(space_before_location(columns - offset.length - 1))
32
- end
33
-
34
- def space_before_location(start)
35
- return start if start > text.length
36
- text.rindex(/(\s|-)/, start) || start
37
- end
38
-
39
- def text_up_to(count)
40
- text.slice!(0 .. count)
41
- end
42
-
43
- def indentation
44
- ' '
45
- end
46
-
47
- def offset
48
- indentation * indents
49
- end
50
- end
51
- end