file_crawler 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b18468fb9ef26484e074f797eca9d4323ea34012
4
- data.tar.gz: b970cc673130d37e5f46b6b59b2eb000b7dd8789
3
+ metadata.gz: 9486f8689c3aceebad5b8d061f0ba516d57f51b9
4
+ data.tar.gz: 975019e5017db6289e3dc9f386e3c932b3587bcc
5
5
  SHA512:
6
- metadata.gz: b2d1fadd395355fbda390bbc1683a0752077fd3cec402f15512b0613a9e0201cfd16fed8ad99aa715f328e941dd58ff748ae401cb6122e280fcf58685fdca405
7
- data.tar.gz: 7fbb2d29b40af52deb561cabf703a9bd768e822eb54a05c2596b5bd8b436ccc4ea6bbe83136208a1365f8af0be97f7e26e6764162f2980c3efdad690faf51e69
6
+ metadata.gz: 7f4d20fb6b0146e96ba49f8c3cb0d2c9a69e5b82936afcc8775235ce9cb9c336ce7a1ba1140daabee1c7a31f1e221bf1a13734957d085f3aed73473cdb798e96
7
+ data.tar.gz: bb3a47a3c550dfb406bd7850435780949ddb178ea2bc3a9d0a4a0a614fc2b6b0274200ad7784bd86b7894ef95cc3faa42634128bbae78b46970f7b648e9f3159
@@ -7,6 +7,7 @@ module FileCrawler
7
7
 
8
8
  include Command::Collect
9
9
  include Command::Move
10
+ include Command::Resemble
10
11
  include Command::Search
11
12
 
12
13
  def initialize
@@ -66,4 +67,12 @@ module FileCrawler
66
67
  finder.rows
67
68
  end
68
69
 
70
+ def self.resemble(path, conditions = {})
71
+ finder = FileCrawler::Finder.new
72
+
73
+ finder.search(path).collect(conditions).resemble()
74
+
75
+ finder.rows
76
+ end
77
+
69
78
  end
@@ -1,3 +1,4 @@
1
1
  require_relative 'command/collect'
2
2
  require_relative 'command/move'
3
+ require_relative 'command/resemble'
3
4
  require_relative 'command/search'
@@ -48,15 +48,15 @@ module FileCrawler
48
48
  def decide_index_for_collect(string)
49
49
  if !regexs.empty?
50
50
  regexs.each {|regex|
51
- return $1 unless regex.pattern.match(string).nil?
51
+ return $1.strip unless regex.pattern.match(string).nil?
52
52
  }
53
53
  end
54
54
 
55
55
  pattern = /[\p{Hiragana}|\p{Katakana}|\p{Han}|[a-zA-Z0-9]ー  ]+/
56
56
  result = string.strip.scan(pattern).first
57
- return result unless result.nil?
57
+ return result.strip unless result.nil?
58
58
 
59
- string
59
+ string.strip
60
60
  end
61
61
 
62
62
  end
@@ -0,0 +1,31 @@
1
+ module FileCrawler
2
+ class Finder
3
+ module Command
4
+ module Resemble
5
+
6
+ def resemble()
7
+ tap {
8
+ @rows = resemble_in_collection(@rows.values)
9
+ }
10
+ end
11
+
12
+ # use rows after using #collect
13
+ def resemble_in_collection(collection)
14
+ files = []
15
+
16
+ pattern = /\(\d+\)$/
17
+
18
+ collection.each {|files_in_same_directory|
19
+ files_in_same_directory.each {|file|
20
+ filename = File.basename(file)
21
+ files << file unless pattern.match(filename).nil?
22
+ }
23
+ }
24
+
25
+ files
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module FileCrawler
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_crawler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hirohisa Kawasaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-10 00:00:00.000000000 Z
11
+ date: 2016-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,7 @@ files:
67
67
  - lib/file_crawler/finder/command.rb
68
68
  - lib/file_crawler/finder/command/collect.rb
69
69
  - lib/file_crawler/finder/command/move.rb
70
+ - lib/file_crawler/finder/command/resemble.rb
70
71
  - lib/file_crawler/finder/command/search.rb
71
72
  - lib/file_crawler/version.rb
72
73
  homepage: https://github.com/hirohisa/file_crawler