pdd 0.2.1 → 0.2.2

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/bin/pdd CHANGED
@@ -35,6 +35,8 @@ opts = Slop.parse do
35
35
  on 'f', 'file', 'File to save XML into', argument: :required
36
36
  end
37
37
 
38
+ fail '-f is mandatory when using -v' if opts.verbose? && !opts.file?
39
+
38
40
  if opts.help?
39
41
  puts opts
40
42
  else
data/lib/pdd.rb CHANGED
@@ -40,7 +40,13 @@ module PDD
40
40
 
41
41
  # Get logger.
42
42
  def self.log
43
- @log ||= Logger.new(STDOUT)
43
+ unless @log
44
+ @log = Logger.new(STDOUT)
45
+ @log.formatter = proc { |severity, _, _, msg|
46
+ puts "#{severity}: #{msg.dump}"
47
+ }
48
+ end
49
+ @log
44
50
  end
45
51
 
46
52
  class << self
@@ -36,8 +36,9 @@ module PDD
36
36
 
37
37
  # Fetch all sources.
38
38
  def fetch
39
+ types = [/^text\//, /application\/xml/]
39
40
  Dir.glob(@dir + '/**/*')
40
- .select { |f| @magic.file(f) =~ /^text\// }
41
+ .select { |f| types.index { |re| @magic.file(f) =~ re } }
41
42
  .map do |file|
42
43
  Source.new(file, file[@dir.length + 1, file.length])
43
44
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.rubygems_version = '2.2.2'
30
30
  s.required_ruby_version = '>= 1.9.3'
31
31
  s.name = 'pdd'
32
- s.version = '0.2.1'
32
+ s.version = '0.2.2'
33
33
  s.license = 'MIT'
34
34
  s.summary = 'Puzzle Driven Development collector'
35
35
  s.description = 'Collects puzzles from source code base'
@@ -23,5 +23,3 @@
23
23
 
24
24
  require 'simplecov'
25
25
  require 'pdd'
26
-
27
- PDD.log = Logger.new(STDOUT)
@@ -48,4 +48,23 @@ class TestSources < Minitest::Test
48
48
  assert_equal 1, list.size
49
49
  end
50
50
  end
51
+
52
+ def test_detects_all_text_files
53
+ Dir.mktmpdir 'test' do |dir|
54
+ exts = %w[(xsl java rb cpp apt)]
55
+ exts.each do |ext|
56
+ File.write(File.join(dir, "test.#{ext}"), 'text')
57
+ end
58
+ list = PDD::Sources.new(dir).fetch
59
+ assert_equal exts.size, list.size
60
+ end
61
+ end
62
+
63
+ def test_detects_xml_file
64
+ Dir.mktmpdir 'test' do |dir|
65
+ File.write(File.join(dir, 'a.xml'), '<?xml version="1.0"?><hello/>')
66
+ list = PDD::Sources.new(dir).fetch
67
+ assert_equal 1, list.size
68
+ end
69
+ end
51
70
  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.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: