simple_commander 0.0.1 → 0.1.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.byebug_history +15 -0
  3. data/.rubocop.yml +9 -0
  4. data/.rubocop_todo.yml +77 -0
  5. data/.travis.yml +6 -0
  6. data/Gemfile +1 -0
  7. data/History.rdoc +3 -0
  8. data/bin/simple_commander +1 -1
  9. data/coverage/.last_run.json +5 -0
  10. data/coverage/.resultset.json +1660 -0
  11. data/coverage/.resultset.json.lock +0 -0
  12. data/dir_glob.rb +7 -8
  13. data/ember_c +7 -38
  14. data/helper.rb +5 -0
  15. data/helpers/http_helper.rb +5 -0
  16. data/lib/simple_commander/command.rb +3 -3
  17. data/lib/simple_commander/configure.rb +2 -2
  18. data/lib/simple_commander/core_ext.rb +2 -2
  19. data/lib/simple_commander/delegates.rb +4 -3
  20. data/lib/simple_commander/help_formatters/base.rb +1 -1
  21. data/lib/simple_commander/help_formatters/terminal.rb +1 -1
  22. data/lib/simple_commander/help_formatters/terminal_compact.rb +1 -1
  23. data/lib/simple_commander/help_formatters.rb +4 -4
  24. data/lib/simple_commander/helpers/io.rb +128 -0
  25. data/lib/simple_commander/helpers.rb +1 -0
  26. data/lib/simple_commander/import.rb +1 -1
  27. data/lib/simple_commander/methods.rb +4 -4
  28. data/lib/simple_commander/platform.rb +1 -1
  29. data/lib/simple_commander/runner.rb +28 -6
  30. data/lib/simple_commander/user_interaction.rb +2 -2
  31. data/lib/simple_commander/version.rb +2 -2
  32. data/lib/simple_commander.rb +1 -0
  33. data/simple_commander.gemspec +2 -1
  34. data/spec/command_spec.rb +157 -0
  35. data/spec/configure_spec.rb +37 -0
  36. data/spec/core_ext/array_spec.rb +18 -0
  37. data/spec/core_ext/object_spec.rb +19 -0
  38. data/spec/help_formatters/terminal_compact_spec.rb +69 -0
  39. data/spec/help_formatters/terminal_spec.rb +67 -0
  40. data/spec/methods_spec.rb +20 -0
  41. data/spec/runner_spec.rb +659 -0
  42. data/spec/spec_helper.rb +82 -0
  43. data/spec/ui_spec.rb +30 -0
  44. data/test.rb +24 -0
  45. data/todo.yml +16 -4
  46. metadata +37 -2
@@ -0,0 +1,82 @@
1
+ require 'rubygems'
2
+ require 'stringio'
3
+ require 'simplecov'
4
+ require "codeclimate-test-reporter"
5
+ CodeClimate::TestReporter.start
6
+
7
+ SimpleCov.start do
8
+ add_filter '/spec/'
9
+ end
10
+
11
+
12
+
13
+ # Unshift so that local files load instead of something in gems
14
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
15
+
16
+ # This basically replicates the behavior of `require 'simple_commander/import'`
17
+ # but without adding an `at_exit` hook, which interferes with exit code
18
+ require 'simple_commander'
19
+ require 'simple_commander/methods'
20
+
21
+ # Mock terminal IO streams so we can spec against them
22
+
23
+ def mock_terminal
24
+ @input = StringIO.new
25
+ @output = StringIO.new
26
+ $terminal = HighLine.new @input, @output
27
+ end
28
+
29
+ # Create test command for usage within several specs
30
+
31
+ def create_test_command
32
+ command :test do
33
+ syntax = 'test [options] <file>'
34
+ description = 'test description'
35
+ example 'description', 'command'
36
+ example 'description 2', 'command 2'
37
+ option '-v', '--verbose', 'verbose description'
38
+ when_called do |args, _options|
39
+ format('test %s', args.join)
40
+ end
41
+ end
42
+ @command = command :test
43
+ end
44
+
45
+ # Create a new command runner
46
+
47
+ def new_command_runner(*args, &block)
48
+ SimpleCommander::Runner.instance_variable_set :"@singleton", SimpleCommander::Runner.new(args)
49
+ program :name, 'test'
50
+ program :version, '1.2.3'
51
+ program :description, 'something'
52
+ create_test_command
53
+ yield if block
54
+ SimpleCommander::Runner.instance
55
+ end
56
+
57
+ # Comply with how specs were previously written
58
+
59
+ def command_runner
60
+ SimpleCommander::Runner.instance
61
+ end
62
+
63
+ def run(*args)
64
+ new_command_runner(*args) do
65
+ program :help_formatter, SimpleCommander::HelpFormatter::Base
66
+ end.run!
67
+ @output.string
68
+ end
69
+
70
+ RSpec.configure do |c|
71
+ c.expect_with(:rspec) do |e|
72
+ e.syntax = :expect
73
+ end
74
+
75
+ c.mock_with(:rspec) do |m|
76
+ m.syntax = :expect
77
+ end
78
+
79
+ c.before(:each) do
80
+ allow(SimpleCommander::UI).to receive(:enable_paging)
81
+ end
82
+ end
data/spec/ui_spec.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe SimpleCommander::UI do
4
+ include SimpleCommander::Methods
5
+
6
+ describe '.replace_tokens' do
7
+ it 'should replace tokens within a string, with hash values' do
8
+ result = SimpleCommander::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(SimpleCommander::UI.available_editor('sh -c')).to eq('sh -c')
28
+ end
29
+ end
30
+ end
data/test.rb ADDED
@@ -0,0 +1,24 @@
1
+ module Helper
2
+ def testing
3
+ puts 'testing!'
4
+ end
5
+ end
6
+
7
+
8
+ class Document
9
+ def include_mixin
10
+ Document.include Helper
11
+ end
12
+ end
13
+
14
+ class InvalidCommandError < StandardError; end
15
+ Helper123 = "marcell"
16
+ #puts Object.const_get("Helper").instance_of?(::Module)
17
+ #fail InvalidCommandError, 'invalid command', caller if !defined? helper_name
18
+
19
+ doc = Document.new
20
+ doc.include_mixin
21
+ doc.testing
22
+
23
+ puts doc.methods.include? :testing
24
+
data/todo.yml CHANGED
@@ -1,8 +1,15 @@
1
- create gem scommander
2
- add highline as a dependency on the gem
3
- change the name of the Commander module to SimpleCommander
4
- create scommader cli which transform the script in an directory with helpers,
1
+ write documentaion for hepers in the readme
2
+ write tests and add helper functionality to readme
3
+ make the helper search in the helpers folder of the project
4
+ raise exeption when the helper is undefined
5
+ write tests for the helpers method
6
+ implement helpers command
7
+ create scommader cli which transform the script in an directory with helpers,
5
8
  tests etc..
9
+ add ci
10
+ add codeclimate
11
+ add test coverage
12
+ add logo to read and simple readme
6
13
  add suport for helpers
7
14
  make syntax, options ect.. actually methods instead of variables
8
15
  make say accept a color hex
@@ -14,6 +21,11 @@ learn about the implementation of the commander progress bar
14
21
  figuring out the progress bar
15
22
 
16
23
  done:
24
+ learn how to use rubocop
25
+ change the name of the Commander module to SimpleCommander
26
+ add highline as a dependency on the gem
27
+ add commander rspec tests and write tests for the new functionalities
28
+ create gem scommander
17
29
  make help default command work too
18
30
  add suport for nested commands
19
31
  studying commander api in ./commander
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcell Monteiro Cruz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.7.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.7.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +89,9 @@ extensions: []
75
89
  extra_rdoc_files: []
76
90
  files:
77
91
  - ".byebug_history"
92
+ - ".rubocop.yml"
93
+ - ".rubocop_todo.yml"
94
+ - ".travis.yml"
78
95
  - DEVELOPMENT
79
96
  - Gemfile
80
97
  - History.rdoc
@@ -83,8 +100,13 @@ files:
83
100
  - README.md
84
101
  - Rakefile
85
102
  - bin/simple_commander
103
+ - coverage/.last_run.json
104
+ - coverage/.resultset.json
105
+ - coverage/.resultset.json.lock
86
106
  - dir_glob.rb
87
107
  - ember_c
108
+ - helper.rb
109
+ - helpers/http_helper.rb
88
110
  - ideal_spec.rb
89
111
  - lib/simple_commander.rb
90
112
  - lib/simple_commander/blank.rb
@@ -102,6 +124,8 @@ files:
102
124
  - lib/simple_commander/help_formatters/terminal_compact.rb
103
125
  - lib/simple_commander/help_formatters/terminal_compact/command_help.erb
104
126
  - lib/simple_commander/help_formatters/terminal_compact/help.erb
127
+ - lib/simple_commander/helpers.rb
128
+ - lib/simple_commander/helpers/io.rb
105
129
  - lib/simple_commander/import.rb
106
130
  - lib/simple_commander/methods.rb
107
131
  - lib/simple_commander/platform.rb
@@ -109,6 +133,17 @@ files:
109
133
  - lib/simple_commander/user_interaction.rb
110
134
  - lib/simple_commander/version.rb
111
135
  - simple_commander.gemspec
136
+ - spec/command_spec.rb
137
+ - spec/configure_spec.rb
138
+ - spec/core_ext/array_spec.rb
139
+ - spec/core_ext/object_spec.rb
140
+ - spec/help_formatters/terminal_compact_spec.rb
141
+ - spec/help_formatters/terminal_spec.rb
142
+ - spec/methods_spec.rb
143
+ - spec/runner_spec.rb
144
+ - spec/spec_helper.rb
145
+ - spec/ui_spec.rb
146
+ - test.rb
112
147
  - todo.yml
113
148
  homepage: https://github.com/0000marcell/simple_commander
114
149
  licenses: