tty 0.8.1 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +18 -0
  3. data/README.md +3 -1
  4. data/lib/tty.rb +1 -1
  5. data/lib/tty/cli.rb +0 -1
  6. data/lib/tty/cmd.rb +0 -1
  7. data/lib/tty/commands/add.rb +0 -1
  8. data/lib/tty/commands/new.rb +5 -6
  9. data/lib/tty/gemspec.rb +0 -1
  10. data/lib/tty/licenses.rb +0 -1
  11. data/lib/tty/path_helpers.rb +0 -1
  12. data/lib/tty/plugins.rb +1 -1
  13. data/lib/tty/plugins/plugin.rb +1 -1
  14. data/lib/tty/templater.rb +0 -1
  15. data/lib/tty/version.rb +2 -2
  16. data/tty.gemspec +21 -18
  17. data/tty.manifest +7 -0
  18. metadata +63 -84
  19. data/.gitignore +0 -19
  20. data/.rspec +0 -4
  21. data/.travis.yml +0 -35
  22. data/.yardopts +0 -4
  23. data/CODE_OF_CONDUCT.md +0 -49
  24. data/Gemfile +0 -17
  25. data/Rakefile +0 -8
  26. data/appveyor.yml +0 -22
  27. data/images/tty.png +0 -0
  28. data/spec/fixtures/foo-0.0.1.gemspec +0 -17
  29. data/spec/integration/add_desc_args_spec.rb +0 -341
  30. data/spec/integration/add_force_spec.rb +0 -98
  31. data/spec/integration/add_namespaced_spec.rb +0 -291
  32. data/spec/integration/add_spec.rb +0 -535
  33. data/spec/integration/add_subcommand_spec.rb +0 -259
  34. data/spec/integration/new_author_spec.rb +0 -19
  35. data/spec/integration/new_license_spec.rb +0 -39
  36. data/spec/integration/new_namespaced_spec.rb +0 -228
  37. data/spec/integration/new_spec.rb +0 -354
  38. data/spec/integration/new_test_spec.rb +0 -21
  39. data/spec/integration/start_spec.rb +0 -21
  40. data/spec/spec_helper.rb +0 -73
  41. data/spec/unit/gemspec_spec.rb +0 -17
  42. data/spec/unit/plugins/activate_spec.rb +0 -13
  43. data/spec/unit/plugins/load_from_spec.rb +0 -28
  44. data/spec/unit/plugins/plugin/load_spec.rb +0 -32
  45. data/spec/unit/plugins/plugin/new_spec.rb +0 -13
  46. data/spec/unit/tty_spec.rb +0 -14
  47. data/tasks/console.rake +0 -11
  48. data/tasks/coverage.rake +0 -11
  49. data/tasks/spec.rake +0 -29
@@ -1,354 +0,0 @@
1
- RSpec.describe 'teletype new', type: :cli do
2
-
3
- it "generates cli application" do
4
- app_name = tmp_path('newcli')
5
-
6
- output = <<-OUT
7
- Creating gem 'newcli'...
8
- create tmp/newcli/Gemfile
9
- create tmp/newcli/lib/newcli.rb
10
- create tmp/newcli/lib/newcli/version.rb
11
- create tmp/newcli/newcli.gemspec
12
- create tmp/newcli/Rakefile
13
- create tmp/newcli/README.md
14
- create tmp/newcli/bin/console
15
- create tmp/newcli/bin/setup
16
- create tmp/newcli/.gitignore
17
- create tmp/newcli/.travis.yml
18
- create tmp/newcli/.rspec
19
- create tmp/newcli/spec/spec_helper.rb
20
- create tmp/newcli/spec/newcli_spec.rb
21
- append tmp/newcli/README.md
22
- inject tmp/newcli/newcli.gemspec
23
- create tmp/newcli/lib/newcli/cli.rb
24
- create tmp/newcli/lib/newcli/command.rb
25
- create tmp/newcli/exe/newcli
26
- create tmp/newcli/LICENSE.txt
27
- create tmp/newcli/lib/newcli/commands/.gitkeep
28
- create tmp/newcli/lib/newcli/templates/.gitkeep
29
- create tmp/newcli/spec/integration/.gitkeep
30
- create tmp/newcli/spec/support/.gitkeep
31
- create tmp/newcli/spec/unit/.gitkeep
32
- Initializing git repo in #{app_name}
33
-
34
- Your teletype project has been created successfully.
35
-
36
- Run "teletype help" for more commands.
37
- OUT
38
-
39
- command = "teletype new #{app_name} --no-coc --no-color --license mit --no-ext"
40
- out, err, status = Open3.capture3(command)
41
-
42
- expect(out).to include(output)
43
- expect(err).to eq('')
44
- expect(status.exitstatus).to eq(0)
45
-
46
- within_dir(app_name) do
47
-
48
- # doesn't generate coc
49
- expect(::File.exist?('CODE_OF_CONDUCT.md')).to eq(false)
50
-
51
- # doesn't generate ext
52
- expect(::File.exist?("ext/newcli/extconf.rb")).to eq(false)
53
-
54
- expect(::File.read('LICENSE.txt')).to match(/The MIT License \(MIT\)/)
55
-
56
- # newcli.gemspec
57
- gemspec = ::File.read('newcli.gemspec')
58
-
59
- expect(gemspec).to match(/spec.license\s+= \"MIT\"/)
60
-
61
- expect(gemspec).to match(%r{
62
- spec.add_dependency "tty-color", "~> \d+.\d+.\d+"
63
- spec.add_dependency "tty-command", "~> \d+.\d+.\d+"
64
- spec.add_dependency "tty-config", "~> \d+.\d+.\d+"
65
- spec.add_dependency "tty-cursor", "~> \d+.\d+.\d+"
66
- spec.add_dependency "tty-editor", "~> \d+.\d+.\d+"
67
- spec.add_dependency "tty-file", "~> \d+.\d+.\d+"
68
- spec.add_dependency "tty-font", "~> \d+.\d+.\d+"
69
- spec.add_dependency "tty-markdown", "~> \d+.\d+.\d+"
70
- spec.add_dependency "tty-pager", "~> \d+.\d+.\d+"
71
- spec.add_dependency "tty-platform", "~> \d+.\d+.\d+"
72
- spec.add_dependency "tty-progressbar", "~> \d+.\d+.\d+"
73
- spec.add_dependency "tty-prompt", "~> \d+.\d+.\d+"
74
- spec.add_dependency "tty-screen", "~> \d+.\d+.\d+"
75
- spec.add_dependency "tty-spinner", "~> \d+.\d+.\d+"
76
- spec.add_dependency "tty-table", "~> \d+.\d+.\d+"
77
- spec.add_dependency "tty-tree", "~> \d+.\d+.\d+"
78
- spec.add_dependency "tty-which", "~> \d+.\d+.\d+"
79
- spec.add_dependency "pastel", "~> \d+.\d+.\d+"
80
- spec.add_dependency "thor", "~> \d+.\d+.\d+"
81
- })
82
-
83
- # exe/newcli
84
- #
85
- expect(::File.read('exe/newcli')).to eq(<<-EOS)
86
- #!/usr/bin/env ruby
87
- # frozen_string_literal: true
88
-
89
- lib_path = File.expand_path('../lib', __dir__)
90
- $:.unshift(lib_path) if !$:.include?(lib_path)
91
- require 'newcli/cli'
92
-
93
- Signal.trap('INT') do
94
- warn(\"\\n\#{caller.join(\"\\n\")}: interrupted\")
95
- exit(1)
96
- end
97
-
98
- begin
99
- Newcli::CLI.start
100
- rescue Newcli::CLI::Error => err
101
- puts \"ERROR: \#{err.message}\"
102
- exit 1
103
- end
104
- EOS
105
-
106
- # lib/newcli/cli.rb
107
- #
108
- expect(::File.read('lib/newcli/cli.rb')).to eq(<<-EOS)
109
- # frozen_string_literal: true
110
-
111
- require 'thor'
112
-
113
- module Newcli
114
- # Handle the application command line parsing
115
- # and the dispatch to various command objects
116
- #
117
- # @api public
118
- class CLI < Thor
119
- # Error raised by this runner
120
- Error = Class.new(StandardError)
121
-
122
- desc 'version', 'newcli version'
123
- def version
124
- require_relative 'version'
125
- puts \"v\#{Newcli::VERSION}\"
126
- end
127
- map %w(--version -v) => :version
128
- end
129
- end
130
- EOS
131
-
132
- # lib/newcli/cmd.rb
133
- #
134
- expect(::File.read('lib/newcli/command.rb')).to eq(<<-EOS)
135
- # frozen_string_literal: true
136
-
137
- require 'forwardable'
138
-
139
- module Newcli
140
- class Command
141
- extend Forwardable
142
-
143
- def_delegators :command, :run
144
-
145
- # Execute this command
146
- #
147
- # @api public
148
- def execute(*)
149
- raise(
150
- NotImplementedError,
151
- "\#{self.class}#\#{__method__} must be implemented"
152
- )
153
- end
154
-
155
- # The external commands runner
156
- #
157
- # @see http://www.rubydoc.info/gems/tty-command
158
- #
159
- # @api public
160
- def command(**options)
161
- require 'tty-command'
162
- TTY::Command.new(options)
163
- end
164
-
165
- # The cursor movement
166
- #
167
- # @see http://www.rubydoc.info/gems/tty-cursor
168
- #
169
- # @api public
170
- def cursor
171
- require 'tty-cursor'
172
- TTY::Cursor
173
- end
174
-
175
- # Open a file or text in the user's preferred editor
176
- #
177
- # @see http://www.rubydoc.info/gems/tty-editor
178
- #
179
- # @api public
180
- def editor
181
- require 'tty-editor'
182
- TTY::Editor
183
- end
184
-
185
- # File manipulation utility methods
186
- #
187
- # @see http://www.rubydoc.info/gems/tty-file
188
- #
189
- # @api public
190
- def generator
191
- require 'tty-file'
192
- TTY::File
193
- end
194
-
195
- # Terminal output paging
196
- #
197
- # @see http://www.rubydoc.info/gems/tty-pager
198
- #
199
- # @api public
200
- def pager(**options)
201
- require 'tty-pager'
202
- TTY::Pager.new(options)
203
- end
204
-
205
- # Terminal platform and OS properties
206
- #
207
- # @see http://www.rubydoc.info/gems/tty-pager
208
- #
209
- # @api public
210
- def platform
211
- require 'tty-platform'
212
- TTY::Platform.new
213
- end
214
-
215
- # The interactive prompt
216
- #
217
- # @see http://www.rubydoc.info/gems/tty-prompt
218
- #
219
- # @api public
220
- def prompt(**options)
221
- require 'tty-prompt'
222
- TTY::Prompt.new(options)
223
- end
224
-
225
- # Get terminal screen properties
226
- #
227
- # @see http://www.rubydoc.info/gems/tty-screen
228
- #
229
- # @api public
230
- def screen
231
- require 'tty-screen'
232
- TTY::Screen
233
- end
234
-
235
- # The unix which utility
236
- #
237
- # @see http://www.rubydoc.info/gems/tty-which
238
- #
239
- # @api public
240
- def which(*args)
241
- require 'tty-which'
242
- TTY::Which.which(*args)
243
- end
244
-
245
- # Check if executable exists
246
- #
247
- # @see http://www.rubydoc.info/gems/tty-which
248
- #
249
- # @api public
250
- def exec_exist?(*args)
251
- require 'tty-which'
252
- TTY::Which.exist?(*args)
253
- end
254
- end
255
- end
256
- EOS
257
-
258
- # Ensure executable
259
- #
260
- unless Gem.win_platform?
261
- expect(::File.executable?("exe/newcli")).to eq(true)
262
- end
263
- end
264
- end
265
-
266
- it "generates C extensions boilerplate" do
267
- app_name = tmp_path('newcli')
268
-
269
- output = <<-OUT
270
- create tmp/newcli/ext/newcli/extconf.rb
271
- create tmp/newcli/ext/newcli/newcli.h
272
- create tmp/newcli/ext/newcli/newcli.c
273
- OUT
274
-
275
- command = "teletype new #{app_name} --ext --no-color --license mit"
276
- out, err, status = Open3.capture3(command)
277
-
278
- expect(out).to include(output)
279
- expect(err).to eq('')
280
- expect(status.exitstatus).to eq(0)
281
-
282
- within_dir(app_name) do
283
- expect(::File.exist?("ext/newcli/extconf.rb")).to eq(true)
284
- end
285
- end
286
-
287
- it "generates code of conduct file" do
288
- app_name = tmp_path('newcli')
289
-
290
- output = <<-OUT
291
- create tmp/newcli/CODE_OF_CONDUCT.md
292
- OUT
293
-
294
- command = "teletype new #{app_name} --coc --no-color --license mit"
295
- out, err, status = Open3.capture3(command)
296
-
297
- expect(out).to match(output)
298
- expect(err).to eq('')
299
- expect(status.exitstatus).to eq(0)
300
-
301
- within_dir(app_name) do
302
- expect(::File.exist?("CODE_OF_CONDUCT.md")).to eq(true)
303
- end
304
- end
305
-
306
- it "fails without cli name" do
307
- output = <<-OUT.unindent
308
- ERROR: 'teletype new' was called with no arguments
309
- Usage: 'teletype new PROJECT_NAME'\n
310
- OUT
311
- command = "teletype new"
312
- out, err, status = Open3.capture3(command)
313
- expect([out, err, status.exitstatus]).to match_array([output, '', 1])
314
- end
315
-
316
- it "displays help" do
317
- output = <<-OUT
318
- Usage:
319
- teletype new PROJECT_NAME [OPTIONS]
320
-
321
- Options:
322
- -a, [--author=name1 name2] # Author(s) of this library
323
- [--ext], [--no-ext] # Generate a boilerpalate for C extension
324
- [--coc], [--no-coc] # Generate a code of conduct file
325
- # Default: true
326
- -f, [--force] # Overwrite existing files
327
- -h, [--help], [--no-help] # Display usage information
328
- -l, [--license=mit] # Generate a license file
329
- # Default: mit
330
- # Possible values: agplv3, apache, bsd2, bsd3, gplv2, gplv3, lgplv3, mit, mplv2, custom
331
- -t, [--test=rspec] # Generate a test setup
332
- # Default: rspec
333
- # Possible values: rspec, minitest
334
- [--no-color] # Disable colorization in output
335
- -r, [--dry-run], [--no-dry-run] # Run but do not make any changes
336
- [--debug], [--no-debug] # Run in debug mode
337
-
338
- Description:
339
- The 'teletype new' command creates a new command line application with a
340
- default directory structure and configuration at the specified path.
341
-
342
- The PROJECT_NAME will be the name for the directory that includes all the
343
- files and be the default binary name.
344
-
345
- Example: teletype new cli_app
346
- OUT
347
-
348
- command = "teletype new --help"
349
- out, err, status = Open3.capture3(command)
350
- expect(out).to eq(output)
351
- expect(err).to eq('')
352
- expect(status.exitstatus).to eq(0)
353
- end
354
- end
@@ -1,21 +0,0 @@
1
- RSpec.describe 'teletype new --test', type: :cli do
2
- it "generates a rspec test setup" do
3
- app_name = tmp_path('newcli')
4
- command = "teletype new #{app_name} --test rspec"
5
- `#{command}`
6
-
7
- expect(File.exist?('newcli/spec/unit/.gitkeep'))
8
- expect(File.exist?('newcli/spec/support/.gitkeep'))
9
- expect(File.exist?('newcli/spec/integration/.gitkeep'))
10
- end
11
-
12
- it "generates a minitest test setup" do
13
- app_name = tmp_path('newcli')
14
- command = "teletype new #{app_name} --test=minitest"
15
- `#{command}`
16
-
17
- expect(File.exist?('newcli/test/unit/.gitkeep'))
18
- expect(File.exist?('newcli/test/support/.gitkeep'))
19
- expect(File.exist?('newcli/test/integration/.gitkeep'))
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- RSpec.describe 'teletype' do
2
- xit "prints available commands and global options" do
3
- command = "teletype"
4
-
5
- out = `#{command}`
6
-
7
- expect(out).to eq(<<-OUT)
8
- #{TTY::CLI.top_banner}Commands:
9
- teletype add COMMAND_NAME [OPTIONS] # Add a command to the command line app.
10
- teletype help [COMMAND] # Describe available commands or one specific command
11
- teletype new PROJECT_NAME [OPTIONS] # Create a new command line app skeleton.
12
- teletype version # TTY version
13
-
14
- Options:
15
- [--no-color] # Disable colorization in output.
16
- -r, [--dry-run], [--no-dry-run] # Run but do not make any changes.
17
- [--debug], [--no-debug] # Run with debug logging.
18
-
19
- OUT
20
- end
21
- end
@@ -1,73 +0,0 @@
1
- # encoding: utf-8
2
-
3
- if ENV['TRAVIS'] || ENV['COVERAGE']
4
- require 'simplecov'
5
-
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
- SimpleCov::Formatter::HTMLFormatter,
8
- ]
9
-
10
- SimpleCov.start do
11
- add_filter 'spec'
12
- end
13
- end
14
-
15
- require 'tty'
16
- require 'tty-file'
17
- require 'fileutils'
18
- require 'open3'
19
-
20
- class String
21
- def unindent
22
- gsub(/^[ \t]*/, '').chomp
23
- end
24
- end
25
-
26
- module TestHelpers
27
- module Paths
28
- def gem_root
29
- File.expand_path("#{File.dirname(__FILE__)}/..")
30
- end
31
-
32
- def dir_path(*args)
33
- path = File.join(gem_root, *args)
34
- FileUtils.mkdir_p(path)
35
- File.realpath(path)
36
- end
37
-
38
- def tmp_path(*args)
39
- File.join(dir_path('tmp'), *args)
40
- end
41
-
42
- def fixtures_path(*args)
43
- File.join(dir_path('spec/fixtures'), *args)
44
- end
45
-
46
- def within_dir(target, &block)
47
- ::Dir.chdir(target, &block)
48
- end
49
- end
50
-
51
- module Silent
52
- def silent_run(*args)
53
- out = Tempfile.new('tty-cmd')
54
- result = system(*args, out: out.path)
55
- return if result
56
- out.rewind
57
- fail "#{args.join} failed:\n#{out.read}"
58
- end
59
- end
60
- end
61
-
62
- RSpec.configure do |config|
63
- config.include(TestHelpers::Paths)
64
- config.include(TestHelpers::Silent)
65
- config.after(:example, type: :cli) do
66
- FileUtils.rm_rf(tmp_path)
67
- end
68
- config.run_all_when_everything_filtered = true
69
- config.filter_run :focus
70
- config.order = :random
71
- config.raise_errors_for_deprecations!
72
- config.disable_monkey_patching!
73
- end