commander-openflighthpc 1.0.0.pre.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +44 -0
  5. data/.rubocop_todo.yml +77 -0
  6. data/.travis.yml +14 -0
  7. data/CHANGELOG.md +5 -0
  8. data/Gemfile +3 -0
  9. data/LICENSE +51 -0
  10. data/Manifest +38 -0
  11. data/README.md +492 -0
  12. data/Rakefile +13 -0
  13. data/bin/commander +104 -0
  14. data/commander-openflighthpc.gemspec +32 -0
  15. data/lib/commander.rb +36 -0
  16. data/lib/commander/blank.rb +7 -0
  17. data/lib/commander/command.rb +263 -0
  18. data/lib/commander/configure.rb +14 -0
  19. data/lib/commander/core_ext.rb +2 -0
  20. data/lib/commander/core_ext/array.rb +24 -0
  21. data/lib/commander/core_ext/object.rb +8 -0
  22. data/lib/commander/delegates.rb +27 -0
  23. data/lib/commander/help_formatters.rb +52 -0
  24. data/lib/commander/help_formatters/base.rb +24 -0
  25. data/lib/commander/help_formatters/terminal.rb +24 -0
  26. data/lib/commander/help_formatters/terminal/command_help.erb +35 -0
  27. data/lib/commander/help_formatters/terminal/help.erb +36 -0
  28. data/lib/commander/help_formatters/terminal/subcommand_help.erb +23 -0
  29. data/lib/commander/help_formatters/terminal_compact.rb +11 -0
  30. data/lib/commander/help_formatters/terminal_compact/command_help.erb +26 -0
  31. data/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
  32. data/lib/commander/help_formatters/terminal_compact/subcommand_help.erb +15 -0
  33. data/lib/commander/import.rb +5 -0
  34. data/lib/commander/methods.rb +11 -0
  35. data/lib/commander/patches/decimal-integer.rb +17 -0
  36. data/lib/commander/patches/help_formatter_binding.rb +15 -0
  37. data/lib/commander/patches/implicit-short-tags.rb +75 -0
  38. data/lib/commander/patches/option_defaults.rb +23 -0
  39. data/lib/commander/patches/validate_inputs.rb +76 -0
  40. data/lib/commander/platform.rb +7 -0
  41. data/lib/commander/runner.rb +493 -0
  42. data/lib/commander/user_interaction.rb +551 -0
  43. data/lib/commander/version.rb +3 -0
  44. data/spec/command_spec.rb +157 -0
  45. data/spec/configure_spec.rb +37 -0
  46. data/spec/core_ext/array_spec.rb +18 -0
  47. data/spec/core_ext/object_spec.rb +19 -0
  48. data/spec/help_formatters/terminal_compact_spec.rb +69 -0
  49. data/spec/help_formatters/terminal_spec.rb +67 -0
  50. data/spec/methods_spec.rb +61 -0
  51. data/spec/patches/validate_inputs_spec.rb +84 -0
  52. data/spec/runner_spec.rb +672 -0
  53. data/spec/spec_helper.rb +79 -0
  54. data/spec/ui_spec.rb +30 -0
  55. metadata +183 -0
@@ -0,0 +1,79 @@
1
+ require 'rubygems'
2
+ require 'stringio'
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ end
7
+
8
+ # Unshift so that local files load instead of something in gems
9
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
10
+
11
+ # This basically replicates the behavior of `require 'commander/import'`
12
+ # but without adding an `at_exit` hook, which interferes with exit code
13
+ require 'commander'
14
+ require 'commander/methods'
15
+
16
+ # Mock terminal IO streams so we can spec against them
17
+
18
+ def mock_terminal
19
+ @input = StringIO.new
20
+ @output = StringIO.new
21
+ $terminal = HighLine.new @input, @output
22
+ end
23
+
24
+ # Create test command for usage within several specs
25
+
26
+ def create_test_command
27
+ stub_const('Commander::Patches::ValidateInputs::PatchEnabled', false)
28
+ command :test do |c|
29
+ c.syntax = 'test [options] <file>'
30
+ c.description = 'test description'
31
+ c.example 'description', 'command'
32
+ c.example 'description 2', 'command 2'
33
+ c.option '-v', '--verbose', 'verbose description'
34
+ c.when_called do |args, _options|
35
+ format('test %s', args.join)
36
+ end
37
+ end
38
+ @command = command :test
39
+ end
40
+
41
+ # Create a new command runner
42
+
43
+ def new_command_runner(*args, &block)
44
+ Commander::Runner.instance_variable_set :"@singleton", Commander::Runner.new(args)
45
+ program :name, 'test'
46
+ program :version, '1.2.3'
47
+ program :description, 'something'
48
+ create_test_command
49
+ yield if block
50
+ Commander::Runner.instance
51
+ end
52
+
53
+ # Comply with how specs were previously written
54
+
55
+ def command_runner
56
+ Commander::Runner.instance
57
+ end
58
+
59
+ def run(*args)
60
+ new_command_runner(*args) do
61
+ program :help_formatter, Commander::HelpFormatter::Base
62
+ yield if block_given?
63
+ end.run!
64
+ @output.string
65
+ end
66
+
67
+ RSpec.configure do |c|
68
+ c.expect_with(:rspec) do |e|
69
+ e.syntax = :expect
70
+ end
71
+
72
+ c.mock_with(:rspec) do |m|
73
+ m.syntax = :expect
74
+ end
75
+
76
+ c.before(:each) do
77
+ allow(Commander::UI).to receive(:enable_paging)
78
+ end
79
+ end
data/spec/ui_spec.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Commander::UI do
4
+ include Commander::Methods
5
+
6
+ describe '.replace_tokens' do
7
+ it 'should replace tokens within a string, with hash values' do
8
+ result = Commander::UI.replace_tokens 'Welcome :name, enjoy your :object'.freeze, name: 'TJ', object: 'cookie'
9
+ expect(result).to eq('Welcome TJ, enjoy your cookie')
10
+ end
11
+ end
12
+
13
+ describe 'progress' do
14
+ it 'should not die on an empty list' do
15
+ exception = false
16
+ begin
17
+ progress([]) {}
18
+ rescue
19
+ exception = true
20
+ end
21
+ expect(exception).not_to be true
22
+ end
23
+ end
24
+
25
+ describe '.available_editor' do
26
+ it 'should not fail on available editors with shell arguments' do
27
+ expect(Commander::UI.available_editor('sh -c')).to eq('sh -c')
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commander-openflighthpc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.alpha1
5
+ platform: ruby
6
+ authors:
7
+ - Alces Flight Ltd
8
+ - TJ Holowaychuk
9
+ - Gabriel Gilder
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2019-04-03 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: highline
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 1.7.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: 1.7.2
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '3.2'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.2'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: simplecov
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rubocop
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: 0.49.1
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: 0.49.1
85
+ description: The complete solution for Ruby command-line executables. Commander bridges
86
+ the gap between other terminal related libraries you know and love (OptionParser,
87
+ HighLine), while providing many new features, and an elegant API.
88
+ email:
89
+ - flight@openflighthpc.org
90
+ executables:
91
+ - commander
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - ".rspec"
97
+ - ".rubocop.yml"
98
+ - ".rubocop_todo.yml"
99
+ - ".travis.yml"
100
+ - CHANGELOG.md
101
+ - Gemfile
102
+ - LICENSE
103
+ - Manifest
104
+ - README.md
105
+ - Rakefile
106
+ - bin/commander
107
+ - commander-openflighthpc.gemspec
108
+ - lib/commander.rb
109
+ - lib/commander/blank.rb
110
+ - lib/commander/command.rb
111
+ - lib/commander/configure.rb
112
+ - lib/commander/core_ext.rb
113
+ - lib/commander/core_ext/array.rb
114
+ - lib/commander/core_ext/object.rb
115
+ - lib/commander/delegates.rb
116
+ - lib/commander/help_formatters.rb
117
+ - lib/commander/help_formatters/base.rb
118
+ - lib/commander/help_formatters/terminal.rb
119
+ - lib/commander/help_formatters/terminal/command_help.erb
120
+ - lib/commander/help_formatters/terminal/help.erb
121
+ - lib/commander/help_formatters/terminal/subcommand_help.erb
122
+ - lib/commander/help_formatters/terminal_compact.rb
123
+ - lib/commander/help_formatters/terminal_compact/command_help.erb
124
+ - lib/commander/help_formatters/terminal_compact/help.erb
125
+ - lib/commander/help_formatters/terminal_compact/subcommand_help.erb
126
+ - lib/commander/import.rb
127
+ - lib/commander/methods.rb
128
+ - lib/commander/patches/decimal-integer.rb
129
+ - lib/commander/patches/help_formatter_binding.rb
130
+ - lib/commander/patches/implicit-short-tags.rb
131
+ - lib/commander/patches/option_defaults.rb
132
+ - lib/commander/patches/validate_inputs.rb
133
+ - lib/commander/platform.rb
134
+ - lib/commander/runner.rb
135
+ - lib/commander/user_interaction.rb
136
+ - lib/commander/version.rb
137
+ - spec/command_spec.rb
138
+ - spec/configure_spec.rb
139
+ - spec/core_ext/array_spec.rb
140
+ - spec/core_ext/object_spec.rb
141
+ - spec/help_formatters/terminal_compact_spec.rb
142
+ - spec/help_formatters/terminal_spec.rb
143
+ - spec/methods_spec.rb
144
+ - spec/patches/validate_inputs_spec.rb
145
+ - spec/runner_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/ui_spec.rb
148
+ homepage: https://github.com/openflighthpc/commander-openflighthpc
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">"
164
+ - !ruby/object:Gem::Version
165
+ version: 1.3.1
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.7.6
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: The complete solution for Ruby command-line executables
172
+ test_files:
173
+ - spec/command_spec.rb
174
+ - spec/configure_spec.rb
175
+ - spec/core_ext/array_spec.rb
176
+ - spec/core_ext/object_spec.rb
177
+ - spec/help_formatters/terminal_compact_spec.rb
178
+ - spec/help_formatters/terminal_spec.rb
179
+ - spec/methods_spec.rb
180
+ - spec/patches/validate_inputs_spec.rb
181
+ - spec/runner_spec.rb
182
+ - spec/spec_helper.rb
183
+ - spec/ui_spec.rb