pdd 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ release:
8
8
  - "sudo bundle install"
9
9
  - "rake"
10
10
  - "rm -rf *.gem"
11
- - "sed -i \"s/1\\.0\\.snapshot/${tag}/g\" pdd.gemspec"
11
+ - "sed -i \"s/1\\.0\\.snapshot/${tag}/g\" lib/pdd/version.rb"
12
12
  - "gem build pdd.gemspec"
13
13
  - "chmod 0600 ../rubygems.yml"
14
14
  - "gem push *.gem --config-file ../rubygems.yml"
@@ -73,6 +73,8 @@
73
73
  <xs:sequence>
74
74
  <xs:element name="puzzle" type="puzzle" minOccurs="0" maxOccurs="unbounded" />
75
75
  </xs:sequence>
76
+ <xs:attribute name="version" use="required" type="xs:string"/>
77
+ <xs:attribute name="date" use="required" type="xs:dateTime"/>
76
78
  </xs:complexType>
77
79
  <xs:unique name="puzzleBody">
78
80
  <xs:selector xpath="./puzzle" />
data/bin/pdd CHANGED
@@ -26,10 +26,10 @@ STDOUT.sync = true
26
26
 
27
27
  require 'pdd'
28
28
  require 'slop'
29
+ require 'pdd/version'
29
30
 
30
- opts = Slop.parse do
31
- banner 'Usage: pdd [options]'
32
- on 'h', 'help', 'Print this page'
31
+ opts = Slop.parse(ARGV, strict: true, help: true) do
32
+ banner "Usage (#{PDD::VERSION}): pdd [options]"
33
33
  on 'v', 'verbose', 'Enable verbose mode'
34
34
  on 's', 'source', 'Source directory to parse', argument: :required
35
35
  on 'f', 'file', 'File to save XML into', argument: :required
@@ -5,7 +5,7 @@ Feature: Command Line Processing
5
5
  Scenario: Help can be printed
6
6
  When I run bin/pdd with "-h"
7
7
  Then Exit code is zero
8
- And Stdout contains "Usage: pdd"
8
+ And Stdout contains "-v, --verbose"
9
9
 
10
10
  Scenario: Simple puzzles collecting
11
11
  Given I have a "Sample.java" file with content:
@@ -36,3 +36,23 @@ Feature: Command Line Processing
36
36
  When I run bin/pdd with "> out.xml"
37
37
  Then Exit code is zero
38
38
  And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"
39
+
40
+ Scenario: Excluding unnecessary files
41
+ Given I have a "a/b/c/test.txt" file with content:
42
+ """
43
+ ~~ @todo #44 some puzzle to be excluded
44
+ """
45
+ And I have a "f/g/h/hello.md" file with content:
46
+ """
47
+ ~~ @todo #44 some puzzle to be excluded as well
48
+ """
49
+ When I run bin/pdd with "-e **/*.md --exclude **/*.txt > out.xml"
50
+ Then Exit code is zero
51
+ And XML file "out.xml" matches "/puzzles[count(puzzle)=0]"
52
+
53
+ Scenario: Rejects unknown options
54
+ Given I have a "test.txt" file with content:
55
+ """
56
+ """
57
+ When I run bin/pdd with "--some-unknown-option"
58
+ Then Exit code is not zero
@@ -91,3 +91,7 @@ end
91
91
  Then(/^Exit code is zero$/) do
92
92
  fail "Non-zero exit code #{@exitstatus}" unless @exitstatus == 0
93
93
  end
94
+
95
+ Then(/^Exit code is not zero$/) do
96
+ fail 'Zero exit code' if @exitstatus == 0
97
+ end
data/lib/pdd.rb CHANGED
@@ -22,8 +22,10 @@
22
22
  # SOFTWARE.
23
23
 
24
24
  require 'pdd/sources'
25
+ require 'pdd/version'
25
26
  require 'nokogiri'
26
27
  require 'logger'
28
+ require 'time'
27
29
 
28
30
  # PDD main module.
29
31
  # Author:: Yegor Bugayenko (yegor@teamed.io)
@@ -60,6 +62,7 @@ module PDD
60
62
  def initialize(opts)
61
63
  @opts = opts
62
64
  PDD.log = Logger.new(File::NULL) unless @opts.verbose?
65
+ PDD.log.info "my version is #{PDD::VERSION}"
63
66
  end
64
67
 
65
68
  # Generate XML.
@@ -74,7 +77,7 @@ module PDD
74
77
  sanitize(
75
78
  Nokogiri::XML::Builder.new do |xml|
76
79
  xml << '<?xml-stylesheet type="text/xsl" href="puzzles.xsl"?>'
77
- xml.puzzles do
80
+ xml.puzzles(version: PDD::VERSION, date: Time.now.utc.iso8601) do
78
81
  sources.fetch.each do |source|
79
82
  source.puzzles.each do |puzzle|
80
83
  PDD.log.info "puzzle #{puzzle.props[:ticket]}:" \
@@ -105,6 +108,7 @@ module PDD
105
108
  )
106
109
  errors = xsd.validate(Nokogiri::XML(xml)).map { |error| error.message }
107
110
  errors.each { |e| PDD.log.error e }
111
+ PDD.log.error(xml) unless errors.empty?
108
112
  fail SchemaError, errors.join('; ') unless errors.empty?
109
113
  xml
110
114
  end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright (c) 2014 TechnoPark Corp.
4
+ # Copyright (c) 2014 Yegor Bugayenko
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the 'Software'), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ # SOFTWARE.
23
+
24
+ # PDD main module.
25
+ # Author:: Yegor Bugayenko (yegor@teamed.io)
26
+ # Copyright:: Copyright (c) 2014 Yegor Bugayenko
27
+ # License:: MIT
28
+ module PDD
29
+ VERSION = '0.4'
30
+ end
@@ -21,6 +21,10 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  # SOFTWARE.
23
23
 
24
+ lib = File.expand_path('../lib', __FILE__)
25
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
26
+ require 'pdd/version'
27
+
24
28
  Gem::Specification.new do |s|
25
29
  s.specification_version = 2 if s.respond_to? :specification_version=
26
30
  if s.respond_to? :required_rubygems_version=
@@ -29,7 +33,7 @@ Gem::Specification.new do |s|
29
33
  s.rubygems_version = '2.2.2'
30
34
  s.required_ruby_version = '>= 1.9.3'
31
35
  s.name = 'pdd'
32
- s.version = '0.3'
36
+ s.version = PDD::VERSION
33
37
  s.license = 'MIT'
34
38
  s.summary = 'Puzzle Driven Development collector'
35
39
  s.description = 'Collects puzzles from source code base'
@@ -41,6 +41,7 @@ class TestPDD < Minitest::Test
41
41
  end
42
42
  File.write(File.join(dir, 'a.txt'), '@todo #55 hello!')
43
43
  xml = Nokogiri::XML::Document.parse(PDD::Base.new(opts).xml)
44
+ assert_equal 1, xml.xpath('/puzzles/@version').size
44
45
  assert_equal 1, xml.xpath('/puzzles/puzzle[file="a.txt"]').size
45
46
  end
46
47
  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.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -260,6 +260,7 @@ files:
260
260
  - lib/pdd/puzzle.rb
261
261
  - lib/pdd/source.rb
262
262
  - lib/pdd/sources.rb
263
+ - lib/pdd/version.rb
263
264
  - pdd.gemspec
264
265
  - test/test_helper.rb
265
266
  - test/test_pdd.rb