scout-gear 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ module SOPT
2
+
3
+ def self.setup(str)
4
+ parts = str.split(/\n\n+/)
5
+
6
+ summary = parts.shift unless parts.first =~ /^\s*\$-/
7
+ synopsys = parts.shift if parts.first =~ /^\s*\$/
8
+
9
+ description = []
10
+ while parts.first and parts.first !~ /^\s*-/
11
+ description << parts.shift
12
+ end
13
+ description = description * "\n\n"
14
+
15
+ options = parts.collect{|part| part.split("\n").select{|l| l=~ /^\s*-/ } }.flatten.compact * "\n"
16
+
17
+ synopsys.sub!(/^\$\s+/,'') if synopsys
18
+
19
+ SOPT.summary = summary.strip if summary
20
+ SOPT.synopsys = synopsys.strip if synopsys
21
+ SOPT.description = description.strip if description
22
+ SOPT.parse options if options
23
+
24
+ SOPT.consume
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'simple_opt/accessor'
2
+ require_relative 'simple_opt/parse'
3
+ require_relative 'simple_opt/doc'
4
+ require_relative 'simple_opt/get'
5
+ require_relative 'simple_opt/setup'
data/lib/scout-gear.rb CHANGED
@@ -2,3 +2,4 @@ require_relative 'scout/indiferent_hash'
2
2
  require_relative 'scout/tmpfile'
3
3
  require_relative 'scout/log'
4
4
  require_relative 'scout/path'
5
+ require_relative 'scout/simple_opt'
data/scout-gear.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: scout-gear 1.2.0 ruby lib
5
+ # stub: scout-gear 2.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "scout-gear".freeze
9
- s.version = "1.2.0"
9
+ s.version = "2.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Miguel Vazquez".freeze]
14
- s.date = "2023-03-24"
14
+ s.date = "2023-03-30"
15
15
  s.description = "Temporary files, logs, etc.".freeze
16
16
  s.email = "mikisvaz@gmail.com".freeze
17
17
  s.executables = ["scout".freeze]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  ]
22
22
  s.files = [
23
23
  ".document",
24
+ ".gitmodules",
24
25
  ".vimproject",
25
26
  "LICENSE.txt",
26
27
  "README.rdoc",
@@ -41,15 +42,26 @@ Gem::Specification.new do |s|
41
42
  "lib/scout/log/progress/util.rb",
42
43
  "lib/scout/meta_extension.rb",
43
44
  "lib/scout/misc.rb",
45
+ "lib/scout/misc/format.rb",
44
46
  "lib/scout/path.rb",
45
47
  "lib/scout/path/find.rb",
46
48
  "lib/scout/path/util.rb",
49
+ "lib/scout/simple_opt.rb",
50
+ "lib/scout/simple_opt/accessor.rb",
51
+ "lib/scout/simple_opt/doc.rb",
52
+ "lib/scout/simple_opt/get.rb",
53
+ "lib/scout/simple_opt/parse.rb",
54
+ "lib/scout/simple_opt/setup.rb",
47
55
  "lib/scout/tmpfile.rb",
48
56
  "scout-gear.gemspec",
57
+ "test/scout/indiferent_hash/test_case_insensitive.rb",
49
58
  "test/scout/indiferent_hash/test_options.rb",
50
59
  "test/scout/log/test_progress.rb",
51
60
  "test/scout/path/test_find.rb",
52
61
  "test/scout/path/test_util.rb",
62
+ "test/scout/simple_opt/test_get.rb",
63
+ "test/scout/simple_opt/test_parse.rb",
64
+ "test/scout/simple_opt/test_setup.rb",
53
65
  "test/scout/test_indiferent_hash.rb",
54
66
  "test/scout/test_log.rb",
55
67
  "test/scout/test_meta_extension.rb",
@@ -0,0 +1,16 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestCaseInsensitiveHash < Test::Unit::TestCase
5
+ def test_case_insensitive_hash
6
+ a = {:a => 1, "b" => 2}
7
+ a.extend CaseInsensitiveHash
8
+
9
+ assert_equal 1, a[:a]
10
+ assert_equal 1, a["A"]
11
+ assert_equal 1, a[:A]
12
+ assert_equal 2, a["B"]
13
+ assert_equal 2, a[:b]
14
+ end
15
+ end
16
+
@@ -10,7 +10,7 @@ class TestPathFind < Test::Unit::TestCase
10
10
  assert_equal "data/some_file", path._subpath
11
11
 
12
12
  path = Path.setup("data", 'scout')
13
- assert_equal nil, path._toplevel
13
+ assert_equal "", path._toplevel
14
14
  assert_equal "data", path._subpath
15
15
  end
16
16
 
@@ -63,5 +63,13 @@ class TestPathFind < Test::Unit::TestCase
63
63
  end
64
64
  end
65
65
 
66
+ def test_located?
67
+
68
+ p = Path.setup("/tmp/foo/bar")
69
+ assert p.located?
70
+ assert_equal p, p.find
71
+
72
+ end
73
+
66
74
  end
67
75
 
@@ -0,0 +1,11 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require 'scout/simple_opt'
3
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
4
+
5
+ class TestSOPTParse < Test::Unit::TestCase
6
+ def test_consume
7
+ SOPT.parse("-f--first* first arg:-f--fun")
8
+ args = "-f myfile --fun".split(" ")
9
+ assert_equal "myfile", SOPT.consume(args)[:first]
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require 'scout/path'
3
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
4
+
5
+ class TestSOPTParse < Test::Unit::TestCase
6
+ def test_parse
7
+ SOPT.parse("-f--first* first arg:-f--fun")
8
+ assert_equal "fun", SOPT.shortcuts["fu"]
9
+ end
10
+ end
@@ -0,0 +1,77 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require 'scout/simple_opt'
3
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
4
+
5
+ class TestSOPTSetup < Test::Unit::TestCase
6
+ def setup
7
+ SOPT.inputs = nil
8
+ SOPT.input_types = nil
9
+ SOPT.input_descriptions = nil
10
+ SOPT.input_shortcuts = nil
11
+ end
12
+
13
+ def test_setup
14
+ SOPT.setup <<-EOF
15
+ Test application
16
+
17
+ $ test cmd -arg 1
18
+
19
+ It does some imaginary stuff
20
+
21
+ -a--arg* Argument
22
+ -a2--arg2* Argument
23
+
24
+ EOF
25
+
26
+ assert_equal "test cmd -arg 1", SOPT.synopsys
27
+ assert SOPT.inputs.include? "arg"
28
+ assert SOPT.inputs.include? "arg2"
29
+ end
30
+
31
+ def test_setup_alt
32
+ SOPT.setup <<-EOF
33
+ Test application
34
+
35
+ It does some imaginary stuff
36
+
37
+ -a--arg* Argument
38
+ -a2--arg2* Argument
39
+
40
+ EOF
41
+
42
+ assert SOPT.inputs.include? "arg"
43
+ assert SOPT.inputs.include? "arg2"
44
+ end
45
+
46
+ def test_setup_alt2
47
+ SOPT.setup <<-EOF
48
+ Test application
49
+
50
+ -a--arg* Argument
51
+ -a2--arg2* Argument
52
+
53
+ EOF
54
+
55
+ assert SOPT.inputs.include? "arg"
56
+ assert SOPT.inputs.include? "arg2"
57
+ end
58
+
59
+ def test_setup_alt3
60
+ SOPT.setup <<-EOF
61
+ Pulls the values from a tsv colum
62
+
63
+ $ rbbt tsv values [options] <filename.tsv|->
64
+
65
+ Use - to read from STDIN
66
+
67
+ -tch--tokyocabinet File is a tokyocabinet hash database
68
+ -tcb--tokyocabinet_bd File is a tokyocabinet B database
69
+ -h--help Print this help
70
+ EOF
71
+
72
+ assert SOPT.inputs.include? "tokyocabinet"
73
+ end
74
+
75
+ end
76
+
77
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout-gear
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-24 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -90,6 +90,7 @@ extra_rdoc_files:
90
90
  - README.rdoc
91
91
  files:
92
92
  - ".document"
93
+ - ".gitmodules"
93
94
  - ".vimproject"
94
95
  - LICENSE.txt
95
96
  - README.rdoc
@@ -110,15 +111,26 @@ files:
110
111
  - lib/scout/log/progress/util.rb
111
112
  - lib/scout/meta_extension.rb
112
113
  - lib/scout/misc.rb
114
+ - lib/scout/misc/format.rb
113
115
  - lib/scout/path.rb
114
116
  - lib/scout/path/find.rb
115
117
  - lib/scout/path/util.rb
118
+ - lib/scout/simple_opt.rb
119
+ - lib/scout/simple_opt/accessor.rb
120
+ - lib/scout/simple_opt/doc.rb
121
+ - lib/scout/simple_opt/get.rb
122
+ - lib/scout/simple_opt/parse.rb
123
+ - lib/scout/simple_opt/setup.rb
116
124
  - lib/scout/tmpfile.rb
117
125
  - scout-gear.gemspec
126
+ - test/scout/indiferent_hash/test_case_insensitive.rb
118
127
  - test/scout/indiferent_hash/test_options.rb
119
128
  - test/scout/log/test_progress.rb
120
129
  - test/scout/path/test_find.rb
121
130
  - test/scout/path/test_util.rb
131
+ - test/scout/simple_opt/test_get.rb
132
+ - test/scout/simple_opt/test_parse.rb
133
+ - test/scout/simple_opt/test_setup.rb
122
134
  - test/scout/test_indiferent_hash.rb
123
135
  - test/scout/test_log.rb
124
136
  - test/scout/test_meta_extension.rb