pdd 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pdd +2 -0
- data/lib/pdd.rb +7 -1
- data/lib/pdd/sources.rb +2 -1
- data/pdd.gemspec +1 -1
- data/test/test_helper.rb +0 -2
- data/test/test_sources.rb +19 -0
- metadata +1 -1
data/bin/pdd
CHANGED
data/lib/pdd.rb
CHANGED
@@ -40,7 +40,13 @@ module PDD
|
|
40
40
|
|
41
41
|
# Get logger.
|
42
42
|
def self.log
|
43
|
-
@log
|
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
|
data/lib/pdd/sources.rb
CHANGED
@@ -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) =~
|
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
|
data/pdd.gemspec
CHANGED
@@ -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.
|
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'
|
data/test/test_helper.rb
CHANGED
data/test/test_sources.rb
CHANGED
@@ -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
|