fde-file_crawler 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +4 -38
- data/bin/console +1 -1
- data/fde-file_crawler.gemspec +2 -1
- data/lib/{file_crawler.rb → fde/file_crawler.rb} +14 -7
- data/lib/{file_crawler → fde/file_crawler}/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d0f14417036814ba9682befc46803b8384cad24
|
4
|
+
data.tar.gz: f7bf404dbfd33354c7ec07952df1143c774a4f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f62fc76a26fbe25cb37ce9abc839c3ef0e56208398d17db884c2e9e82da6f3868f4bd5c708e5472fd0684666a5ae88df380855053a3c9a7aeb32fdb0d1c968
|
7
|
+
data.tar.gz: 6f1fb1f3d5b61e9cae0a6ebac4c372b96f7bf4ce839ff50bb93a4e69cd8b44bf2a600333abcdd1f90e3c2d43cfd3d3557d82fc3e785fd8466cf906bb03542e0b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'file_crawler'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install file_crawler
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/fde-file_crawler.svg)](https://badge.fury.io/rb/fde-file_crawler)
|
2
|
+
[![Build Status](https://travis-ci.org/fashion-data-exchange/file_crawler.svg?branch=master)](https://travis-ci.org/fashion-data-exchange/file_crawler)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/fashion-data-exchange/file_crawler/badges/gpa.svg)](https://codeclimate.com/github/fashion-data-exchange/file_crawler)
|
22
4
|
|
23
|
-
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/file_crawler.
|
36
|
-
|
37
|
-
## License
|
38
|
-
|
39
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
5
|
+
# FileCrawler
|
data/bin/console
CHANGED
data/fde-file_crawler.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "file_crawler/version"
|
4
|
+
require "fde/file_crawler/version"
|
5
|
+
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "fde-file_crawler"
|
7
8
|
spec.version = FDE::FileCrawler::VERSION
|
@@ -1,10 +1,11 @@
|
|
1
|
-
require 'file_crawler/version'
|
1
|
+
require 'fde/file_crawler/version'
|
2
2
|
|
3
3
|
module FDE
|
4
|
-
|
5
4
|
module FileCrawler
|
5
|
+
class NoCopyTargetDefined < StandardError; end
|
6
|
+
|
6
7
|
class Config
|
7
|
-
attr_accessor :
|
8
|
+
attr_accessor :path_in_directory, :path_out_directory
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.config
|
@@ -24,14 +25,20 @@ module FDE
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def self.crawl(query = /.*\.*/i)
|
27
|
-
path = self.config.
|
28
|
+
path = self.config.path_in_directory
|
28
29
|
files = Dir.entries(path)
|
29
30
|
files -= %w[. ..]
|
30
31
|
files.select { |file| query.match(file) }
|
31
32
|
end
|
32
33
|
|
33
|
-
def self.copy(file, target)
|
34
|
-
|
34
|
+
def self.copy(file, target = nil)
|
35
|
+
if self.config.path_out_directory && target.nil?
|
36
|
+
FileUtils.copy(path_for(file), self.config.path_out_directory)
|
37
|
+
elsif target.nil?
|
38
|
+
raise NoCopyTargetDefined
|
39
|
+
else
|
40
|
+
FileUtils.copy(path_for(file), target)
|
41
|
+
end
|
35
42
|
end
|
36
43
|
|
37
44
|
def self.delete(file)
|
@@ -43,7 +50,7 @@ module FDE
|
|
43
50
|
end
|
44
51
|
|
45
52
|
def self.path_for(file)
|
46
|
-
"#{self.config.
|
53
|
+
"#{self.config.path_in_directory}#{file}"
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fde-file_crawler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Langenegger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,8 +112,8 @@ files:
|
|
112
112
|
- bin/console
|
113
113
|
- bin/setup
|
114
114
|
- fde-file_crawler.gemspec
|
115
|
-
- lib/file_crawler.rb
|
116
|
-
- lib/file_crawler/version.rb
|
115
|
+
- lib/fde/file_crawler.rb
|
116
|
+
- lib/fde/file_crawler/version.rb
|
117
117
|
homepage: https://github.com/fashion-data-exchange/file_crawler
|
118
118
|
licenses:
|
119
119
|
- MIT
|