reapack-index 1.1beta3 → 1.1beta4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fe0c0ad52b4938c414bacfff63b2981614c2df2
4
- data.tar.gz: 4c799d2fd3f4d7823bad7ac142cc08146c029c60
3
+ metadata.gz: 68a03118ab26b00e4fd7969dc54c9b2b350f517a
4
+ data.tar.gz: 2bc39e1d5de9c718b69f8f8efbcd4c10fcc3e496
5
5
  SHA512:
6
- metadata.gz: 8c0f24e952b9c836e5db6172928bcd5366f60dba50388fee7d54bd6159b9b3afcbf8c954af8613235a99b463a339a7d561fca7928930dbcab2d7b8649eb7eb53
7
- data.tar.gz: 84acc8f432d45f95d51053c05e2a0233ea4b961e933c2c849cdb471e11f8b93c60d68ebbc86b0624d80547beefaccc85a34941cdddb0e52964c7ea24a63d1afa
6
+ metadata.gz: 88efa5f4a1116dd6ad47cb3fe2bf3418eac5621a6c2e5031e7d33284b66a5540977bc11a1e89ba4e9f60cbeccc91409841a6b64c0a227dbdd75945950baa1395
7
+ data.tar.gz: 8fd0bcb5dba3dcc5f20dd5eccc0e82f21f4ec4017bd1ca2cf6e85fb7e6b9ffe23cb1b69c9d3b23c5045c27efcdb149a546c640c3280cfc24b8588ca5c9d8ad2f
data/.travis.yml CHANGED
@@ -3,6 +3,6 @@ rvm:
3
3
  - 2.3.0
4
4
  before_install:
5
5
  - gem update bundler
6
- - sudo apt-get -qq update
7
- - sudo apt-get install -y pandoc
6
+ - wget https://github.com/jgm/pandoc/releases/download/1.17.2/pandoc-1.17.2-1-amd64.deb -O pandoc.deb
7
+ - sudo dpkg -i pandoc.deb
8
8
  cache: bundler
data/README.md CHANGED
@@ -32,7 +32,7 @@ Modes:
32
32
  -s, --scan [FILE|COMMIT] Scan new commits (default), a file or a commit
33
33
  --rebuild Clear the index and rescan the whole git history
34
34
  Indexer options:
35
- -a, --[no-]amend Reindex existing versions
35
+ -a, --[no-]amend Update existing versions
36
36
  -i, --ignore PATH Don't check or index any file starting with PATH
37
37
  -o, --output FILE=./index.xml Set the output filename and path for the index
38
38
  --[no-]strict Enable strict validation mode
data/bin/reapack-index CHANGED
@@ -5,4 +5,4 @@ Signal.trap('INT') { abort }
5
5
  require 'reapack/index'
6
6
 
7
7
  String.disable_colorization = !STDOUT.tty? || !STDERR.tty?
8
- exit !!ReaPack::Index::CLI.new(ARGV).run
8
+ exit !!catch(:stop) { ReaPack::Index::CLI.new(ARGV).run }
data/lib/reapack/index.rb CHANGED
@@ -298,10 +298,15 @@ private
298
298
 
299
299
  def sort(node)
300
300
  node.element_children.map {|n| sort n }
301
- return if node.name == Package.tag
302
301
 
303
302
  sorted = node.element_children
304
- .stable_sort_by {|n| n[:name].to_s.downcase }
303
+ .stable_sort_by {|n|
304
+ if n.name == Version.tag
305
+ '' # don't sort version tags by name attribute value
306
+ else
307
+ n[:name].to_s.downcase
308
+ end
309
+ }
305
310
  .stable_sort_by {|n| n.name.downcase }
306
311
 
307
312
  sorted.each {|n| node << n }
@@ -2,16 +2,13 @@ class ReaPack::Index::CLI
2
2
  attr_reader :index
3
3
 
4
4
  def initialize(argv = [])
5
- @opts = parse_options(argv)
6
- path = argv.last || Dir.pwd
5
+ @opts = parse_options argv
7
6
 
8
- return unless @exit.nil?
7
+ @git = ReaPack::Index::Git.new argv.first || Dir.pwd
8
+ log "found git repository in #{@git.path}"
9
9
 
10
- @git = ReaPack::Index::Git.new path
11
10
  @opts = parse_options(read_config).merge @opts unless @opts[:noconfig]
12
-
13
11
  @opts = DEFAULTS.merge @opts
14
- return unless @exit.nil?
15
12
 
16
13
  log Hash[@opts.sort].inspect
17
14
 
@@ -21,12 +18,10 @@ class ReaPack::Index::CLI
21
18
  set_url_template
22
19
  rescue Rugged::OSError, Rugged::RepositoryError, ReaPack::Index::Error => e
23
20
  $stderr.puts e.message
24
- @exit = false
21
+ throw :stop, false
25
22
  end
26
23
 
27
24
  def run
28
- return @exit unless @exit.nil?
29
-
30
25
  if @opts[:check]
31
26
  return do_check
32
27
  end
@@ -45,7 +40,7 @@ class ReaPack::Index::CLI
45
40
 
46
41
  unless @index.modified?
47
42
  $stderr.puts 'Nothing to do!' unless @opts[:quiet]
48
- return success_code
43
+ return
49
44
  end
50
45
 
51
46
  # changelog will be cleared by Index#write!
@@ -54,15 +49,10 @@ class ReaPack::Index::CLI
54
49
 
55
50
  @index.write!
56
51
  commit changelog
57
-
58
- success_code
52
+ true
59
53
  end
60
54
 
61
55
  private
62
- def success_code
63
- @exit.nil? ? true : @exit
64
- end
65
-
66
56
  def set_url_template
67
57
  tpl = @opts[:url_template]
68
58
  is_custom = tpl != DEFAULTS[:url_template]
@@ -92,9 +82,8 @@ private
92
82
  elsif c = @git.get_commit(hash)
93
83
  c
94
84
  else
95
- $stderr.puts "--scan: bad file or revision: '%s'" % @opts[:scan]
96
- @exit = false
97
- nil
85
+ $stderr.puts "--scan: bad file or revision: '%s'" % hash
86
+ throw :stop, false
98
87
  end
99
88
  }.compact
100
89
  end
@@ -72,7 +72,7 @@ class ReaPack::Index::CLI
72
72
 
73
73
  op.separator 'Indexer options:'
74
74
 
75
- op.on '-a', '--[no-]amend', 'Reindex existing versions' do |bool|
75
+ op.on '-a', '--[no-]amend', 'Update existing versions' do |bool|
76
76
  opts[:amend] = bool
77
77
  end
78
78
 
@@ -171,14 +171,12 @@ class ReaPack::Index::CLI
171
171
 
172
172
  op.on_tail '-v', '--version', 'Display version information' do
173
173
  puts op.ver
174
- @exit = true
175
- return opts
174
+ throw :stop, true
176
175
  end
177
176
 
178
177
  op.on_tail '-h', '--help', 'Prints this help' do
179
178
  puts op
180
- @exit = true
181
- return opts
179
+ throw :stop, true
182
180
  end
183
181
  end.parse! args
184
182
 
@@ -186,7 +184,6 @@ class ReaPack::Index::CLI
186
184
  rescue OptionParser::ParseError => e
187
185
  $stderr.puts "#{PROGRAM_NAME}: #{e.message}"
188
186
  $stderr.puts "Try '#{PROGRAM_NAME} --help' for more information."
189
- @exit = false
190
- opts
187
+ throw :stop, false
191
188
  end
192
189
  end
@@ -1,5 +1,5 @@
1
1
  module ReaPack
2
2
  class Index
3
- VERSION = '1.1beta3'
3
+ VERSION = '1.1beta4'
4
4
  end
5
5
  end
@@ -158,7 +158,7 @@ class ReaPack::Index
158
158
  end
159
159
 
160
160
  def inspect
161
- "#<#{self.class} #{id} #{message}>"
161
+ "#<#{self.class} #{id} #{summary}>"
162
162
  end
163
163
 
164
164
  private
@@ -143,12 +143,12 @@ class ReaPack::Index
143
143
  end
144
144
 
145
145
  def make_rtf(content)
146
- PandocRuby.new(content).to_rtf :standalone
146
+ PandocRuby.new(content).to_rtf :standalone, f: :commonmark
147
147
  rescue Errno::ENOENT
148
148
  raise Error, [
149
149
  "RTF conversion failed because the pandoc executable " \
150
150
  "cannot be found in your PATH.",
151
- "Try again after installing pandoc from <http://pandoc.org/>."
151
+ "Try again after installing pandoc <http://pandoc.org/>."
152
152
  ].join("\n")
153
153
  end
154
154
 
@@ -38,7 +38,7 @@ class ReaPack::Index
38
38
  HEADER_ALIASES = {
39
39
  [:reascript_name, :jsfx_name, :theme_name,
40
40
  :extension_name, :desc] => :description,
41
- :links => :link,
41
+ [:links, :website] => :link,
42
42
  :screenshots => :screenshot,
43
43
  }.freeze
44
44
 
@@ -129,7 +129,15 @@ class ReaPack::Index
129
129
  raise Error, "file not found '#{line.file_pattern}'" if files.empty?
130
130
  else
131
131
  # use the relative path for external urls
132
- files = [line.file_pattern]
132
+ if line.file_pattern.start_with? '/'
133
+ prefix = []
134
+ dirs = File.split(@pkg.category).size - 1
135
+ dirs.times { prefix << '..' }
136
+
137
+ files = [File.join(*prefix, line.file_pattern)]
138
+ else
139
+ files = [line.file_pattern]
140
+ end
133
141
  end
134
142
 
135
143
  files.map {|file|
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'addressable', '~> 2.4'
30
30
  spec.add_runtime_dependency 'colorize', '~> 0.7'
31
31
  spec.add_runtime_dependency 'gitable', '~> 0.3'
32
- spec.add_runtime_dependency 'metaheader', '~> 1.3beta2'
32
+ spec.add_runtime_dependency 'metaheader', '~> 1.3beta4'
33
33
  spec.add_runtime_dependency 'nokogiri', '~> 1.6.8'
34
34
  spec.add_runtime_dependency 'pandoc-ruby', '~> 2.0'
35
35
  spec.add_runtime_dependency 'rugged', '~> 0.24'
@@ -1,9 +1,11 @@
1
+ Unicode true
2
+
1
3
  !include MUI2.nsh
2
4
  !include Sections.nsh
3
5
  !include StrRep.nsh
4
6
 
5
- !define VERSION "1.1beta3"
6
- !define NAME "ReaPack Index ${VERSION}"
7
+ !define VERSION "1.1beta4"
8
+ !define NAME "reapack-index ${VERSION}"
7
9
  !define LONG_VERSION "0.1.0.0"
8
10
 
9
11
  !define RUBY_VERSION "2.3.1"
@@ -11,8 +13,8 @@
11
13
  !define RUBYINSTALLER_URL \
12
14
  "http://dl.bintray.com/oneclick/rubyinstaller/${RUBYINSTALLER_FILE}"
13
15
 
14
- !define PANDOC_VERSION "1.17.1"
15
- !define PANDOC_FILE "pandoc-${PANDOC_VERSION}-1-windows.msi"
16
+ !define PANDOC_VERSION "1.17.2"
17
+ !define PANDOC_FILE "pandoc-${PANDOC_VERSION}-windows.msi"
16
18
  !define PANDOC_URL \
17
19
  "https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/${PANDOC_FILE}"
18
20
 
@@ -74,7 +76,7 @@ VIAddVersionKey "LegalCopyright" "Copyright (C) 2015-2016 Christian Fillion"
74
76
  !macro RELOAD_PATH
75
77
  ; reload the path to use the one freshly set by the ruby installer
76
78
  ReadRegStr $R1 HKCU "Environment" "Path"
77
- System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("Path", R1).r2'
79
+ System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("Path", R1).r2'
78
80
  !macroend
79
81
 
80
82
  Section /o "Ruby for Windows" InstallRuby
@@ -125,7 +127,7 @@ Section /o "Pandoc" InstallPandoc
125
127
  !insertmacro EXEC_GUI '"msiexec" /i $R0 /passive' ${PANDOC_FILE}
126
128
  SectionEnd
127
129
 
128
- Section "ReaPack Index" InstallMain
130
+ Section "reapack-index" InstallMain
129
131
  SectionIn RO
130
132
 
131
133
  DetailPrint "Installing reapack-index... (this can take a while)"
@@ -162,10 +164,9 @@ Function .onInit
162
164
  nsExec::ExecToStack '"pandoc" --version'
163
165
  Pop $0
164
166
 
165
- StrCmp $0 "error" 0 +5 ; failed to launch pandoc
167
+ StrCmp $0 "error" 0 +4 ; failed to launch pandoc
166
168
  SectionGetFlags ${InstallPandoc} $1
167
169
  IntOp $1 $1 | ${SF_SELECTED}
168
- IntOp $1 $1 | ${SF_RO}
169
170
  SectionSetFlags ${InstallPandoc} $1
170
171
 
171
172
  SectionGetFlags ${InstallMain} $1
@@ -184,5 +185,5 @@ FunctionEnd
184
185
  "Install Pandoc to enable automatic conversion from various document formats into RTF."
185
186
 
186
187
  !insertmacro MUI_DESCRIPTION_TEXT ${InstallMain} \
187
- "Install ReaPack's Package Indexer v${VERSION} on your computer."
188
+ "Install Package indexer for git-based ReaPack repositories v${VERSION} on your computer."
188
189
  !insertmacro MUI_FUNCTION_DESCRIPTION_END
@@ -66,7 +66,7 @@ Finished checks for 2 packages with 1 failure
66
66
  wrapper ['--check'], setup: setup do
67
67
  mkfile 'Chunky/Bacon.lua', "@version 1.0\n@provides ../background.png"
68
68
 
69
- capture_io { assert_equal true, @cli.run }
69
+ capture_io { @cli.run }
70
70
  end
71
71
  end
72
72
 
@@ -112,9 +112,7 @@ Finished checks for 1 package with 0 failures
112
112
  mkfile 'Directory/test/1.lua', 'konnichiwa'
113
113
  mkfile 'Directory/test2.lua', '@version 1.0'
114
114
 
115
- assert_output nil, expected do
116
- @cli.run
117
- end
115
+ assert_output(nil, expected) { @cli.run }
118
116
  end
119
117
  end
120
118
 
@@ -148,9 +146,7 @@ Finished checks for 1 package with 0 failures
148
146
 
149
147
  def test_unset_name_warning
150
148
  wrapper ['--check'] do
151
- assert_output nil, /index is unnamed/i do
152
- @cli.run
153
- end
149
+ assert_output(nil, /index is unnamed/i) { @cli.run }
154
150
  end
155
151
  end
156
152
 
@@ -187,7 +183,7 @@ Finished checks for 2 packages with 1 failure
187
183
  wrapper ['--check'], setup: setup do
188
184
  mkfile 'test.lua', '@version 1.0'
189
185
 
190
- assert_equal true, @cli.run
186
+ @cli.run
191
187
  end
192
188
  end
193
189
 
@@ -7,19 +7,14 @@ class TestCLI::Metadata < MiniTest::Test
7
7
 
8
8
  def test_website_link
9
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
-
10
+ assert_output("1 new website link, empty index\n") { @cli.run }
14
11
  assert_match 'rel="website">http://cfillion.tk</link>', read_index
15
12
  end
16
13
  end
17
14
 
18
15
  def test_donation_link
19
16
  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
17
+ assert_output("1 new donation link, empty index\n") { @cli.run }
23
18
 
24
19
  assert_match 'rel="donation" href="http://cfillion.tk">Link Label</link>',
25
20
  read_index
@@ -28,9 +23,7 @@ class TestCLI::Metadata < MiniTest::Test
28
23
 
29
24
  def test_screenshot_link
30
25
  wrapper ['--screenshot-link', 'Link Label http://cfillion.tk'] do
31
- assert_output "1 new screenshot link, empty index\n" do
32
- assert_equal true, @cli.run
33
- end
26
+ assert_output("1 new screenshot link, empty index\n") { @cli.run }
34
27
 
35
28
  assert_match 'rel="screenshot" href="http://cfillion.tk">Link Label</link>',
36
29
  read_index
@@ -41,9 +34,7 @@ class TestCLI::Metadata < MiniTest::Test
41
34
  wrapper ['--link', 'shinsekai yori', '--donation-link', 'hello world',
42
35
  '--screenshot-link', 'chunky bacon',
43
36
  '--link', 'http://cfillion.tk'] do
44
- stdout, stderr = capture_io do
45
- assert_equal true, @cli.run
46
- end
37
+ stdout, stderr = capture_io { @cli.run }
47
38
 
48
39
  assert_equal "1 new website link, empty index\n", stdout
49
40
  assert_match /warning: --link: invalid link 'shinsekai yori'/i, stderr
@@ -55,10 +46,7 @@ class TestCLI::Metadata < MiniTest::Test
55
46
 
56
47
  def test_remove_link
57
48
  wrapper ['--link', 'http://test.com', '--link', '-http://test.com'] do
58
- assert_output "1 new website link, 1 removed website link, empty index\n" do
59
- assert_equal true, @cli.run
60
- end
61
-
49
+ assert_output("1 new website link, 1 removed website link, empty index\n") { @cli.run }
62
50
  refute_match 'rel="website">http://test.com</link>', read_index
63
51
  end
64
52
  end
@@ -77,7 +65,7 @@ class TestCLI::Metadata < MiniTest::Test
77
65
 
78
66
  wrapper ['--ls-links'], setup: setup do
79
67
  stdin, stderr = capture_io do
80
- assert_equal true, @cli.run
68
+ @cli.run
81
69
  end
82
70
 
83
71
  expected = <<-OUT
@@ -96,9 +84,7 @@ class TestCLI::Metadata < MiniTest::Test
96
84
  setup = proc { opts << mkfile('README.md', '# Hello World') }
97
85
 
98
86
  wrapper opts, setup: setup do
99
- assert_output "1 modified metadata, empty index\n" do
100
- assert_equal true, @cli.run
101
- end
87
+ assert_output("1 modified metadata, empty index\n") { @cli.run }
102
88
 
103
89
  assert_match 'Hello World', read_index
104
90
  end
@@ -109,7 +95,7 @@ class TestCLI::Metadata < MiniTest::Test
109
95
  wrapper ['--about=404.md'] do
110
96
  assert_output "empty index\n",
111
97
  /warning: --about: no such file or directory - 404.md/i do
112
- assert_equal true, @cli.run
98
+ @cli.run
113
99
  end
114
100
  end
115
101
  end
@@ -126,7 +112,7 @@ class TestCLI::Metadata < MiniTest::Test
126
112
  wrapper opts, setup: setup do
127
113
  assert_output "empty index\n", /pandoc executable cannot be found/i do
128
114
  ENV['PATH'] = String.new
129
- assert_equal true, @cli.run
115
+ @cli.run
130
116
  end
131
117
  end
132
118
  ensure
@@ -145,10 +131,7 @@ class TestCLI::Metadata < MiniTest::Test
145
131
  }
146
132
 
147
133
  wrapper ['--remove-about'], setup: setup do
148
- assert_output "1 modified metadata\n" do
149
- assert_equal true, @cli.run
150
- end
151
-
134
+ assert_output("1 modified metadata\n") { @cli.run }
152
135
  refute_match 'Hello World', read_index
153
136
  end
154
137
  end
@@ -165,17 +148,13 @@ class TestCLI::Metadata < MiniTest::Test
165
148
  }
166
149
 
167
150
  wrapper ['--dump-about'], setup: setup do
168
- assert_output 'Hello World' do
169
- assert_equal true, @cli.run
170
- end
151
+ assert_output('Hello World') { @cli.run }
171
152
  end
172
153
  end
173
154
 
174
155
  def test_unset_name_warning
175
156
  wrapper do
176
- _, stderr = capture_io do
177
- assert_equal true, @cli.run
178
- end
157
+ _, stderr = capture_io { @cli.run }
179
158
 
180
159
  assert_match /index is unnamed/i, stderr
181
160
  refute_match File.dirname($0), stderr
@@ -185,9 +164,7 @@ class TestCLI::Metadata < MiniTest::Test
185
164
 
186
165
  def test_set_name
187
166
  wrapper ['--name=Hello World'] do
188
- _, stderr = capture_io do
189
- assert_equal true, @cli.run
190
- end
167
+ _, stderr = capture_io { @cli.run }
191
168
 
192
169
  refute_match /index is unnamed/i, stderr
193
170
  assert_match 'name="Hello World"', read_index
@@ -196,9 +173,7 @@ class TestCLI::Metadata < MiniTest::Test
196
173
 
197
174
  def test_set_name_invalid
198
175
  wrapper ['--name=Hello/World'] do
199
- _, stderr = capture_io do
200
- assert_equal true, @cli.run
201
- end
176
+ _, stderr = capture_io { @cli.run }
202
177
 
203
178
  refute_match /The name of this index is unset/i, stderr
204
179
  assert_match /invalid name 'Hello\/World'/i, stderr
@@ -34,9 +34,7 @@ class TestCLI::Scan < MiniTest::Test
34
34
  mkfile('Category/Sub/test2.lua', '@version 1.0'),
35
35
  ]
36
36
 
37
- assert_output "2 new categories, 2 new packages, 2 new versions\n" do
38
- assert_equal true, @cli.run
39
- end
37
+ assert_output("2 new categories, 2 new packages, 2 new versions\n") { @cli.run }
40
38
 
41
39
  assert_equal @git.last_commit.id, @cli.index.commit
42
40
  assert_equal @git.last_commit.time, @cli.index.time
@@ -47,7 +45,7 @@ class TestCLI::Scan < MiniTest::Test
47
45
  def test_empty_branch
48
46
  wrapper do
49
47
  assert_output nil, /the current branch does not contains any commit/i do
50
- assert_equal true, @cli.run
48
+ @cli.run
51
49
  end
52
50
  end
53
51
  end
@@ -60,10 +58,7 @@ class TestCLI::Scan < MiniTest::Test
60
58
  Dir.mkdir mkpath('test')
61
59
  Dir.chdir mkpath('test')
62
60
 
63
- assert_output /1 new package/ do
64
- assert_equal true, @cli.run
65
- end
66
-
61
+ assert_output(/1 new package/) { @cli.run }
67
62
  assert_match 'test1.lua', read_index
68
63
  end
69
64
  end
@@ -85,7 +80,7 @@ class TestCLI::Scan < MiniTest::Test
85
80
  File.delete mkpath('cat/test.lua')
86
81
  @git.create_commit 'third commit', [mkpath('cat/test.lua')]
87
82
 
88
- assert_equal true, @cli.run
83
+ @cli.run
89
84
  end
90
85
  end
91
86
 
@@ -108,7 +103,7 @@ processing [a-f0-9]{7}: third commit
108
103
  @git.create_commit 'initial commit', [mkfile('README.md', '# Hello World')]
109
104
 
110
105
  stdout, stderr = capture_io do
111
- assert_equal true, @cli.run
106
+ @cli.run
112
107
  end
113
108
 
114
109
  assert_equal "empty index\n", stdout
@@ -122,7 +117,7 @@ processing [a-f0-9]{7}: third commit
122
117
  [mkfile('cat/test.lua', 'no version tag in this script!')]
123
118
 
124
119
  assert_output nil, /warning: cat\/test\.lua:\n\x20\x20missing tag/i do
125
- assert_equal true, @cli.run
120
+ @cli.run
126
121
  end
127
122
  end
128
123
  end
@@ -133,7 +128,7 @@ processing [a-f0-9]{7}: third commit
133
128
  [mkfile('cat/test.lua', 'no version tag in this script!')]
134
129
 
135
130
  _, stderr = capture_io do
136
- assert_equal true, @cli.run
131
+ @cli.run
137
132
  end
138
133
 
139
134
  refute_match /warning/i, stderr
@@ -145,9 +140,7 @@ processing [a-f0-9]{7}: third commit
145
140
  @git.create_commit 'initial commit',
146
141
  [mkfile('cat/test.lua', 'no version tag in this script!')]
147
142
 
148
- assert_output nil, /warning/i do
149
- assert_equal true, @cli.run
150
- end
143
+ assert_output(nil, /warning/i) { @cli.run }
151
144
  end
152
145
  end
153
146
 
@@ -166,9 +159,7 @@ processing [a-f0-9]{7}: third commit
166
159
  @git.create_commit 'second commit',
167
160
  [mkfile('cat/test2.lua', '@version 1.0')]
168
161
 
169
- assert_output nil, '' do
170
- assert_equal true, @cli.run
171
- end
162
+ assert_output(nil, '') { @cli.run }
172
163
 
173
164
  refute_match 'test1.lua', read_index
174
165
  assert_match 'test2.lua', read_index
@@ -177,7 +168,7 @@ processing [a-f0-9]{7}: third commit
177
168
 
178
169
  def test_amend
179
170
  wrapper ['--amend'] do
180
- assert_equal true, @cli.index.amend
171
+ @cli.index.amend
181
172
  end
182
173
  end
183
174
 
@@ -199,7 +190,7 @@ processing [a-f0-9]{7}: third commit
199
190
  ]
200
191
 
201
192
  assert_output "1 new category, 1 new package, 1 new version\n" do
202
- assert_equal true, @cli.run
193
+ @cli.run
203
194
  end
204
195
 
205
196
  refute_match 'Hello/World.lua', read_index
@@ -216,10 +207,7 @@ processing [a-f0-9]{7}: third commit
216
207
  File.delete mkpath('cat/test.lua')
217
208
  @git.create_commit 'second commit', [mkpath('cat/test.lua')]
218
209
 
219
- assert_output /1 removed package/i do
220
- assert_equal true, @cli.run
221
- end
222
-
210
+ assert_output(/1 removed package/i) { @cli.run }
223
211
  refute_match 'test.lua', read_index
224
212
  end
225
213
  end
@@ -240,7 +228,7 @@ processing [a-f0-9]{7}: third commit
240
228
  ]
241
229
 
242
230
  _, stderr = capture_io do
243
- assert_equal true, @cli.run
231
+ @cli.run
244
232
  end
245
233
 
246
234
  refute_match 'conflict', stderr
@@ -262,7 +250,7 @@ processing [a-f0-9]{7}: third commit
262
250
  ]
263
251
 
264
252
  _, stderr = capture_io do
265
- assert_equal true, @cli.run
253
+ @cli.run
266
254
  end
267
255
 
268
256
  refute_match 'conflict', stderr
@@ -286,7 +274,7 @@ processing [a-f0-9]{7}: third commit
286
274
  }
287
275
 
288
276
  wrapper options, setup: setup do
289
- capture_io { assert_equal true, @cli.run }
277
+ capture_io { @cli.run }
290
278
 
291
279
  refute_match 'test1.lua', read_index, 'The initial commit was scanned'
292
280
  assert_match 'test2.lua', read_index
@@ -311,7 +299,7 @@ processing [a-f0-9]{7}: third commit
311
299
  }
312
300
 
313
301
  wrapper options, setup: setup do
314
- capture_io { assert_equal true, @cli.run }
302
+ capture_io { @cli.run }
315
303
 
316
304
  refute_match 'test1.lua', read_index, 'The initial commit was scanned'
317
305
  assert_match 'test2.lua', read_index
@@ -330,7 +318,7 @@ processing [a-f0-9]{7}: third commit
330
318
  }
331
319
 
332
320
  wrapper options, setup: setup do
333
- capture_io { assert_equal true, @cli.run }
321
+ capture_io { @cli.run }
334
322
 
335
323
  assert_equal false, @cli.index.auto_bump_commit
336
324
  refute_match %Q[commit="#{options[1]}"], read_index
@@ -354,7 +342,7 @@ processing [a-f0-9]{7}: third commit
354
342
  }
355
343
 
356
344
  wrapper options, setup: setup do
357
- capture_io { assert_equal true, @cli.run }
345
+ capture_io { @cli.run }
358
346
 
359
347
  refute_match 'version name="1"', read_index, 'The initial commit was scanned'
360
348
  assert_match 'version name="2"', read_index
@@ -378,7 +366,7 @@ processing [a-f0-9]{7}: third commit
378
366
  }
379
367
 
380
368
  wrapper options, setup: setup do
381
- capture_io { assert_equal true, @cli.run }
369
+ capture_io { @cli.run }
382
370
  assert_match 'test1.lua', read_index
383
371
  end
384
372
  end
@@ -393,7 +381,7 @@ processing [a-f0-9]{7}: third commit
393
381
  }
394
382
 
395
383
  wrapper options, setup: setup do
396
- capture_io { assert_equal true, @cli.run }
384
+ capture_io { @cli.run }
397
385
  end
398
386
  end
399
387
 
@@ -403,12 +391,25 @@ processing [a-f0-9]{7}: third commit
403
391
  @git.create_commit 'initial commit', [mkfile('README.md')]
404
392
 
405
393
  assert_output nil, /--scan: bad file or revision: '#{Regexp.escape hash}'/i do
406
- assert_equal false, @cli.run
394
+ assert_throws(:stop, false) { @cli.run }
407
395
  end
408
396
  end
409
397
  }
410
398
  end
411
399
 
400
+ def test_report_right_invalid_hash
401
+ wrapper ['--scan', 'README.md', '--scan', INVALID_HASHES.first] do
402
+ @git.create_commit 'initial commit', [mkfile('README.md')]
403
+
404
+ _, stderr = capture_io do
405
+ assert_throws(:stop, false) { @cli.run }
406
+ end
407
+
408
+ refute_match 'README.md', stderr
409
+ assert_match INVALID_HASHES.first, stderr
410
+ end
411
+ end
412
+
412
413
  def test_rebuild
413
414
  setup = proc {
414
415
  @git.create_commit 'initial commit',
@@ -428,9 +429,7 @@ processing [a-f0-9]{7}: third commit
428
429
  @git.create_commit 'second commit',
429
430
  [mkfile('cat/test2.lua', '@version 1.0')]
430
431
 
431
- assert_output nil, '' do
432
- assert_equal true, @cli.run
433
- end
432
+ assert_output(nil, '') { @cli.run }
434
433
 
435
434
  contents = read_index
436
435
  assert_match 'test1.lua', contents
@@ -457,9 +456,7 @@ processing [a-f0-9]{7}: third commit
457
456
  @git.create_commit 'second commit',
458
457
  [mkfile('cat/test2.lua', '@version 1.0')]
459
458
 
460
- assert_output nil, '' do
461
- assert_equal true, @cli.run
462
- end
459
+ assert_output(nil, '') { @cli.run }
463
460
 
464
461
  contents = read_index
465
462
  refute_match 'test1.lua', contents
@@ -87,19 +87,6 @@ class TestIndex::Provides < MiniTest::Test
87
87
  assert_equal expected, File.read(index.path)
88
88
  end
89
89
 
90
- def test_invalid_options
91
- index = ReaPack::Index.new @dummy_path
92
- index.url_template = 'http://host/$path'
93
-
94
- error = assert_raises ReaPack::Index::Error do
95
- index.scan 'cat/test.lua', <<-IN
96
- @version 1.0
97
- @provides
98
- [hello] test.png
99
- IN
100
- end
101
- end
102
-
103
90
  def test_custom_url
104
91
  index = ReaPack::Index.new @dummy_path
105
92
  index.files = ['Category/script.lua']
@@ -108,11 +95,14 @@ class TestIndex::Provides < MiniTest::Test
108
95
  @version 1.0
109
96
  @provides
110
97
  script.lua http://google.com/download/$commit/$version/$path
98
+ /root http://google.com/download/$commit/$version/$path
111
99
  IN
112
100
 
113
101
  index.write!
114
- assert_match 'http://google.com/download/master/1.0/Category/script.lua',
115
- File.read(index.path)
102
+
103
+ xml = File.read index.path
104
+ assert_match 'http://google.com/download/master/1.0/Category/script.lua', xml
105
+ assert_match 'file="../root"', xml
116
106
  end
117
107
 
118
108
  def test_empty_tag
data/test/test_cli.rb CHANGED
@@ -5,22 +5,19 @@ class TestCLI < MiniTest::Test
5
5
 
6
6
  def test_help
7
7
  assert_output /--help/, '' do
8
- i = ReaPack::Index::CLI.new ['--help']
9
- assert_equal true, i.run # does nothing
8
+ assert_throws(:stop, true) { ReaPack::Index::CLI.new ['--help'] }
10
9
  end
11
10
  end
12
11
 
13
12
  def test_version
14
13
  assert_output /#{Regexp.escape ReaPack::Index::VERSION.to_s}/, '' do
15
- i = ReaPack::Index::CLI.new ['--version']
16
- assert_equal true, i.run # does nothing
14
+ assert_throws(:stop, true) { ReaPack::Index::CLI.new ['--version'] }
17
15
  end
18
16
  end
19
17
 
20
18
  def test_help_version
21
19
  stdout, _ = capture_io do
22
- i = ReaPack::Index::CLI.new ['--help', '--version']
23
- assert_equal true, i.run # does nothing
20
+ assert_throws(:stop, true) { ReaPack::Index::CLI.new ['--help', '--version'] }
24
21
  end
25
22
 
26
23
  refute_match ReaPack::Index::VERSION.to_s, stdout
@@ -28,22 +25,19 @@ class TestCLI < MiniTest::Test
28
25
 
29
26
  def test_invalid_option
30
27
  assert_output '', /reapack-index: invalid option: --hello-world/i do
31
- i = ReaPack::Index::CLI.new ['--hello-world']
32
- assert_equal false, i.run
28
+ assert_throws(:stop, false) { ReaPack::Index::CLI.new ['--hello-world'] }
33
29
  end
34
30
  end
35
31
 
36
32
  def test_ambiguous_option
37
33
  assert_output '', /reapack-index: ambiguous option: --c/i do
38
- i = ReaPack::Index::CLI.new ['--c']
39
- assert_equal false, i.run
34
+ assert_throws(:stop, false) { ReaPack::Index::CLI.new ['--c'] }
40
35
  end
41
36
  end
42
37
 
43
38
  def test_missing_argument
44
39
  assert_output nil, /missing argument/ do
45
- i = ReaPack::Index::CLI.new ['--output']
46
- assert_equal false, i.run # does nothing
40
+ assert_throws(:stop, false) { ReaPack::Index::CLI.new ['--output'] }
47
41
  end
48
42
  end
49
43
 
@@ -96,10 +90,12 @@ class TestCLI < MiniTest::Test
96
90
  end
97
91
 
98
92
  def test_config
99
- assert_output /--help/, '' do
100
- wrapper [], setup: proc {
101
- mkfile '.reapack-index.conf', '--help'
102
- }
93
+ catch :stop do
94
+ assert_output /--help/, '' do
95
+ wrapper [], setup: proc {
96
+ mkfile '.reapack-index.conf', '--help'
97
+ }
98
+ end
103
99
  end
104
100
  end
105
101
 
@@ -124,7 +120,7 @@ class TestCLI < MiniTest::Test
124
120
  mkfile('cat/test.lua', 'no version tag in this script!')
125
121
  ]
126
122
 
127
- assert_equal true, @cli.run
123
+ @cli.run
128
124
  end
129
125
  end
130
126
 
@@ -140,7 +136,7 @@ class TestCLI < MiniTest::Test
140
136
  Dir.chdir File.join(@git.path, 'Category')
141
137
 
142
138
  assert_output /--help/ do
143
- ReaPack::Index::CLI.new
139
+ catch :stop do ReaPack::Index::CLI.new end
144
140
  end
145
141
  end
146
142
  end
@@ -168,21 +164,18 @@ class TestCLI < MiniTest::Test
168
164
  end
169
165
 
170
166
  assert_output '', no_such_file do
171
- i = ReaPack::Index::CLI.new ['/hello/world']
172
- assert_equal false, i.run
167
+ assert_throws(:stop, false) { ReaPack::Index::CLI.new ['/hello/world'] }
173
168
  end
174
169
 
175
170
  assert_output '', /could not find repository/i do
176
- i = ReaPack::Index::CLI.new ['/']
177
- assert_equal false, i.run
171
+ assert_throws(:stop, false) { ReaPack::Index::CLI.new ['/'] }
178
172
  end
179
173
  end
180
174
 
181
175
  def test_invalid_index
182
176
  assert_output '', /\A'.+index\.xml' is not a ReaPack index file\Z/ do
183
177
  setup = proc { mkfile 'index.xml', "\0" }
184
- wrapper [], setup: setup do
185
- end
178
+ assert_throws(:stop, false) { wrapper [], setup: setup do end }
186
179
  end
187
180
  end
188
181
 
@@ -192,7 +185,7 @@ class TestCLI < MiniTest::Test
192
185
  [mkfile('README.md', '# Hello World')]
193
186
 
194
187
  stdout, stderr = capture_io do
195
- assert_equal true, @cli.run
188
+ @cli.run
196
189
  end
197
190
 
198
191
  assert_equal "empty index\n", stdout
@@ -225,9 +218,7 @@ class TestCLI < MiniTest::Test
225
218
  [mkfile('cat/test.lua', 'no version tag in this script!')]
226
219
 
227
220
  # must output a new line before 'warning:'
228
- assert_output nil, /\nwarning:/i do
229
- assert_equal true, @cli.run
230
- end
221
+ assert_output(nil, /\nwarning:/i) { @cli.run }
231
222
  end
232
223
  end
233
224
 
@@ -236,9 +227,7 @@ class TestCLI < MiniTest::Test
236
227
  @git.create_commit 'initial commit',
237
228
  [mkfile('cat/test.lua', 'no version tag in this script!')]
238
229
 
239
- assert_output '', '' do
240
- assert_equal true, @cli.run
241
- end
230
+ assert_output('', '') { @cli.run }
242
231
  end
243
232
  end
244
233
 
data/test/test_git.rb CHANGED
@@ -164,9 +164,10 @@ class TestGit < MiniTest::Test
164
164
  end
165
165
 
166
166
  def test_inspect_commit
167
- c = @git.create_commit 'message', []
167
+ c = @git.create_commit "summary\n\nlong message", []
168
168
  assert_match c.class.name, c.inspect
169
169
  assert_match c.id, c.inspect
170
- assert_match c.message, c.inspect
170
+ assert_match c.summary, c.inspect
171
+ refute_match c.message, c.inspect
171
172
  end
172
173
  end
data/test/test_index.rb CHANGED
@@ -253,7 +253,7 @@ class TestIndex < MiniTest::Test
253
253
  assert_match /bee.+zebra/m, File.read(index.path)
254
254
  end
255
255
 
256
- def test_dont_sort_versions
256
+ def test_do_not_sort_versions
257
257
  original = <<-XML
258
258
  <?xml version="1.0" encoding="utf-8"?>
259
259
  <index version="1">
@@ -273,6 +273,31 @@ class TestIndex < MiniTest::Test
273
273
  assert_equal original, File.read(index.path)
274
274
  end
275
275
 
276
+ def test_sort_package_tags
277
+ original = <<-XML
278
+ <?xml version="1.0" encoding="utf-8"?>
279
+ <index version="1">
280
+ <category name="Other">
281
+ <reapack name="test.lua">
282
+ <version name="z"/>
283
+ <metadata>
284
+ <link/>
285
+ <description/>
286
+ </metadata>
287
+ </reapack>
288
+ </category>
289
+ </index>
290
+ XML
291
+
292
+ File.write @dummy_path, original
293
+ index = ReaPack::Index.new @dummy_path
294
+ index.write!
295
+
296
+ contents = File.read index.path
297
+ assert_match /metadata.+version/m, contents
298
+ assert_match /description.+link/m, contents
299
+ end
300
+
276
301
  def test_dont_mess_with_link_ordering
277
302
  # https://bugs.ruby-lang.org/issues/11907
278
303
  original = <<-XML
@@ -482,6 +482,23 @@ class TestMetadata < MiniTest::Test
482
482
  assert_equal false, md.modified?
483
483
  end
484
484
 
485
+ def test_about_markdown_blank_before_header
486
+ before = make_node '<index/>'
487
+ md = ReaPack::Index::Metadata.new before
488
+ md.about = "First Line\n# Header\n* List"
489
+
490
+ refute_match 'Firstn Line # Header * List', before.to_s
491
+ assert_match "\\bullet", before.to_s
492
+ end
493
+
494
+ def test_about_markdown_no_4_space_rule
495
+ before = make_node '<index/>'
496
+ md = ReaPack::Index::Metadata.new before
497
+ md.about = "- a\n- b\n - c\n- d"
498
+
499
+ assert_match "\\endash", before.to_s # nested list (c)
500
+ end
501
+
485
502
  def test_pandoc_not_found
486
503
  old_path = ENV['PATH']
487
504
  ENV['PATH'] = String.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reapack-index
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1beta3
4
+ version: 1.1beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - cfillion
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.3beta2
131
+ version: 1.3beta4
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.3beta2
138
+ version: 1.3beta4
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: nokogiri
141
141
  requirement: !ruby/object:Gem::Requirement