pdd 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.rultor.yml +10 -3
- data/features/cli.feature +1 -1
- data/lib/pdd.rb +19 -2
- data/lib/pdd/sources.rb +5 -4
- data/lib/pdd/version.rb +1 -1
- data/pdd.xml +3 -0
- data/test/test_pdd.rb +16 -3
- metadata +3 -2
data/.rultor.yml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
assets:
|
2
2
|
rubygems.yml: "yegor256/home#assets/rubygems.yml"
|
3
|
+
s3cfg: "yegor256/home#assets/s3cfg"
|
4
|
+
|
5
|
+
install:
|
6
|
+
- "sudo apt-get update"
|
7
|
+
- "sudo apt-get install -y --fix-missing libmagic1 libmagic-dev"
|
3
8
|
|
4
9
|
release:
|
5
10
|
script:
|
6
|
-
- "sudo apt-get update"
|
7
|
-
- "sudo apt-get install -y --fix-missing libmagic1 libmagic-dev"
|
8
11
|
- "sudo bundle install"
|
9
12
|
- "rake"
|
10
13
|
- "rm -rf *.gem"
|
@@ -12,4 +15,8 @@ release:
|
|
12
15
|
- "gem build pdd.gemspec"
|
13
16
|
- "chmod 0600 ../rubygems.yml"
|
14
17
|
- "gem push *.gem --config-file ../rubygems.yml"
|
15
|
-
|
18
|
+
- "gem install pdd"
|
19
|
+
- "pdd --source=$(pwd) --verbose --file=pdd.xml -e=test/** -e=features/** -e=README.md"
|
20
|
+
- "s3cmd --no-progress put pdd.xml --config=../s3cfg s3://pdd.teamed.io/pdd.xml"
|
21
|
+
- "s3cmd --no-progress put assets/puzzles.xsd --acl-public --config=../s3cfg s3://pdd.teamed.io/xsd/${tag}.xsd"
|
22
|
+
- "s3cmd --no-progress put assets/puzzles.xsl --acl-public --config=../s3cfg s3://pdd.teamed.io/xsl/${tag}.xsl"
|
data/features/cli.feature
CHANGED
@@ -46,7 +46,7 @@ Feature: Command Line Processing
|
|
46
46
|
"""
|
47
47
|
~~ @todo #44 some puzzle to be excluded as well
|
48
48
|
"""
|
49
|
-
When I run bin/pdd with "-e
|
49
|
+
When I run bin/pdd with "-e f/g/**/*.md --exclude a/**/*.txt > out.xml"
|
50
50
|
Then Exit code is zero
|
51
51
|
And XML file "out.xml" matches "/puzzles[count(puzzle)=0]"
|
52
52
|
|
data/lib/pdd.rb
CHANGED
@@ -76,8 +76,8 @@ module PDD
|
|
76
76
|
end unless @opts[:exclude].nil?
|
77
77
|
sanitize(
|
78
78
|
Nokogiri::XML::Builder.new do |xml|
|
79
|
-
xml <<
|
80
|
-
xml.puzzles(
|
79
|
+
xml << "<?xml-stylesheet type='text/xsl' href='#{xsl}'?>"
|
80
|
+
xml.puzzles(attrs) do
|
81
81
|
sources.fetch.each do |source|
|
82
82
|
source.puzzles.each do |puzzle|
|
83
83
|
PDD.log.info "puzzle #{puzzle.props[:ticket]}:" \
|
@@ -93,6 +93,23 @@ module PDD
|
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
|
+
def attrs
|
97
|
+
{
|
98
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
99
|
+
'xsi:noNamespaceSchemaLocation' => "#{host}/xsd/#{PDD::VERSION}.xsd",
|
100
|
+
'version' => PDD::VERSION,
|
101
|
+
'date' => Time.now.utc.iso8601
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def host
|
106
|
+
'http://pdd.teamed.io'
|
107
|
+
end
|
108
|
+
|
109
|
+
def xsl
|
110
|
+
"#{host}/xsl/#{PDD::VERSION}.xsl"
|
111
|
+
end
|
112
|
+
|
96
113
|
def render(puzzle, xml)
|
97
114
|
props = puzzle.props
|
98
115
|
xml.puzzle do
|
data/lib/pdd/sources.rb
CHANGED
@@ -38,15 +38,16 @@ module PDD
|
|
38
38
|
|
39
39
|
# Fetch all sources.
|
40
40
|
def fetch
|
41
|
-
files = Rake::FileList.new(@dir
|
41
|
+
files = Rake::FileList.new(File.join(@dir, '**/*')) do |list|
|
42
42
|
@exclude.each do |ptn|
|
43
|
-
Rake::FileList.new(@dir
|
43
|
+
Rake::FileList.new(File.join(@dir, ptn)).each do |f|
|
44
44
|
list.exclude(f)
|
45
45
|
end
|
46
46
|
end
|
47
|
-
end
|
47
|
+
end.to_a
|
48
|
+
PDD.log.info "#{files.size} file(s) found"
|
48
49
|
types = [/^text\//, /application\/xml/]
|
49
|
-
files
|
50
|
+
files
|
50
51
|
.select { |f| types.index { |re| @magic.file(f) =~ re } }
|
51
52
|
.map do |file|
|
52
53
|
Source.new(file, file[@dir.length + 1, file.length])
|
data/lib/pdd/version.rb
CHANGED
data/pdd.xml
ADDED
data/test/test_pdd.rb
CHANGED
@@ -40,9 +40,22 @@ class TestPDD < Minitest::Test
|
|
40
40
|
on 'e', 'exclude', as: Array, argument: :required
|
41
41
|
end
|
42
42
|
File.write(File.join(dir, 'a.txt'), '@todo #55 hello!')
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
matches(
|
44
|
+
Nokogiri::XML::Document.parse(PDD::Base.new(opts).xml),
|
45
|
+
[
|
46
|
+
'/processing-instruction("xml-stylesheet")[contains(.,".xsl")]',
|
47
|
+
'/puzzles/@version',
|
48
|
+
'/puzzles/@date',
|
49
|
+
'/puzzles[count(puzzle)=1]',
|
50
|
+
'/puzzles/puzzle[file="a.txt"]'
|
51
|
+
]
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def matches(xml, xpaths)
|
57
|
+
xpaths.each do |xpath|
|
58
|
+
fail "doesn't match '#{xpath}': #{xml}" unless xml.xpath(xpath).size == 1
|
46
59
|
end
|
47
60
|
end
|
48
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-08-
|
12
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/pdd/sources.rb
|
266
266
|
- lib/pdd/version.rb
|
267
267
|
- pdd.gemspec
|
268
|
+
- pdd.xml
|
268
269
|
- test/test_helper.rb
|
269
270
|
- test/test_pdd.rb
|
270
271
|
- test/test_source.rb
|