rubycom 0.1.1

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.
@@ -0,0 +1,16 @@
1
+ require "#{File.expand_path(File.dirname(__FILE__))}/../../lib/rubycom.rb"
2
+ require "#{File.expand_path(File.dirname(__FILE__))}/util_test_module.rb"
3
+
4
+ module UtilTestComposite
5
+ include UtilTestModule
6
+
7
+ # A test_command in a composite console
8
+ #
9
+ # @param [String] test_arg a test argument
10
+ # @return [String] the test arg
11
+ def self.test_composite_command(test_arg)
12
+ test_arg
13
+ end
14
+
15
+ include Rubycom
16
+ end
@@ -0,0 +1,96 @@
1
+ require "#{File.expand_path(File.dirname(__FILE__))}/../../lib/rubycom.rb"
2
+
3
+ module UtilTestModule
4
+
5
+ # A test non-command method
6
+ def non_command
7
+ puts 'fail'
8
+ end
9
+
10
+ # A basic test command
11
+ def self.test_command
12
+ puts 'command test'
13
+ end
14
+
15
+ # A test_command with one arg
16
+ #
17
+ # @param [String] test_arg a test argument
18
+ def self.test_command_with_arg(test_arg)
19
+ "test_arg=#{test_arg}"
20
+ end
21
+
22
+ # A test_command with two args
23
+ # @param [String] test_arg a test argument
24
+ # @param [String] another_test_arg another test argument
25
+ def self.test_command_with_args(test_arg, another_test_arg)
26
+ puts "test_arg=#{test_arg},another_test_arg=#{another_test_arg}"
27
+ end
28
+
29
+ # A test_command with an optional argument
30
+ # @param [String] test_arg a test argument
31
+ # @param [String] test_option an optional test argument
32
+ def self.test_command_with_options(test_arg, test_option='option_default')
33
+ puts "test_arg=#{test_arg},test_option=#{test_option}"
34
+ end
35
+
36
+ # A test_command with all optional arguments
37
+ # @param [String] test_arg an optional test argument
38
+ # @param [String] test_option another optional test argument
39
+ def self.test_command_all_options(test_arg='test_arg_default', test_option='test_option_default')
40
+ puts "Output is test_arg=#{test_arg},test_option=#{test_option}"
41
+ end
42
+
43
+ # A test_command with an options array
44
+ # @param [String] test_option an optional test argument
45
+ # @param [String] test_options an optional array of arguments
46
+ def self.test_command_options_arr (
47
+ test_option="test_option_default",
48
+ *test_options
49
+ )
50
+ puts "Output is test_option=#{test_option},test_option_arr=#{test_options}"
51
+ end
52
+
53
+ # A test_command with a return argument
54
+ #
55
+ # @param [String] test_arg a test argument
56
+ # @param [Integer] test_option_int an optional test argument which happens to be an Integer
57
+ # @return [Array] an array including both params if test_option_int != 1
58
+ # @return [String] a the first param if test_option_int == 1
59
+ def self.test_command_with_return(test_arg, test_option_int=1)
60
+ ret = [test_arg, test_option_int]
61
+ if test_option_int == 1
62
+ ret = test_arg
63
+ end
64
+ ret
65
+ end
66
+
67
+ # A test_command with a Timestamp argument and an unnecessarily long description which should overflow when
68
+ # it tries to line up with other descriptions.
69
+ # @param [Timestamp] test_time a test Timestamp argument
70
+ # @return [Hash] a hash including the given argument
71
+ def self.test_command_arg_timestamp(test_time)
72
+ {test_time: test_time}
73
+ end
74
+
75
+ # A test_command with a Boolean argument
76
+ # @param [Boolean] test_flag a test Boolean argument
77
+ # @return [Boolean] the flag passed in
78
+ def self.test_command_arg_false(test_flag=false)
79
+ test_flag
80
+ end
81
+
82
+ # A test_command with an array argument
83
+ #
84
+ # @param [Array] test_arr an Array test argument
85
+ def self.test_command_arg_arr(test_arr=[])
86
+ test_arr
87
+ end
88
+
89
+ # A test_command with an Hash argument
90
+ # @param [Hash] test_hash a Hash test argument
91
+ def self.test_command_arg_hash(test_hash={})
92
+ test_hash
93
+ end
94
+
95
+ include Rubycom
96
+ end
@@ -0,0 +1,10 @@
1
+ require "#{File.expand_path(File.dirname(__FILE__))}/../../lib/rubycom.rb"
2
+ require "#{File.expand_path(File.dirname(__FILE__))}/util_test_composite.rb"
3
+
4
+ module UtilTestNoSingleton
5
+ def test_method
6
+ "TEST_NON_SINGLETON_METHOD"
7
+ end
8
+
9
+ include Rubycom
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'time'
2
+
3
+ require "#{File.expand_path(File.dirname(__FILE__))}/../../lib/rubycom.rb"
4
+ require "#{File.expand_path(File.dirname(__FILE__))}/util_test_module.rb"
5
+ require "#{File.expand_path(File.dirname(__FILE__))}/util_test_composite.rb"
6
+ require "#{File.expand_path(File.dirname(__FILE__))}/util_test_no_singleton.rb"
7
+
8
+ require 'test/unit'
9
+ #noinspection RubyInstanceMethodNamingConvention
10
+ class TestCase < Test::Unit::TestCase
11
+ def test_case
12
+ base = UtilTestModule
13
+ args = ["test_command_arg_hash"]
14
+ result = Rubycom.run(base, args)
15
+ puts result
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubycom
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Danny Purcell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: test-unit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: method_source
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Allows command-line access for all singleton methods in an including
95
+ class. Reads Yard style documentation for command line help output. Uses Yaml for
96
+ parsing options. Allows the user to make a command-line tool by simply including
97
+ Rubycom at the bottom.
98
+ email:
99
+ - dpurcelljr@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - lib/rubycom.rb
110
+ - lib/rubycom/version.rb
111
+ - rubycom.gemspec
112
+ - test/rubycom/test_rubycom.rb
113
+ - test/rubycom/util_test_composite.rb
114
+ - test/rubycom/util_test_module.rb
115
+ - test/rubycom/util_test_no_singleton.rb
116
+ - test/rubycom/utility_tester.rb
117
+ homepage: http://dannypurcell.github.io/Rubycom
118
+ licenses:
119
+ - MIT
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.24
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Converts singleton methods to command-line functions upon inclusion.
142
+ test_files:
143
+ - test/rubycom/test_rubycom.rb
144
+ - test/rubycom/util_test_composite.rb
145
+ - test/rubycom/util_test_module.rb
146
+ - test/rubycom/util_test_no_singleton.rb
147
+ - test/rubycom/utility_tester.rb
148
+ has_rdoc: