pdd 0.4.1 → 0.5

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.
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 **/*.md --exclude **/*.txt > out.xml"
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 << '<?xml-stylesheet type="text/xsl" href="puzzles.xsl"?>'
80
- xml.puzzles(version: PDD::VERSION, date: Time.now.utc.iso8601) do
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 + '/**/*') do |list|
41
+ files = Rake::FileList.new(File.join(@dir, '**/*')) do |list|
42
42
  @exclude.each do |ptn|
43
- Rake::FileList.new(@dir + '/' + ptn).each do |f|
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.to_a
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
@@ -26,5 +26,5 @@
26
26
  # Copyright:: Copyright (c) 2014 Yegor Bugayenko
27
27
  # License:: MIT
28
28
  module PDD
29
- VERSION = '0.4.1'
29
+ VERSION = '0.5'
30
30
  end
data/pdd.xml ADDED
@@ -0,0 +1,3 @@
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet type="text/xsl" href="puzzles.xsl"?>
3
+ <puzzles version="1.0.snapshot" date="2014-08-13T12:52:38Z"/>
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
- xml = Nokogiri::XML::Document.parse(PDD::Base.new(opts).xml)
44
- assert_equal 1, xml.xpath('/puzzles/@version').size
45
- assert_equal 1, xml.xpath('/puzzles/puzzle[file="a.txt"]').size
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.1
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 00:00:00.000000000 Z
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