reapack-index 1.0beta3 → 1.0beta4
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/.travis.yml +1 -1
- data/README.md +11 -113
- data/Rakefile +1 -1
- data/lib/reapack/index.rb +159 -109
- data/lib/reapack/index/cdetector.rb +120 -0
- data/lib/reapack/index/cli.rb +127 -161
- data/lib/reapack/index/cli/options.rb +29 -10
- data/lib/reapack/index/gem_version.rb +1 -1
- data/lib/reapack/index/git.rb +189 -0
- data/lib/reapack/index/metadata.rb +2 -2
- data/lib/reapack/index/named_node.rb +17 -12
- data/lib/reapack/index/package.rb +16 -9
- data/lib/reapack/index/provides.rb +46 -0
- data/lib/reapack/index/source.rb +59 -0
- data/lib/reapack/index/version.rb +3 -52
- data/reapack-index.gemspec +7 -6
- data/setup/reapack-index.nsi +9 -5
- data/test/cli/test_check.rb +190 -0
- data/test/cli/test_metadata.rb +194 -0
- data/test/cli/test_scan.rb +326 -0
- data/test/data/index.xml +1 -1
- data/test/helper.rb +90 -1
- data/test/index/test_metadata.rb +111 -0
- data/test/index/test_provides.rb +302 -0
- data/test/index/test_scan.rb +333 -0
- data/test/test_cdetector.rb +214 -0
- data/test/test_cli.rb +69 -797
- data/test/test_git.rb +139 -0
- data/test/test_index.rb +109 -703
- data/test/test_metadata.rb +2 -2
- data/test/test_named_node.rb +50 -42
- data/test/test_package.rb +15 -26
- data/test/test_provides.rb +68 -0
- data/test/test_source.rb +115 -0
- data/test/test_version.rb +10 -63
- metadata +33 -22
@@ -0,0 +1,59 @@
|
|
1
|
+
class ReaPack::Index
|
2
|
+
class Source
|
3
|
+
TAG = 'source'.freeze
|
4
|
+
PLATFORM = 'platform'.freeze
|
5
|
+
TYPE = 'type'.freeze
|
6
|
+
FILE = 'file'.freeze
|
7
|
+
|
8
|
+
PLATFORMS = {
|
9
|
+
all: nil,
|
10
|
+
windows: :all, win32: :windows, win64: :windows,
|
11
|
+
darwin: :all, darwin32: :darwin, darwin64: :darwin,
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def is_platform?(input)
|
16
|
+
PLATFORMS.has_key? input&.to_sym
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(url = nil)
|
21
|
+
@url = url
|
22
|
+
@platform = :all
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :platform, :type
|
26
|
+
attr_accessor :file, :url
|
27
|
+
|
28
|
+
def platform=(new_platform)
|
29
|
+
new_platform ||= :all
|
30
|
+
|
31
|
+
unless self.class.is_platform? new_platform
|
32
|
+
raise Error, "invalid platform '#{new_platform}'"
|
33
|
+
end
|
34
|
+
|
35
|
+
@platform = new_platform.to_sym
|
36
|
+
end
|
37
|
+
|
38
|
+
def type=(new_type)
|
39
|
+
return @type = new_type if new_type.nil?
|
40
|
+
|
41
|
+
unless ReaPack::Index.is_type? new_type
|
42
|
+
raise Error, "invalid type '#{new_type}'"
|
43
|
+
end
|
44
|
+
|
45
|
+
@type = new_type.to_sym
|
46
|
+
end
|
47
|
+
|
48
|
+
def make_node(parent)
|
49
|
+
@node = Nokogiri::XML::Node.new TAG, parent.document
|
50
|
+
@node[PLATFORM] = @platform
|
51
|
+
@node[TYPE] = @type if @type
|
52
|
+
@node[FILE] = @file if @file
|
53
|
+
@node.content = Addressable::URI.encode @url
|
54
|
+
@node.parent = parent
|
55
|
+
rescue Addressable::URI::InvalidURIError => e
|
56
|
+
raise Error, e.message
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -5,9 +5,8 @@ class ReaPack::Index
|
|
5
5
|
AUTHOR = 'author'.freeze
|
6
6
|
TIME = 'time'.freeze
|
7
7
|
|
8
|
-
def initialize(node
|
8
|
+
def initialize(node)
|
9
9
|
super
|
10
|
-
|
11
10
|
@changelog = Changelog.new @node
|
12
11
|
end
|
13
12
|
|
@@ -64,13 +63,10 @@ class ReaPack::Index
|
|
64
63
|
new_sources = hash_sources children(Source::TAG)
|
65
64
|
@dirty = was_dirty || old_sources != new_sources
|
66
65
|
|
67
|
-
if new_sources.empty?
|
68
|
-
raise Error, 'no sources found. @provides tag missing?'
|
69
|
-
end
|
66
|
+
raise Error, 'no files provided' if new_sources.empty?
|
70
67
|
end
|
71
68
|
|
72
|
-
def add_source(src
|
73
|
-
src = Source.new src, file, url unless src.is_a? Source
|
69
|
+
def add_source(src)
|
74
70
|
src.make_node @node
|
75
71
|
|
76
72
|
@dirty = true
|
@@ -84,51 +80,6 @@ class ReaPack::Index
|
|
84
80
|
end
|
85
81
|
end
|
86
82
|
|
87
|
-
class Source
|
88
|
-
TAG = 'source'.freeze
|
89
|
-
PLATFORM = 'platform'.freeze
|
90
|
-
FILE = 'file'.freeze
|
91
|
-
|
92
|
-
PLATFORMS = [
|
93
|
-
:all,
|
94
|
-
:windows, :win32, :win64,
|
95
|
-
:darwin, :darwin32, :darwin64,
|
96
|
-
].freeze
|
97
|
-
|
98
|
-
def self.validate_platform(platform)
|
99
|
-
return unless platform # nil platform will be replaced by the default
|
100
|
-
|
101
|
-
unless PLATFORMS.include? platform.to_sym
|
102
|
-
raise Error, 'invalid platform %s' % platform
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def initialize(platform = nil, file = nil, url = nil)
|
107
|
-
self.platform = platform
|
108
|
-
self.file = file
|
109
|
-
self.url = url
|
110
|
-
end
|
111
|
-
|
112
|
-
def platform=(new_platform)
|
113
|
-
new_platform = :all if new_platform.nil?
|
114
|
-
|
115
|
-
self.class.validate_platform new_platform
|
116
|
-
|
117
|
-
@platform = new_platform
|
118
|
-
end
|
119
|
-
|
120
|
-
attr_reader :platform
|
121
|
-
attr_accessor :file, :url
|
122
|
-
|
123
|
-
def make_node(parent)
|
124
|
-
@node = Nokogiri::XML::Node.new TAG, parent.document
|
125
|
-
@node.parent = parent
|
126
|
-
@node[PLATFORM] = @platform
|
127
|
-
@node[FILE] = @file if @file
|
128
|
-
@node.content = Addressable::URI.encode @url
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
83
|
class Changelog
|
133
84
|
TAG = 'changelog'.freeze
|
134
85
|
|
data/reapack-index.gemspec
CHANGED
@@ -9,18 +9,19 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = ReaPack::Index::VERSION
|
10
10
|
spec.authors = ['cfillion']
|
11
11
|
spec.email = ['reapack-index@cfillion.tk']
|
12
|
-
spec.summary = 'Package indexer for
|
12
|
+
spec.summary = 'Package indexer for git-based ReaPack repositories'
|
13
13
|
spec.homepage = 'https://github.com/cfillion/reapack-index'
|
14
|
-
spec.license =
|
14
|
+
spec.license = 'GPL-3.0+'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.required_ruby_version = '>= 2.3'
|
20
22
|
|
21
23
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
24
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
23
|
-
spec.add_development_dependency 'git', '~> 1.3'
|
24
25
|
spec.add_development_dependency 'minitest', '~> 5.8'
|
25
26
|
spec.add_development_dependency 'rake', '~> 11.0'
|
26
27
|
spec.add_development_dependency 'simplecov', '~> 0.11'
|
@@ -28,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
28
29
|
spec.add_runtime_dependency 'addressable', '~> 2.4'
|
29
30
|
spec.add_runtime_dependency 'colorize', '~> 0.7'
|
30
31
|
spec.add_runtime_dependency 'gitable', '~> 0.3'
|
31
|
-
spec.add_runtime_dependency 'metaheader', '~> 1.
|
32
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.6'
|
32
|
+
spec.add_runtime_dependency 'metaheader', '~> 1.1'
|
33
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.6.8.rc2'
|
33
34
|
spec.add_runtime_dependency 'pandoc-ruby', '~> 2.0'
|
34
35
|
spec.add_runtime_dependency 'rugged', '~> 0.24'
|
35
36
|
end
|
data/setup/reapack-index.nsi
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
!include Sections.nsh
|
3
3
|
!include StrRep.nsh
|
4
4
|
|
5
|
-
!define VERSION "1.
|
5
|
+
!define VERSION "1.0beta4"
|
6
6
|
!define NAME "ReaPack Index ${VERSION}"
|
7
7
|
!define LONG_VERSION "0.1.0.0"
|
8
8
|
|
9
|
-
!define RUBY_VERSION "2.
|
9
|
+
!define RUBY_VERSION "2.3.0"
|
10
10
|
!define RUBYINSTALLER_FILE "rubyinstaller-${RUBY_VERSION}.exe"
|
11
11
|
!define RUBYINSTALLER_URL \
|
12
12
|
"http://dl.bintray.com/oneclick/rubyinstaller/${RUBYINSTALLER_FILE}"
|
@@ -19,7 +19,7 @@
|
|
19
19
|
!define RUGGED_VERSION "0.24.0"
|
20
20
|
!define RUGGED_FILE "rugged-${RUGGED_VERSION}-%PLATFORM%.gem"
|
21
21
|
!define RUGGED_URL \
|
22
|
-
"https://github.com/cfillion/reapack-index/releases/download/
|
22
|
+
"https://github.com/cfillion/reapack-index/releases/download/v1.0beta4/${RUGGED_FILE}"
|
23
23
|
|
24
24
|
Name "${NAME}"
|
25
25
|
OutFile "reapack-index-${VERSION}.exe"
|
@@ -124,11 +124,15 @@ SectionEnd
|
|
124
124
|
Function .onInit
|
125
125
|
!insertmacro RELOAD_PATH
|
126
126
|
nsExec::ExecToStack '"ruby" -e " \
|
127
|
+
rubyver = Gem::Version.new(RUBY_VERSION); \
|
128
|
+
exit 2 unless rubyver >= Gem::Version.new(\"${RUBY_VERSION}\"); \
|
129
|
+
; \
|
127
130
|
spec = Gem::Specification.find_all_by_name(\"rugged\").first; \
|
128
131
|
req = Gem::Requirement.new(\"~> ${RUGGED_VERSION}\"); \
|
129
|
-
|
132
|
+
exit 3 unless spec && req =~ spec.version'
|
130
133
|
Pop $0
|
131
134
|
|
135
|
+
StrCmp $0 "2" +2 0 ; ruby out of date
|
132
136
|
StrCmp $0 "error" 0 +6 ; failed to launch ruby
|
133
137
|
SectionGetFlags ${InstallRuby} $1
|
134
138
|
IntOp $1 $1 | ${SF_SELECTED}
|
@@ -136,7 +140,7 @@ Function .onInit
|
|
136
140
|
SectionSetFlags ${InstallRuby} $1
|
137
141
|
Goto +2 ; also install rugged
|
138
142
|
|
139
|
-
StrCmp $0 "
|
143
|
+
StrCmp $0 "3" 0 +5 ; rugged missing/out of date
|
140
144
|
SectionGetFlags ${InstallRugged} $1
|
141
145
|
IntOp $1 $1 | ${SF_SELECTED}
|
142
146
|
IntOp $1 $1 | ${SF_RO}
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require File.expand_path '../../helper', __FILE__
|
2
|
+
|
3
|
+
TestCLI ||= Class.new MiniTest::Test
|
4
|
+
|
5
|
+
class TestCLI::Check < MiniTest::Test
|
6
|
+
include CLIHelper
|
7
|
+
|
8
|
+
def test_pass
|
9
|
+
expected = <<-STDERR
|
10
|
+
..
|
11
|
+
|
12
|
+
Finished checks for 2 packages with 0 failures
|
13
|
+
STDERR
|
14
|
+
|
15
|
+
setup = proc { mkfile 'index.xml', '<index name="test"/>' }
|
16
|
+
|
17
|
+
wrapper ['--check'], setup: setup do
|
18
|
+
mkfile 'test1.lua', '@version 1.0'
|
19
|
+
mkfile 'test2.lua', '@version 1.0'
|
20
|
+
|
21
|
+
assert_output nil, expected do
|
22
|
+
assert_equal true, @cli.run
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_failure
|
28
|
+
expected = <<-STDERR
|
29
|
+
F.
|
30
|
+
|
31
|
+
1) cat/test1.lua failed:
|
32
|
+
missing tag 'version'
|
33
|
+
missing value for tag 'author'
|
34
|
+
|
35
|
+
Finished checks for 2 packages with 1 failure
|
36
|
+
STDERR
|
37
|
+
|
38
|
+
setup = proc { mkfile 'index.xml', '<index name="test"/>' }
|
39
|
+
|
40
|
+
wrapper ['--check'], setup: setup do
|
41
|
+
mkfile 'cat/test1.lua', '@author'
|
42
|
+
mkfile 'cat/test2.lua', '@version 1.0'
|
43
|
+
|
44
|
+
assert_output nil, expected do
|
45
|
+
assert_equal false, @cli.run
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_uses_scan
|
51
|
+
expected = <<-STDERR
|
52
|
+
F
|
53
|
+
|
54
|
+
1) Hello/World.lua failed:
|
55
|
+
file not found 'background.png'
|
56
|
+
|
57
|
+
Finished checks for 1 package with 1 failure
|
58
|
+
STDERR
|
59
|
+
|
60
|
+
setup = proc {
|
61
|
+
mkfile 'index.xml', <<-XML
|
62
|
+
<index name="test">
|
63
|
+
<category name="Hello">
|
64
|
+
<reapack name="World.lua" type="script">
|
65
|
+
<version name="1.0"/>
|
66
|
+
</reapack>
|
67
|
+
</category>
|
68
|
+
</index>
|
69
|
+
XML
|
70
|
+
}
|
71
|
+
|
72
|
+
wrapper ['--check'], setup: setup do
|
73
|
+
mkfile 'Hello/World.lua', "@version 1.0\n@provides background.png"
|
74
|
+
|
75
|
+
assert_output nil, expected do
|
76
|
+
assert_equal false, @cli.run
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_quiet
|
82
|
+
expected = <<-STDERR
|
83
|
+
1) cat/test1.lua failed:
|
84
|
+
missing tag 'version'
|
85
|
+
missing value for tag 'author'
|
86
|
+
|
87
|
+
2) cat/test2.lua failed:
|
88
|
+
missing tag 'version'
|
89
|
+
STDERR
|
90
|
+
|
91
|
+
setup = proc { mkfile 'index.xml', '<index name="test"/>' }
|
92
|
+
|
93
|
+
wrapper ['--check', '--quiet'], setup: setup do
|
94
|
+
mkfile 'cat/test1.lua', '@author'
|
95
|
+
mkfile 'cat/test2.lua'
|
96
|
+
mkfile 'cat/test3.lua', '@version 1.0'
|
97
|
+
|
98
|
+
assert_output nil, expected do
|
99
|
+
assert_equal false, @cli.run
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_ignore
|
105
|
+
setup = proc {
|
106
|
+
Dir.chdir @git.path
|
107
|
+
mkfile 'index.xml', '<index name="test"/>'
|
108
|
+
}
|
109
|
+
|
110
|
+
expected = <<-STDERR
|
111
|
+
.
|
112
|
+
|
113
|
+
Finished checks for 1 package with 0 failures
|
114
|
+
STDERR
|
115
|
+
|
116
|
+
wrapper ['--check', '--ignore=Hello', '--ignore=Chunky/Bacon.lua',
|
117
|
+
'--ignore=test2.lua', '--ignore=Directory/test'], setup: setup do
|
118
|
+
mkfile 'Hello/World.lua', 'konnichiwa'
|
119
|
+
mkfile 'Chunky/Bacon.lua', 'konnichiwa'
|
120
|
+
mkfile 'Directory/test/1.lua', 'konnichiwa'
|
121
|
+
mkfile 'Directory/test2.lua', '@version 1.0'
|
122
|
+
|
123
|
+
assert_output nil, expected do
|
124
|
+
@cli.run
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_ignore_from_config
|
130
|
+
expected = <<-STDERR
|
131
|
+
.
|
132
|
+
|
133
|
+
Finished checks for 1 package with 0 failures
|
134
|
+
STDERR
|
135
|
+
|
136
|
+
setup = proc {
|
137
|
+
mkfile '.reapack-index.conf', <<-CONFIG
|
138
|
+
--ignore=Hello
|
139
|
+
--ignore=Chunky/Bacon.lua
|
140
|
+
--ignore=test2.lua
|
141
|
+
CONFIG
|
142
|
+
|
143
|
+
mkfile 'index.xml', '<index name="test"/>'
|
144
|
+
}
|
145
|
+
|
146
|
+
wrapper ['--check'], setup: setup do
|
147
|
+
mkfile 'Hello/World.lua', 'konnichiwa'
|
148
|
+
mkfile 'Chunky/Bacon.lua', 'konnichiwa'
|
149
|
+
mkfile 'Directory/test2.lua', '@version 1.0'
|
150
|
+
|
151
|
+
assert_output nil, expected do
|
152
|
+
@cli.run
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_unset_name_warning
|
158
|
+
wrapper ['--check'] do
|
159
|
+
assert_output nil, /index is unnamed/i do
|
160
|
+
@cli.run
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_verbose
|
166
|
+
expected = <<-STDERR
|
167
|
+
Path/To/test1.lua: failed
|
168
|
+
test2.lua: passed
|
169
|
+
|
170
|
+
1) Path/To/test1.lua failed:
|
171
|
+
missing tag 'version'
|
172
|
+
missing value for tag 'author'
|
173
|
+
|
174
|
+
Finished checks for 2 packages with 1 failure
|
175
|
+
STDERR
|
176
|
+
|
177
|
+
setup = proc { mkfile 'index.xml', '<index name="test"/>' }
|
178
|
+
|
179
|
+
_, stderr = capture_io do
|
180
|
+
wrapper ['--check', '--verbose'], setup: setup do
|
181
|
+
mkfile 'Path/To/test1.lua', '@author'
|
182
|
+
mkfile 'test2.lua', '@version 1.0'
|
183
|
+
|
184
|
+
assert_equal false, @cli.run
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
assert_match expected, stderr
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require File.expand_path '../../helper', __FILE__
|
2
|
+
|
3
|
+
TestCLI ||= Class.new MiniTest::Test
|
4
|
+
|
5
|
+
class TestCLI::Metadata < MiniTest::Test
|
6
|
+
include CLIHelper
|
7
|
+
|
8
|
+
def test_website_link
|
9
|
+
wrapper ['-l http://cfillion.tk'] do
|
10
|
+
assert_output "1 new website link, empty index\n" do
|
11
|
+
assert_equal true, @cli.run
|
12
|
+
end
|
13
|
+
|
14
|
+
assert_match 'rel="website">http://cfillion.tk</link>', read_index
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_donation_link
|
19
|
+
wrapper ['--donation-link', 'Link Label=http://cfillion.tk'] do
|
20
|
+
assert_output "1 new donation link, empty index\n" do
|
21
|
+
assert_equal true, @cli.run
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_match 'rel="donation" href="http://cfillion.tk">Link Label</link>',
|
25
|
+
read_index
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_invalid_link
|
30
|
+
wrapper ['--link', 'shinsekai yori', '--donation-link', 'hello world',
|
31
|
+
'--link', 'http://cfillion.tk'] do
|
32
|
+
stdout, stderr = capture_io do
|
33
|
+
assert_equal true, @cli.run
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_equal "1 new website link, empty index\n", stdout
|
37
|
+
assert_match /warning: --link: invalid link 'shinsekai yori'/i, stderr
|
38
|
+
assert_match /warning: --donation-link: invalid link 'hello world'/i, stderr
|
39
|
+
assert_match 'rel="website">http://cfillion.tk</link>', read_index
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_remove_link
|
44
|
+
wrapper ['--link', 'http://test.com', '--link', '-http://test.com'] do
|
45
|
+
assert_output "1 new website link, 1 removed website link, empty index\n" do
|
46
|
+
assert_equal true, @cli.run
|
47
|
+
end
|
48
|
+
|
49
|
+
refute_match 'rel="website">http://test.com</link>', read_index
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_list_links
|
54
|
+
setup = proc {
|
55
|
+
mkfile 'index.xml', <<-XML
|
56
|
+
<?xml version="1.0" encoding="utf-8"?>
|
57
|
+
<index version="1">
|
58
|
+
<metadata>
|
59
|
+
<link rel="website" href="http://anidb.net/a9002">Shinsekai Yori</link>
|
60
|
+
<link rel="donation" href="http://paypal.com">Donate!</link>
|
61
|
+
<link rel="website">http://cfillion.tk</link>
|
62
|
+
XML
|
63
|
+
}
|
64
|
+
|
65
|
+
wrapper ['--ls-links'], setup: setup do
|
66
|
+
stdin, stderr = capture_io do
|
67
|
+
assert_equal true, @cli.run
|
68
|
+
end
|
69
|
+
|
70
|
+
expected = <<-OUT
|
71
|
+
[website] Shinsekai Yori (http://anidb.net/a9002)
|
72
|
+
[website] http://cfillion.tk
|
73
|
+
[donation] Donate! (http://paypal.com)
|
74
|
+
OUT
|
75
|
+
|
76
|
+
assert_equal expected, stdin
|
77
|
+
assert_empty stderr
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_about
|
82
|
+
opts = ['--about']
|
83
|
+
setup = proc { opts << mkfile('README.md', '# Hello World') }
|
84
|
+
|
85
|
+
wrapper opts, setup: setup do
|
86
|
+
assert_output "1 modified metadata, empty index\n" do
|
87
|
+
assert_equal true, @cli.run
|
88
|
+
end
|
89
|
+
|
90
|
+
assert_match 'Hello World', read_index
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_about_file_not_found
|
95
|
+
# 404.md is read in the working directory
|
96
|
+
wrapper ['--about=404.md'] do
|
97
|
+
assert_output "empty index\n",
|
98
|
+
/warning: --about: no such file or directory - 404.md/i do
|
99
|
+
assert_equal true, @cli.run
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_about_pandoc_not_found
|
105
|
+
old_path = ENV['PATH']
|
106
|
+
|
107
|
+
opts = ['--about']
|
108
|
+
|
109
|
+
setup = proc {
|
110
|
+
opts << mkfile('README.md', '# Hello World')
|
111
|
+
}
|
112
|
+
|
113
|
+
wrapper opts, setup: setup do
|
114
|
+
assert_output "empty index\n", /pandoc executable cannot be found/i do
|
115
|
+
ENV['PATH'] = String.new
|
116
|
+
assert_equal true, @cli.run
|
117
|
+
end
|
118
|
+
end
|
119
|
+
ensure
|
120
|
+
ENV['PATH'] = old_path
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_about_clear
|
124
|
+
setup = proc {
|
125
|
+
mkfile 'index.xml', <<-XML
|
126
|
+
<index>
|
127
|
+
<metadata>
|
128
|
+
<description><![CDATA[Hello World]]></description>
|
129
|
+
</metadata>
|
130
|
+
</index>
|
131
|
+
XML
|
132
|
+
}
|
133
|
+
|
134
|
+
wrapper ['--remove-about'], setup: setup do
|
135
|
+
assert_output "1 modified metadata\n" do
|
136
|
+
assert_equal true, @cli.run
|
137
|
+
end
|
138
|
+
|
139
|
+
refute_match 'Hello World', read_index
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_about_dump
|
144
|
+
setup = proc {
|
145
|
+
mkfile 'index.xml', <<-XML
|
146
|
+
<index>
|
147
|
+
<metadata>
|
148
|
+
<description><![CDATA[Hello World]]></description>
|
149
|
+
</metadata>
|
150
|
+
</index>
|
151
|
+
XML
|
152
|
+
}
|
153
|
+
|
154
|
+
wrapper ['--dump-about'], setup: setup do
|
155
|
+
assert_output 'Hello World' do
|
156
|
+
assert_equal true, @cli.run
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_unset_name_warning
|
162
|
+
wrapper do
|
163
|
+
_, stderr = capture_io do
|
164
|
+
assert_equal true, @cli.run
|
165
|
+
end
|
166
|
+
|
167
|
+
assert_match /index is unnamed/i, stderr
|
168
|
+
refute_match File.dirname($0), stderr
|
169
|
+
refute_match 'name', read_index
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_set_name
|
174
|
+
wrapper ['--name=Hello World'] do
|
175
|
+
_, stderr = capture_io do
|
176
|
+
assert_equal true, @cli.run
|
177
|
+
end
|
178
|
+
|
179
|
+
refute_match /index is unnamed/i, stderr
|
180
|
+
assert_match 'name="Hello World"', read_index
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_set_name_invalid
|
185
|
+
wrapper ['--name=Hello/World'] do
|
186
|
+
_, stderr = capture_io do
|
187
|
+
assert_equal true, @cli.run
|
188
|
+
end
|
189
|
+
|
190
|
+
refute_match /The name of this index is unset/i, stderr
|
191
|
+
assert_match /invalid name 'Hello\/World'/i, stderr
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|