scout-gear 1.1.0 → 1.2.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.
- checksums.yaml +4 -4
- data/.vimproject +2 -1
- data/Rakefile +2 -12
- data/VERSION +1 -1
- data/lib/scout/log/progress/report.rb +1 -1
- data/lib/scout/log/progress/util.rb +0 -1
- data/lib/scout/log.rb +1 -1
- data/lib/scout/meta_extension.rb +15 -1
- data/lib/scout/misc.rb +13 -0
- data/lib/scout/path/find.rb +79 -30
- data/lib/scout/path/util.rb +52 -0
- data/lib/scout/path.rb +12 -5
- data/lib/scout/tmpfile.rb +2 -6
- data/lib/scout-gear.rb +1 -0
- data/scout-gear.gemspec +13 -17
- data/test/scout/path/test_find.rb +33 -0
- data/test/scout/path/test_util.rb +22 -0
- data/test/scout/test_meta_extension.rb +16 -2
- data/test/scout/test_misc.rb +13 -0
- data/test/scout/test_path.rb +16 -0
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 644f7b057adc20478b49952953a8e984d0e89190728e089a3775c2313248680a
|
4
|
+
data.tar.gz: 37c9350027e3d28e24700ebb25bd449fb7aa7a1466c9c663d7681ca29e69fb8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6060f31e07e7b7d76abd36760217814f385c73dad65e8d533e503eb5cdcaa5cbfc86257ad87e820ccf57395f3d0df6c3d4fa7d9c5dc77537b0582ea217d6be2c
|
7
|
+
data.tar.gz: cfb254eefc93331ef067043c1861337886f6749871bc5cdbf44e282238e84970f5bc1eb421833920968839c91bf0f3319f39c93a970af477e4bf194cfea88b11
|
data/.vimproject
CHANGED
@@ -5,6 +5,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
5
5
|
lib=lib {
|
6
6
|
scout-gear.rb
|
7
7
|
scout=scout{
|
8
|
+
misc.rb
|
8
9
|
exceptions.rb
|
9
10
|
meta_extension.rb
|
10
11
|
tmpfile.rb
|
@@ -27,6 +28,7 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
27
28
|
path.rb
|
28
29
|
path=path{
|
29
30
|
find.rb
|
31
|
+
util.rb
|
30
32
|
}
|
31
33
|
}
|
32
34
|
}
|
@@ -42,4 +44,3 @@ scout-gear=/$PWD filter="*.rb *.yaml" {
|
|
42
44
|
}
|
43
45
|
}
|
44
46
|
}
|
45
|
-
|
data/Rakefile
CHANGED
@@ -18,21 +18,11 @@ Juwelier::Tasks.new do |gem|
|
|
18
18
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
19
19
|
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
20
20
|
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
21
|
+
gem.add_runtime_dependency 'term-ansicolor'
|
22
|
+
|
21
23
|
gem.add_development_dependency "rdoc", "~> 3.12"
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
24
|
gem.add_development_dependency "bundler", "~> 1.0"
|
27
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
28
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
29
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
30
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
31
25
|
gem.add_development_dependency "juwelier", "~> 2.1.0"
|
32
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
33
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
34
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
35
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
36
26
|
gem.add_development_dependency "simplecov", ">= 0"
|
37
27
|
end
|
38
28
|
Juwelier::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -208,7 +208,7 @@ module Log
|
|
208
208
|
done_msg << Log.color(:magenta, " · " << desc)
|
209
209
|
print(io, Log.up_lines(@depth) << done_msg << Log.down_lines(@depth))
|
210
210
|
|
211
|
-
FileUtils.rm file if file and File.
|
211
|
+
FileUtils.rm file if file and File.exist?(file)
|
212
212
|
|
213
213
|
@callback.call self if @callback
|
214
214
|
end
|
data/lib/scout/log.rb
CHANGED
data/lib/scout/meta_extension.rb
CHANGED
@@ -13,9 +13,23 @@ module MetaExtension
|
|
13
13
|
|
14
14
|
meta.define_method(:setup) do |obj,*rest|
|
15
15
|
obj.extend base
|
16
|
-
self.class_variable_get("@@extension_attrs")
|
16
|
+
attrs = self.class_variable_get("@@extension_attrs")
|
17
|
+
|
18
|
+
return if attrs.nil? || attrs.empty?
|
19
|
+
|
20
|
+
if rest.length == 1 && Hash === (rlast = rest.last) &&
|
21
|
+
! (rlkey = rlast.keys.first).nil? &&
|
22
|
+
attrs.include?(rlkey.to_sym)
|
23
|
+
|
24
|
+
pairs = rlast
|
25
|
+
else
|
26
|
+
pairs = attrs.zip(rest)
|
27
|
+
end
|
28
|
+
|
29
|
+
pairs.each do |name,value|
|
17
30
|
obj.instance_variable_set("@#{name}", value)
|
18
31
|
end
|
32
|
+
|
19
33
|
obj
|
20
34
|
end
|
21
35
|
|
data/lib/scout/misc.rb
ADDED
data/lib/scout/path/find.rb
CHANGED
@@ -12,54 +12,103 @@ module Path
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.follow(path, map)
|
15
|
-
map.sub('{PKGDIR}', path.pkgdir).
|
15
|
+
map.sub('{PKGDIR}', path.pkgdir || Path.default_pkgdir).
|
16
16
|
sub('{RESOURCE}', path.to_s).
|
17
17
|
sub('{PWD}', FileUtils.pwd).
|
18
18
|
sub('{TOPLEVEL}', path._toplevel).
|
19
19
|
sub('{SUBPATH}', path._subpath).
|
20
20
|
sub('{BASENAME}', File.basename(path)).
|
21
21
|
sub('{PATH}', path).
|
22
|
-
sub('{LIBDIR}', path.libdir).
|
22
|
+
sub('{LIBDIR}', path.libdir || Path.caller_lib_dir).
|
23
23
|
sub('{REMOVE}/', '').
|
24
24
|
sub('{REMOVE}', '').gsub(/\/+/,'/')
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def
|
44
|
-
|
27
|
+
def self.path_maps
|
28
|
+
@@path_maps ||= IndiferentHash.setup({
|
29
|
+
:current => File.join("{PWD}", "{TOPLEVEL}", "{SUBPATH}"),
|
30
|
+
:user => File.join(ENV['HOME'], ".{PKGDIR}", "{TOPLEVEL}", "{SUBPATH}"),
|
31
|
+
:global => File.join('/', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
32
|
+
:usr => File.join('/usr/', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
33
|
+
:local => File.join('/usr/local', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
34
|
+
:fast => File.join('/fast', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
35
|
+
:cache => File.join('/cache', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
36
|
+
:bulk => File.join('/bulk', "{TOPLEVEL}", "{PKGDIR}", "{SUBPATH}"),
|
37
|
+
:lib => File.join('{LIBDIR}', "{TOPLEVEL}", "{SUBPATH}"),
|
38
|
+
:base => File.join(Path.caller_lib_dir(__FILE__), "{TOPLEVEL}", "{SUBPATH}"),
|
39
|
+
:default => :user
|
40
|
+
})
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.map_search
|
44
|
+
@@map_search ||= %w(current workflow user local global lib fast cache bulk)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.search_order
|
48
|
+
@@search_order ||= (path_maps.keys & map_search) + (path_maps.keys - map_search)
|
49
|
+
end
|
50
|
+
|
51
|
+
SLASH = "/"[0]
|
52
|
+
DOT = "."[0]
|
53
|
+
def located?
|
54
|
+
# OPEN RESOURCE
|
55
|
+
self.slice(0,1) == SLASH || (self.char(0,1) == DOT && self.char(1,2) == SLASH) # || (resource != Rbbt && (Open.remote?(self) || Open.ssh?(self)))
|
56
|
+
end
|
57
|
+
|
58
|
+
def annotate_found_where(found, where)
|
59
|
+
self.annotate(found).tap{|p|
|
60
|
+
p.instance_variable_set("@where", where)
|
61
|
+
p.instance_variable_set("@original", self.dup)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def where
|
66
|
+
@where
|
67
|
+
end
|
68
|
+
|
69
|
+
def original
|
70
|
+
@original
|
71
|
+
end
|
72
|
+
|
73
|
+
def follow(map_name = :default, annotate = true)
|
74
|
+
map = Path.path_maps[map_name]
|
45
75
|
while Symbol === map
|
46
|
-
|
76
|
+
map_name = map
|
77
|
+
map = Path.path_maps[map_name]
|
47
78
|
end
|
48
|
-
Path.follow(self, map)
|
79
|
+
found = Path.follow(self, map)
|
80
|
+
|
81
|
+
annotate_found_where(found, map_name) if annotate
|
82
|
+
|
83
|
+
found
|
49
84
|
end
|
50
85
|
|
51
86
|
def find(where = nil)
|
52
|
-
return
|
87
|
+
return self if located?
|
88
|
+
return follow(where) if where
|
89
|
+
|
53
90
|
|
54
|
-
|
55
|
-
|
91
|
+
Path.search_order.each do |map_name|
|
92
|
+
found = follow(map_name, false)
|
56
93
|
|
57
|
-
|
58
|
-
map = PATH_MAPS[name]
|
59
|
-
real_path = _follow(map)
|
60
|
-
return real_path if File.exists?(real_path)
|
94
|
+
return annotate_found_where(found, map_name) if File.exist?(found) || File.directory?(real_path)
|
61
95
|
end
|
62
96
|
|
63
|
-
return
|
97
|
+
return follow(:default)
|
64
98
|
end
|
99
|
+
|
100
|
+
def exist?
|
101
|
+
# OPEN
|
102
|
+
found = self.find
|
103
|
+
File.exist?(found) || File.directory?(found)
|
104
|
+
end
|
105
|
+
|
106
|
+
alias exists? exist?
|
107
|
+
|
108
|
+
def find_all(caller_lib = nil, search_paths = nil)
|
109
|
+
Path.search_order
|
110
|
+
.collect{|where| find(where) }
|
111
|
+
.select{|file| file.exist? }.uniq
|
112
|
+
end
|
113
|
+
|
65
114
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Path
|
2
|
+
def directory?
|
3
|
+
return nil unless self.exist?
|
4
|
+
File.directory?(self.find)
|
5
|
+
end
|
6
|
+
|
7
|
+
def dirname
|
8
|
+
self.annotate(File.dirname(self))
|
9
|
+
end
|
10
|
+
|
11
|
+
def basename
|
12
|
+
self.annotate(File.basename(self))
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def glob(pattern = '*')
|
17
|
+
if self.include? "*"
|
18
|
+
self.glob_all
|
19
|
+
else
|
20
|
+
return [] unless self.exist?
|
21
|
+
found = self.find
|
22
|
+
exp = File.join(found, pattern)
|
23
|
+
paths = Dir.glob(exp).collect{|f| self.annotate(f) }
|
24
|
+
|
25
|
+
paths.each do |p|
|
26
|
+
p.original = File.join(found.original, p.sub(/^#{found}/, ''))
|
27
|
+
end if found.original
|
28
|
+
|
29
|
+
paths
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def glob_all(pattern = nil, caller_lib = nil, search_paths = nil)
|
34
|
+
search_paths ||= Path.search_paths
|
35
|
+
search_paths = search_paths.dup
|
36
|
+
|
37
|
+
location_paths = {}
|
38
|
+
search_paths.keys.collect do |where|
|
39
|
+
found = find(where, Path.caller_lib_dir, search_paths)
|
40
|
+
paths = pattern ? Dir.glob(File.join(found, pattern)) : Dir.glob(found)
|
41
|
+
|
42
|
+
paths = paths.collect{|p| self.annotate p }
|
43
|
+
|
44
|
+
paths = paths.each do |p|
|
45
|
+
p.original = File.join(found.original, p.sub(/^#{found}/, ''))
|
46
|
+
p.where = where
|
47
|
+
end if found.original and pattern
|
48
|
+
|
49
|
+
location_paths[where] = paths
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/scout/path.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require_relative 'meta_extension'
|
2
|
+
require_relative 'path/find'
|
3
|
+
require_relative 'path/util'
|
2
4
|
|
3
5
|
module Path
|
4
6
|
extend MetaExtension
|
@@ -31,11 +33,16 @@ module Path
|
|
31
33
|
return nil
|
32
34
|
end
|
33
35
|
|
34
|
-
def self.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def self.default_pkgdir
|
37
|
+
@@default_pkgdir = 'scout'
|
38
|
+
end
|
39
|
+
|
40
|
+
def pkgdir
|
41
|
+
@pkgdir ||= Path.default_pkgdir
|
42
|
+
end
|
43
|
+
|
44
|
+
def libdir
|
45
|
+
@libdir ||= Path.caller_lib_dir
|
39
46
|
end
|
40
47
|
|
41
48
|
def join(subpath, prevpath = nil)
|
data/lib/scout/tmpfile.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require_relative 'misc'
|
2
3
|
|
3
4
|
module TmpFile
|
4
5
|
def self.user_tmp(subdir = nil)
|
@@ -83,13 +84,8 @@ module TmpFile
|
|
83
84
|
|
84
85
|
def self.in_dir(*args)
|
85
86
|
with_dir(*args) do |dir|
|
86
|
-
|
87
|
-
begin
|
88
|
-
FileUtils.mkdir_p dir unless File.exist?(dir)
|
89
|
-
FileUtils.cd dir
|
87
|
+
Misc.in_dir dir do
|
90
88
|
yield dir
|
91
|
-
ensure
|
92
|
-
FileUtils.cd old_pwd
|
93
89
|
end
|
94
90
|
end
|
95
91
|
end
|
data/lib/scout-gear.rb
CHANGED
data/scout-gear.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.
|
5
|
+
# stub: scout-gear 1.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "scout-gear".freeze
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.2.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]
|
@@ -40,39 +40,35 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/scout/log/progress/report.rb",
|
41
41
|
"lib/scout/log/progress/util.rb",
|
42
42
|
"lib/scout/meta_extension.rb",
|
43
|
+
"lib/scout/misc.rb",
|
43
44
|
"lib/scout/path.rb",
|
44
45
|
"lib/scout/path/find.rb",
|
46
|
+
"lib/scout/path/util.rb",
|
45
47
|
"lib/scout/tmpfile.rb",
|
46
48
|
"scout-gear.gemspec",
|
47
49
|
"test/scout/indiferent_hash/test_options.rb",
|
48
50
|
"test/scout/log/test_progress.rb",
|
49
51
|
"test/scout/path/test_find.rb",
|
52
|
+
"test/scout/path/test_util.rb",
|
50
53
|
"test/scout/test_indiferent_hash.rb",
|
51
54
|
"test/scout/test_log.rb",
|
52
55
|
"test/scout/test_meta_extension.rb",
|
56
|
+
"test/scout/test_misc.rb",
|
53
57
|
"test/scout/test_path.rb",
|
54
58
|
"test/scout/test_tmpfile.rb",
|
55
59
|
"test/test_helper.rb"
|
56
60
|
]
|
57
61
|
s.homepage = "http://github.com/mikisvaz/scout-gear".freeze
|
58
62
|
s.licenses = ["MIT".freeze]
|
59
|
-
s.rubygems_version = "3.
|
63
|
+
s.rubygems_version = "3.4.6".freeze
|
60
64
|
s.summary = "basic gear for scouts".freeze
|
61
65
|
|
62
|
-
|
63
|
-
s.specification_version = 4
|
64
|
-
end
|
66
|
+
s.specification_version = 4
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
73
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
74
|
-
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
75
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
76
|
-
end
|
68
|
+
s.add_runtime_dependency(%q<term-ansicolor>.freeze, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
70
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
71
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
72
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
77
73
|
end
|
78
74
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
|
2
2
|
require 'scout/path'
|
3
|
+
require 'scout/misc'
|
3
4
|
require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
|
5
|
+
|
4
6
|
class TestPathFind < Test::Unit::TestCase
|
5
7
|
def test_parts
|
6
8
|
path = Path.setup("share/data/some_file", 'scout')
|
@@ -30,5 +32,36 @@ class TestPathFind < Test::Unit::TestCase
|
|
30
32
|
assert_equal File.join(tmpdir,"share/data/some_file"), path.find(:current)
|
31
33
|
end
|
32
34
|
end
|
35
|
+
|
36
|
+
def test_current_find
|
37
|
+
path = Path.setup("share/data/some_file", 'scout')
|
38
|
+
TmpFile.in_dir do |tmpdir|
|
39
|
+
FileUtils.mkdir_p(File.dirname(File.join(tmpdir, path)))
|
40
|
+
File.write(File.join(tmpdir, path), 'string')
|
41
|
+
assert_equal File.join(tmpdir,"share/data/some_file"), path.find
|
42
|
+
assert_equal :current, path.find.where
|
43
|
+
assert_equal "share/data/some_file", path.find.original
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_current_find_all
|
48
|
+
path = Path.setup("share/data/some_file", 'scout')
|
49
|
+
TmpFile.with_dir do |tmpdir|
|
50
|
+
Path.setup tmpdir
|
51
|
+
|
52
|
+
FileUtils.mkdir_p(tmpdir.lib)
|
53
|
+
FileUtils.mkdir_p(tmpdir.share.data)
|
54
|
+
File.write(tmpdir.share.data.some_file, 'string')
|
55
|
+
|
56
|
+
FileUtils.mkdir_p(tmpdir.subdir.share.data)
|
57
|
+
File.write(tmpdir.subdir.share.data.some_file, 'string')
|
58
|
+
|
59
|
+
path.libdir = tmpdir
|
60
|
+
Misc.in_dir tmpdir.subdir do
|
61
|
+
assert_equal 2, path.find_all.length
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
33
66
|
end
|
34
67
|
|
@@ -0,0 +1,22 @@
|
|
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 TestPathUtil < Test::Unit::TestCase
|
6
|
+
def test_dirname
|
7
|
+
p = Path.setup("/usr/share/scout/data")
|
8
|
+
|
9
|
+
assert_equal "/usr/share/scout", p.dirname
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_glob
|
13
|
+
TmpFile.in_dir :erase => false do |tmpdir|
|
14
|
+
Path.setup tmpdir
|
15
|
+
File.write(tmpdir.foo, 'foo')
|
16
|
+
File.write(tmpdir.bar, 'bar')
|
17
|
+
assert_equal 2, tmpdir.glob.length
|
18
|
+
assert_equal %w(foo bar).sort, tmpdir.glob.collect{|p| p.basename }.sort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -5,10 +5,10 @@ class TestMetaExtension < Test::Unit::TestCase
|
|
5
5
|
module ExtensionClass
|
6
6
|
extend MetaExtension
|
7
7
|
|
8
|
-
extension_attr :code
|
8
|
+
extension_attr :code, :code2
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def test_setup_annotate
|
12
12
|
str = "String"
|
13
13
|
ExtensionClass.setup(str, :code)
|
14
14
|
assert ExtensionClass === str
|
@@ -18,5 +18,19 @@ class TestMetaExtension < Test::Unit::TestCase
|
|
18
18
|
str.annotate(str2)
|
19
19
|
assert_equal :code, str2.code
|
20
20
|
end
|
21
|
+
|
22
|
+
def test_setup_alternatives
|
23
|
+
str = "String"
|
24
|
+
|
25
|
+
ExtensionClass.setup(str, :code2 => :code)
|
26
|
+
assert_equal :code, str.code2
|
27
|
+
|
28
|
+
ExtensionClass.setup(str, code2: :code)
|
29
|
+
assert_equal :code, str.code2
|
30
|
+
|
31
|
+
ExtensionClass.setup(str, "code2" => :code)
|
32
|
+
assert_equal :code, str.code2
|
33
|
+
|
34
|
+
end
|
21
35
|
end
|
22
36
|
|
@@ -0,0 +1,13 @@
|
|
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 TestMisc < Test::Unit::TestCase
|
5
|
+
def test_in_dir
|
6
|
+
TmpFile.with_file do |tmpdir|
|
7
|
+
Misc.in_dir tmpdir do
|
8
|
+
assert_equal tmpdir, FileUtils.pwd
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
data/test/scout/test_path.rb
CHANGED
@@ -32,5 +32,21 @@ class TestPath < Test::Unit::TestCase
|
|
32
32
|
assert_equal 'scout', path.pkgdir
|
33
33
|
assert path.libdir.end_with?("scout-gear")
|
34
34
|
end
|
35
|
+
|
36
|
+
def test_lib_dir
|
37
|
+
TmpFile.with_file do |tmpdir|
|
38
|
+
Path.setup tmpdir
|
39
|
+
FileUtils.mkdir_p tmpdir.lib
|
40
|
+
File.write tmpdir.lib.file, <<-EOR
|
41
|
+
require '#{File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')}'
|
42
|
+
a = "1"
|
43
|
+
Path.setup(a)
|
44
|
+
print a.libdir
|
45
|
+
EOR
|
46
|
+
Misc.in_dir tmpdir.tmp do
|
47
|
+
assert_equal tmpdir, `ruby #{tmpdir.lib.file}`
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
35
51
|
end
|
36
52
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scout-gear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: term-ansicolor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rdoc
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,16 +109,20 @@ files:
|
|
95
109
|
- lib/scout/log/progress/report.rb
|
96
110
|
- lib/scout/log/progress/util.rb
|
97
111
|
- lib/scout/meta_extension.rb
|
112
|
+
- lib/scout/misc.rb
|
98
113
|
- lib/scout/path.rb
|
99
114
|
- lib/scout/path/find.rb
|
115
|
+
- lib/scout/path/util.rb
|
100
116
|
- lib/scout/tmpfile.rb
|
101
117
|
- scout-gear.gemspec
|
102
118
|
- test/scout/indiferent_hash/test_options.rb
|
103
119
|
- test/scout/log/test_progress.rb
|
104
120
|
- test/scout/path/test_find.rb
|
121
|
+
- test/scout/path/test_util.rb
|
105
122
|
- test/scout/test_indiferent_hash.rb
|
106
123
|
- test/scout/test_log.rb
|
107
124
|
- test/scout/test_meta_extension.rb
|
125
|
+
- test/scout/test_misc.rb
|
108
126
|
- test/scout/test_path.rb
|
109
127
|
- test/scout/test_tmpfile.rb
|
110
128
|
- test/test_helper.rb
|
@@ -112,7 +130,7 @@ homepage: http://github.com/mikisvaz/scout-gear
|
|
112
130
|
licenses:
|
113
131
|
- MIT
|
114
132
|
metadata: {}
|
115
|
-
post_install_message:
|
133
|
+
post_install_message:
|
116
134
|
rdoc_options: []
|
117
135
|
require_paths:
|
118
136
|
- lib
|
@@ -127,8 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
145
|
- !ruby/object:Gem::Version
|
128
146
|
version: '0'
|
129
147
|
requirements: []
|
130
|
-
rubygems_version: 3.
|
131
|
-
signing_key:
|
148
|
+
rubygems_version: 3.4.6
|
149
|
+
signing_key:
|
132
150
|
specification_version: 4
|
133
151
|
summary: basic gear for scouts
|
134
152
|
test_files: []
|