pdd 0.14 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rultor.yml CHANGED
@@ -1,14 +1,12 @@
1
1
  assets:
2
- rubygems.yml: "yegor256/home#assets/rubygems.yml"
3
- s3cfg: "yegor256/home#assets/s3cfg"
4
-
2
+ rubygems.yml: yegor256/home#assets/rubygems.yml
3
+ s3cfg: yegor256/home#assets/s3cfg
5
4
  install: |
6
5
  sudo apt-get update
7
6
  sudo apt-get install -y --fix-missing libmagic1 libmagic-dev
8
7
  sudo gem install pdd
9
-
10
8
  release:
11
- script: |
9
+ script: |-
12
10
  sudo bundle install
13
11
  rake
14
12
  rm -rf *.gem
@@ -22,3 +20,14 @@ release:
22
20
  s3cmd --no-progress put pdd.xml --config=../s3cfg s3://pdd.teamed.io/pdd.xml
23
21
  s3cmd --no-progress put assets/puzzles.xsd --acl-public --config=../s3cfg s3://pdd-xsd.teamed.io/${tag}.xsd
24
22
  s3cmd --no-progress put assets/puzzles.xsl --acl-public --config=../s3cfg s3://pdd-xsl.teamed.io/${tag}.xsl
23
+ commanders:
24
+ - yegor256
25
+ architect:
26
+ - yegor256
27
+ - davvd
28
+ merge:
29
+ commanders:
30
+ - yegor256
31
+ deploy:
32
+ commanders:
33
+ - yegor256
data/assets/puzzles.xsd CHANGED
@@ -24,6 +24,13 @@
24
24
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
25
25
  <xs:complexType name="puzzle">
26
26
  <xs:all>
27
+ <xs:element name="id" minOccurs="1">
28
+ <xs:simpleType>
29
+ <xs:restriction base="xs:string">
30
+ <xs:pattern value="[a-zA-Z0-9\-]+"/>
31
+ </xs:restriction>
32
+ </xs:simpleType>
33
+ </xs:element>
27
34
  <xs:element name="ticket">
28
35
  <xs:simpleType>
29
36
  <xs:restriction base="xs:string">
data/assets/puzzles.xsl CHANGED
@@ -62,11 +62,13 @@
62
62
  <col/>
63
63
  <col/>
64
64
  <col/>
65
+ <col/>
65
66
  <col style="width:7em;"/>
66
67
  <col/>
67
68
  </colgroup>
68
69
  <thead>
69
70
  <tr>
71
+ <th><xsl:text>id</xsl:text></th>
70
72
  <th><xsl:text>ticket</xsl:text></th>
71
73
  <th><xsl:text>body</xsl:text></th>
72
74
  <th><xsl:text>estimate</xsl:text></th>
@@ -83,6 +85,7 @@
83
85
  </xsl:template>
84
86
  <xsl:template match="puzzle">
85
87
  <tr>
88
+ <td><xsl:value-of select="id"/></td>
86
89
  <td><xsl:value-of select="ticket"/></td>
87
90
  <td>
88
91
  <code>
@@ -46,7 +46,7 @@ end
46
46
  Given(/^I have a "([^"]*)" file with content:$/) do |file, text|
47
47
  FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file)
48
48
  File.open(file, 'w') do |f|
49
- f.write(text)
49
+ f.write(text.gsub(/\\xFF/, "\xFF"))
50
50
  end
51
51
  end
52
52
 
@@ -12,3 +12,14 @@ Feature: Unicode
12
12
  LANG=C ruby -Ipdd/lib pdd/bin/pdd test.txt -v -f=/dev/null -e=pdd/**/*
13
13
  """
14
14
  Then Exit code is zero
15
+
16
+ Scenario: Skip file with broken Unicode
17
+ Given I have a "test.txt" file with content:
18
+ """
19
+ \xFF test
20
+ # @todo #44 \xFF hey
21
+ \xFF test again
22
+ """
23
+ When I run bin/pdd with "--exclude=test.txt --v -f=/dev/null"
24
+ Then Stdout contains "excluding test.txt"
25
+ Then Exit code is zero
data/lib/pdd.rb CHANGED
@@ -76,6 +76,7 @@ module PDD
76
76
  @opts = opts
77
77
  PDD.log.level = Logger::INFO if @opts.verbose?
78
78
  PDD.log.info "my version is #{PDD::VERSION}"
79
+ PDD.log.info "Ruby version is #{RUBY_VERSION} at #{RUBY_PLATFORM}"
79
80
  end
80
81
 
81
82
  # Generate XML.
data/lib/pdd/source.rb CHANGED
@@ -21,6 +21,7 @@
21
21
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  # SOFTWARE.
23
23
 
24
+ require 'digest/md5'
24
25
  require 'pdd/puzzle'
25
26
 
26
27
  module PDD
@@ -36,19 +37,40 @@ module PDD
36
37
 
37
38
  # Fetch all puzzles.
38
39
  def puzzles
40
+ PDD.log.info "reading #{@path}..."
39
41
  re = /(.*(?:^|\s))@todo\s+#([\w\-\.:\/]+)\s+(.+)/
40
42
  puzzles = []
41
43
  lines = File.readlines(@file)
42
44
  lines.each_with_index do |line, idx|
43
45
  re.match(line) do |match|
44
- puzzles << puzzle(lines.drop(idx + 1), match, idx)
46
+ begin
47
+ puzzles << puzzle(lines.drop(idx + 1), match, idx)
48
+ rescue Error => ex
49
+ raise Error, "#{ex.message} in line ##{idx}"
50
+ end
45
51
  end
52
+ /(.*(?:^|\s))@todo\s+#([\w\-\.:\/]+)/
46
53
  end
47
54
  puzzles
48
55
  end
49
56
 
50
57
  private
51
58
 
59
+ # Fetch puzzle
60
+ def puzzle(lines, match, idx)
61
+ tail = tail(lines, match[1])
62
+ body = (match[3] + ' ' + tail.join(' ')).gsub(/[\s\n\t]+/, ' ').strip
63
+ marker = marker(match[2])
64
+ Puzzle.new(
65
+ marker.merge(
66
+ id: "#{marker[:ticket]}-#{Digest::MD5.hexdigest(body)[0..7]}",
67
+ lines: "#{idx + 1}-#{idx + tail.size + 1}",
68
+ body: body,
69
+ file: @path
70
+ ).merge(git(idx + 1))
71
+ )
72
+ end
73
+
52
74
  # Parse a marker.
53
75
  def marker(text)
54
76
  re = /([\w\d\-\.]+)(?::(\d+)(?:(m|h)[a-z]*)?)?(?:\/([A-Z]+))?/
@@ -68,23 +90,6 @@ module PDD
68
90
  min
69
91
  end
70
92
 
71
- # Fetch puzzle
72
- def puzzle(lines, match, idx)
73
- begin
74
- tail = tail(lines, match[1])
75
- rescue Error => ex
76
- raise Error, "#{ex.message} in line ##{idx}"
77
- end
78
- body = (match[3] + ' ' + tail.join(' ')).gsub(/[\s\n\t]+/, ' ').strip
79
- Puzzle.new(
80
- marker(match[2]).merge(
81
- lines: "#{idx + 1}-#{idx + tail.size + 1}",
82
- body: body,
83
- file: @path
84
- ).merge(git(idx + 1))
85
- )
86
- end
87
-
88
93
  # Fetch puzzle tail (all lines after the first one)
89
94
  def tail(lines, prefix)
90
95
  lines
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.14'
29
+ VERSION = '0.14.1'
30
30
  end
data/test/test_pdd.rb CHANGED
@@ -76,6 +76,7 @@ class TestPDD < Minitest::Test
76
76
  Nokogiri::XML(PDD::Base.new(opts).xml),
77
77
  [
78
78
  '/puzzles[count(puzzle)=1]',
79
+ '/puzzles/puzzle[id]',
79
80
  '/puzzles/puzzle[file="x.txt"]',
80
81
  '/puzzles/puzzle[author="Mr. Tester"]',
81
82
  '/puzzles/puzzle[email="test@teamed.io"]',
data/test/test_source.rb CHANGED
@@ -35,14 +35,14 @@ class TestSources < Minitest::Test
35
35
  file = File.join(dir, 'a.txt')
36
36
  File.write(
37
37
  file,
38
- '
38
+ "
39
39
  * @todo #44 hello,
40
- * how are you doing?
40
+ * how are you\t\r\tdoing?
41
41
  * -something else
42
42
  Something else
43
43
  ~~ @todo #ABC-3 this is another puzzle
44
44
  ~~ and it also has to work
45
- '
45
+ "
46
46
  )
47
47
  list = PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
48
48
  assert_equal 2, list.size
@@ -70,6 +70,23 @@ class TestSources < Minitest::Test
70
70
  end
71
71
  end
72
72
 
73
+ def test_failing_on_invalid_puzzle_without_hash_sign
74
+ skip('doesnt work now')
75
+ Dir.mktmpdir 'test' do |dir|
76
+ file = File.join(dir, 'a.txt')
77
+ File.write(
78
+ file,
79
+ '
80
+ * @todo 44 this puzzle is not formatted correctly
81
+ '
82
+ )
83
+ error = assert_raises PDD::Error do
84
+ PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
85
+ end
86
+ assert !error.message.index('Incorrect format').nil?
87
+ end
88
+ end
89
+
73
90
  def test_reads_git_author
74
91
  Dir.mktmpdir 'test' do |dir|
75
92
  fail unless system("
@@ -86,6 +103,7 @@ class TestSources < Minitest::Test
86
103
  list = PDD::Source.new(File.join(dir, 'a.txt'), '').puzzles
87
104
  assert_equal 1, list.size
88
105
  puzzle = list.first
106
+ assert_equal '1-de87adc8', puzzle.props[:id]
89
107
  assert_equal '1-1', puzzle.props[:lines]
90
108
  assert_equal 'this is the puzzle', puzzle.props[:body]
91
109
  assert_equal 'test', puzzle.props[:author]
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.14'
4
+ version: 0.14.1
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: 2015-01-13 00:00:00.000000000 Z
12
+ date: 2015-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri