sicily 0.1.5 → 0.1.6
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 +4 -4
- data/.travis.yml +4 -2
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -7
- data/lib/sicily/config.rb +3 -1
- data/lib/sicily/monitor.rb +18 -2
- data/lib/sicily/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f6d06dfcf656ff02bef26a923b9684d5a28851e
|
4
|
+
data.tar.gz: 5ead2b24d7137cd9eafe16b7f43df83997ec4e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1faa2887227d90898a5efa500d2933bd6e6915621d46db189e7038bb292bae273bc1956f306c17b6789dae943d3ef9dae925db41794efa140afec3693574bff
|
7
|
+
data.tar.gz: 8987884e10095901ddccf3ede93d061f97796d8fbe280304ede4afead9843e098972f90534eb43c4e07f202da32cf413f4fae8a082ec258b224b357f39d3d8bb
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
[](https://badge.fury.io/rb/sicily)
|
2
|
+
[](https://travis-ci.org/eunjae-lee/sicily)
|
2
3
|
|
3
4
|
# Sicily
|
4
5
|
|
@@ -30,17 +31,12 @@ And install a node package as:
|
|
30
31
|
|
31
32
|
Go to your project path, and then execute:
|
32
33
|
|
34
|
+
$ mkdir my-project
|
35
|
+
$ cd my-project
|
33
36
|
$ sicily generate
|
34
37
|
|
35
38
|
### Modify the generated files
|
36
39
|
|
37
|
-
`./config/google_photo.rb`
|
38
|
-
|
39
|
-
Sicily.configure_google do |config|
|
40
|
-
config.id = "your id"
|
41
|
-
config.pw = "your pw"
|
42
|
-
end
|
43
|
-
|
44
40
|
`./config/rules.rb`
|
45
41
|
|
46
42
|
Sicily.on '~/your_folder' do
|
@@ -59,6 +55,13 @@ Go to your project path, and then execute:
|
|
59
55
|
rm
|
60
56
|
end
|
61
57
|
|
58
|
+
`./config/google_photo.rb` (optional)
|
59
|
+
|
60
|
+
Sicily.configure_google do |config|
|
61
|
+
config.id = 'your id'
|
62
|
+
config.pw = 'your pw'
|
63
|
+
end
|
64
|
+
|
62
65
|
### Start & Stop
|
63
66
|
|
64
67
|
If you want to monitor just during the current terminal session, then execute:
|
data/lib/sicily/config.rb
CHANGED
@@ -8,12 +8,14 @@ module Sicily
|
|
8
8
|
class Config
|
9
9
|
attr_reader :forbid_new_file_in_subfolder,
|
10
10
|
:num_thread_pool,
|
11
|
-
:delay_on_file_monitoring
|
11
|
+
:delay_on_file_monitoring,
|
12
|
+
:consume_on_start
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
@forbid_new_file_in_subfolder = true
|
15
16
|
@num_thread_pool = 50
|
16
17
|
@delay_on_file_monitoring = 10
|
18
|
+
@consume_on_start = true
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/sicily/monitor.rb
CHANGED
@@ -8,6 +8,24 @@ require 'sicily/error/monitor_error'
|
|
8
8
|
module Sicily
|
9
9
|
class Monitor
|
10
10
|
def on(path, &user_rule_block)
|
11
|
+
consume_all(path, &user_rule_block)
|
12
|
+
attach_monitor(path, &user_rule_block)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def consume_all(path, &user_rule_block)
|
18
|
+
return unless Sicily.config.consume_on_start
|
19
|
+
|
20
|
+
files = already_existing_files(path)
|
21
|
+
BatchProcessor.new(files).run(&user_rule_block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def already_existing_files(path)
|
25
|
+
Dir["#{File.expand_path(path)}/**/*"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def attach_monitor(path, &user_rule_block)
|
11
29
|
Sicily.logger.info "Starting a monitor on #{path}"
|
12
30
|
path = validate_and_expand_path(path)
|
13
31
|
start_listener(path) do |files|
|
@@ -21,8 +39,6 @@ module Sicily
|
|
21
39
|
path
|
22
40
|
end
|
23
41
|
|
24
|
-
private
|
25
|
-
|
26
42
|
def start_listener(path)
|
27
43
|
delay = Sicily.config.delay_on_file_monitoring
|
28
44
|
listener = Listen.to(path, wait_for_delay: delay) do |_modified, added, _removed|
|
data/lib/sicily/version.rb
CHANGED