epub-search 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 536544d7de71e3a8248d0dfde581b2cf23a32cc1
4
- data.tar.gz: dea71df17f48c5d10fa7b767904259db9021a057
3
+ metadata.gz: 8b13b7b323e7bac69c408b9fddae5c6a1032336b
4
+ data.tar.gz: 5b365484dc01ebb3e354e9997121f0df75bbefa0
5
5
  SHA512:
6
- metadata.gz: 5d77aeba6dfcaff267d8e15577ad0fc5438039cabbb1badee432456906b4b3be780fcca4ea8be15235286205e34efa929bfa85526a1b0c49a927a49292aad345
7
- data.tar.gz: 42f255473c9386d092b1d1d6b15cbfd081b729abf4a694321302c845e3778e14c807a65e108343c2f0a4cdb63d1718aeece69c0b3be3a6787a1d85d16565d7f3
6
+ metadata.gz: a8c64c2c72bd1907bc4b20c1a4e66e147c3165a463dc9bbf7dd7bf7604e990bb2b566d1ca4e69af559bbafc9a310d964c851498b5696df6b584bf6b8313d82f0
7
+ data.tar.gz: 31067155ad835d1d717fadd98b64b0ede7d3accb9886d8a8dad7784fd5d08c5a83fd2a94ec1561757faa4476d6e7bbaf11c01515eaad5db89731f7c9aff8ae5b
@@ -1,6 +1,10 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ 0.0.3
5
+ -----
6
+ * Specify the version of Listen gem as '>= 1.0.0' to aopt to changed API
7
+
4
8
  0.0.2
5
9
  -----
6
10
  * Ruby vertion limited to 2.0
@@ -46,6 +46,9 @@ Configuration file should be written as YAML and you can set properties below:
46
46
  ChangeLog
47
47
  ---------
48
48
 
49
+ ### 0.0.3
50
+ * Specify the version of Listen gem
51
+
49
52
  ### 0.0.2
50
53
  * Ruby vertion limited to 2.0
51
54
  * Database directory changed
@@ -26,17 +26,18 @@ class Watch
26
26
  end
27
27
  Process.daemon if @daemonize
28
28
  write_pid_file
29
+
30
+ EPUB::Search::Database::Actor.supervise_as :db, @db
31
+
29
32
  catch_up
30
33
  begin
31
- Listen.to *@directories, :filter => EPUB_RE do |modified, added, removed|
34
+ Listen.to! *@directories, :filter => EPUB_RE do |modified, added, removed|
32
35
  modified.each do |file_path|
33
36
  next unless file_path =~ EPUB_RE
34
37
  file_path.force_encoding 'UTF-8'
35
38
  begin
36
- $stderr.puts "remove #{file_path}"
37
- @db.remove file_path
38
- $stderr.puts "add #{file_path}"
39
- @db.add file_path
39
+ $stderr.puts "update #{file_path}"
40
+ Celluloid::Actor[:db].async.update file_path
40
41
  title = EPUB::Parser.parse(file_path).title
41
42
  notify %Q|UPDATED: #{title}\n#{file_path}|
42
43
  FileUtils.touch exit_time_file
@@ -49,7 +50,7 @@ class Watch
49
50
  next unless file_path =~ EPUB_RE
50
51
  file_path.force_encoding 'UTF-8'
51
52
  begin
52
- @db.add file_path
53
+ Celluloid::Actor[:db].async.add file_path
53
54
  title = EPUB::Parser.parse(file_path).title
54
55
  notify %Q|ADDED: #{title}\n#{file_path}|
55
56
  FileUtils.touch exit_time_file
@@ -62,7 +63,7 @@ class Watch
62
63
  next unless file_path =~ EPUB_RE
63
64
  file_path.force_encoding 'UTF-8'
64
65
  begin
65
- @db.remove file_path
66
+ Celluloid::Actor[:db].async.remove file_path
66
67
  notify %Q|REMOVED:\n#{file_path}|
67
68
  FileUtils.touch exit_time_file
68
69
  rescue => error
@@ -100,8 +101,8 @@ class Watch
100
101
  Dir["#{dir}/**/*.epub"].each do |file_path|
101
102
  next if File.file? exit_time_file and File.mtime(file_path) < exit_time
102
103
  begin
103
- removed = @db.remove(file_path)
104
- @db.add file_path
104
+ removed = Celluloid::Actor[:db].remove(file_path)
105
+ Celluloid::Actor[:db].async.add file_path
105
106
  operation = removed.zero? ? 'ADDED' : 'UPDATED'
106
107
  title = EPUB::Parser.parse(file_path).title
107
108
  notify "#{operation}: #{title}\n#{file_path}"
@@ -22,12 +22,12 @@ Gem::Specification.new do |gem|
22
22
  gem.add_runtime_dependency 'epub-parser'
23
23
  gem.add_runtime_dependency 'rroonga'
24
24
  gem.add_runtime_dependency 'thor'
25
- gem.add_runtime_dependency 'rb-inotify'
26
- gem.add_runtime_dependency 'listen'
25
+ gem.add_runtime_dependency 'listen', '~> 1.0.0'
27
26
  gem.add_runtime_dependency 'highline'
28
27
  gem.add_runtime_dependency 'notify', '0.5.0'
29
28
  gem.add_runtime_dependency 'rack'
30
29
  gem.add_runtime_dependency 'tilt'
30
+ gem.add_runtime_dependency 'celluloid'
31
31
 
32
32
  gem.add_development_dependency 'rake'
33
33
  gem.add_development_dependency 'bundler'
@@ -4,7 +4,9 @@ require 'epub/parser'
4
4
  require 'groonga'
5
5
  require 'listen'
6
6
  require 'highline'
7
+ require 'celluloid'
7
8
  require 'epub/search/database'
9
+ require 'epub/search/database/actor'
8
10
  require 'epub/search/formatter'
9
11
  require 'epub/search/server'
10
12
 
@@ -0,0 +1,26 @@
1
+ module EPUB
2
+ module Search
3
+ class Database
4
+ class Actor
5
+ include Celluloid
6
+
7
+ def initialize(db)
8
+ @db = db
9
+ end
10
+
11
+ def add(file_path)
12
+ @db.add file_path
13
+ end
14
+
15
+ def remove(file_path)
16
+ @db.remove file_path
17
+ end
18
+
19
+ def update(file_path)
20
+ @db.remove file_path
21
+ @db.add file_path
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  module Search
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-19 00:00:00.000000000 Z
11
+ date: 2013-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: epub-parser
@@ -52,34 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rb-inotify
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: listen
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - '>='
59
+ - - ~>
74
60
  - !ruby/object:Gem::Version
75
- version: '0'
61
+ version: 1.0.0
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '>='
66
+ - - ~>
81
67
  - !ruby/object:Gem::Version
82
- version: '0'
68
+ version: 1.0.0
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: highline
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +122,20 @@ dependencies:
136
122
  - - '>='
137
123
  - !ruby/object:Gem::Version
138
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: celluloid
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -246,6 +246,7 @@ files:
246
246
  - epub-search.gemspec
247
247
  - lib/epub/search.rb
248
248
  - lib/epub/search/database.rb
249
+ - lib/epub/search/database/actor.rb
249
250
  - lib/epub/search/formatter.rb
250
251
  - lib/epub/search/formatter/cli.rb
251
252
  - lib/epub/search/server.rb