ruby_cli 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,15 +10,16 @@ License:: Distributed under the same terms as Ruby
10
10
  programswith a command line interface (CLI) which follows the Unix Philosophy
11
11
  design method outlined in http://www.faqs.org/docs/artu/ch01s06.html.
12
12
 
13
- Currently, RubyCLI is short and simple. It uses Ruby's core Option Parser library.
13
+ Currently, RubyCLI is short and simple. It uses Ruby's core
14
+ optparse[http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html] library.
14
15
 
15
16
  = Design
16
17
 
17
18
  What does a command line application library need to do?
18
- 1. Provide a user interface (UI)
19
- a. Process options (use Ruby's Option Parser)
20
- b. Process arguments
21
- 2. Pass options and arguments as parameters to other functions defined in libraries or other executables.
19
+ 1. Provide a user interface (UI)
20
+ * Process options (use Ruby's Option Parser)
21
+ * Process arguments
22
+ 2. Pass options and arguments as parameters to other functions defined in libraries or other executables.
22
23
 
23
24
  What does a command line application library need not do?
24
25
  1. A command line application does not need to validate options or arguments. Libraries or other executables should do this.
@@ -32,14 +33,14 @@ gem install ruby_cli
32
33
  There are other tools out there which can be used to write command line
33
34
  applications.
34
35
 
35
- - clamp[http://github.com/mdub/clamp]
36
- ** I don't like to learn new DSLs
37
- - optparse[http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html]
38
- ** This library uses this to parse options.
39
- - Thor[http://github.com/wycats/thor]
40
- ** It does not try to follow the Unix Philosophy.
41
- - Clip[http://clip.rubyforge.org/]
42
- ** OptionParser already exists.
36
+ 1. clamp[http://github.com/mdub/clamp]
37
+ * I don't like to learn new DSLs
38
+ 2. optparse[http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html]
39
+ * This library uses this to parse options.
40
+ 3. Thor[http://github.com/wycats/thor]
41
+ * It does not try to follow the Unix Philosophy.
42
+ 4. Clip[http://clip.rubyforge.org/]
43
+ * OptionParser already exists.
43
44
 
44
45
  = Usage
45
46
 
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << 'test'
5
+ end
6
+
7
+ desc "Run tests"
8
+ task :default => :test
data/lib/ruby_cli.rb CHANGED
@@ -104,13 +104,16 @@ module RubyCLI
104
104
  # Performs post-parse processing on options
105
105
  # For instance, some options may be mutually exclusive
106
106
  # Redefine if you need to process options.
107
- def process_options() true end
107
+ def process_options() return true end
108
108
 
109
109
  # Redefine if you need to process options.
110
- def process_arguments() true end
110
+ def process_arguments() return true end
111
111
 
112
112
  # Application logic
113
- def command() raise "This method should be overwritten." end
113
+ def command
114
+ raise "This method should be overwritten."
115
+ return 0
116
+ end
114
117
 
115
118
  def output_help(exit_code)
116
119
  puts @opt_parser
@@ -0,0 +1,13 @@
1
+ require 'test/unit'
2
+ require 'ruby_cli'
3
+
4
+ class RubyCLITest < Test::Unit::TestCase
5
+ def test_hello_world
6
+ m = Class.new do
7
+ include RubyCLI
8
+
9
+ def command() puts "Hello World" end
10
+ end.new(ARGV)
11
+ assert_equal(0, m.run)
12
+ end
13
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_cli
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Martin Velez
@@ -31,6 +31,8 @@ files:
31
31
  - lib/ruby_cli.rb
32
32
  - README.rdoc
33
33
  - bin/hello_world
34
+ - test/test_ruby_cli.rb
35
+ - Rakefile
34
36
  has_rdoc: true
35
37
  homepage: http://github.com/martinvelez/ruby_cli
36
38
  licenses: []