lib/pdd/sources.rb in pdd-0.16.1 vs lib/pdd/sources.rb in pdd-0.16.2
- old
+ new
@@ -19,11 +19,11 @@
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-require 'filemagic'
+require 'ptools'
require 'pdd/source'
require 'rake/file_list'
module PDD
# Code base abstraction
@@ -31,11 +31,10 @@
# Ctor.
# +dir+:: Directory with source code files
def initialize(dir, ptns = [])
@dir = dir
@exclude = ptns
- @magic = FileMagic.new(FileMagic::MAGIC_MIME)
end
# Fetch all sources.
def fetch
files = Rake::FileList.new(File.join(@dir, '**/*')) do |list|
@@ -44,18 +43,15 @@
list.exclude(f)
end
end
end.to_a
PDD.log.info "#{files.size} file(s) found"
- types = [%r{^text/}, %r{application/xml}]
- files
- .select { |f| types.index { |re| @magic.file(f) =~ re } }
- .map do |file|
- VerboseSource.new(
- file,
- Source.new(file, file[@dir.length + 1, file.length])
- )
- end
+ files.select { |f| !File.directory?(f) && !File.binary?(f) }.map do |file|
+ VerboseSource.new(
+ file,
+ Source.new(file, file[@dir.length + 1, file.length])
+ )
+ end
end
def exclude(ptn)
Sources.new(@dir, @exclude.push(ptn))
end