sicily 0.1.3 → 0.1.4

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: 24bffd7625f941daf5ce70d26b13e2e125e357ae
4
- data.tar.gz: 60915840c1a95a889b11fa1025846c1a83507b96
3
+ metadata.gz: c3b5be431300e6ce68436d6126064a6187563139
4
+ data.tar.gz: fa017687e400cf32704eb3bbc4476e7315165b2f
5
5
  SHA512:
6
- metadata.gz: 3628311381543b604a85d12c2e5ce1a824c9111c168d3512d37c01ee5c0270a19d45ccd438d88b983a15b264c15e45eaf2ca1d66dd960f4208a49b56610e7778
7
- data.tar.gz: f8c1ef202d59a65ecc9063a507eb88f8b73f5ded2d359a832539086d7c18b48e707a2c609c894c57dc6d345ba38074c293fae8f718115b8a8abf50ab83f74630
6
+ metadata.gz: e8b827f0e3f9aa7278a596185cd8bbf30d62af0ea02c9e6937befc6a23a6a27d4d5ad6b65fcc1e19ce89bfde7bf8428b4fc5eea834c3396393ae159f945abbdd
7
+ data.tar.gz: 5a41679daa4924a591c7c66160f2aae3d26744423b880f2cd0eceb9b8094a14c697598ae72d5dd4a1bd50b39048351572dde148d6eb5131c5e0fa2eb083de548
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.4
4
+ * Add required ruby version
5
+ * It's now easy to add new generator.
6
+
3
7
  ## 0.1.3
4
8
  * It's now easy to create new task.
5
9
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sicily (0.1.3)
4
+ sicily (0.1.4)
5
5
  concurrent-ruby (~> 1.0.5)
6
6
  exifr (~> 1.3.3)
7
7
  fastimage (~> 2.1.1)
data/README.md CHANGED
@@ -26,14 +26,35 @@ And install a node package as:
26
26
 
27
27
  ## Usage
28
28
 
29
+ ### Generate config files
30
+
29
31
  Go to your project path, and then execute:
30
32
 
31
33
  $ sicily generate
34
+
35
+ ### Modify the generated files
36
+
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
+ ./config/rules.rb
45
+
46
+ Sicily.on "~/your_folder" do
47
+ fit_if_photo 2000, 2000
48
+ google_photo
49
+ mv "~/your_another_folder/%Y/%m/%d"
50
+ end
32
51
 
33
- Modify the generated files:
52
+ Sicily.on "~/your_folder2" do
53
+ fit_if_photo 1000, 1000
54
+ cp "~/your_another_folder/%Y/%m/%d"
55
+ end
34
56
 
35
- ./config/google_photo.rb
36
- ./config/rules.rb
57
+ ### Start & Stop
37
58
 
38
59
  If you want to monitor just during the current terminal session, then execute:
39
60
 
data/exe/sicily CHANGED
@@ -10,54 +10,33 @@ command = ARGV[0]
10
10
  case command
11
11
  when "generate"
12
12
  require "fileutils"
13
+ require "sicily/generator"
14
+
15
+ Dir["./generator/*.rb"].each {|file|
16
+ require file
17
+ }
18
+
19
+ FileUtils.rm_rf "./config"
13
20
  FileUtils.mkdir_p "./config"
14
21
 
15
- god_content = <<-EOF
16
- God.watch do |w|
17
- w.name = "sicily"
18
- w.start = "sicily monitor"
19
- w.dir = File.expand_path("\#{File.dirname(__FILE__)}/..")
20
- w.keepalive
21
- end
22
- EOF
23
- schedule_content = <<-EOF
24
- every :hour do
25
- god_file = File.expand_path("\#{File.dirname(__FILE__)}/.sicily.god")
26
- command "god -c \#{god_file}"
27
- end
28
- EOF
29
- google_photo_content = <<-EOF
30
- Sicily.configure_google do |config|
31
- config.id = "your id"
32
- config.pw = "your pw"
33
- end
34
- EOF
35
- rules_content = <<-EOF
36
- Sicily.on "~/your_folder" do
37
- fit_if_photo 2000, 2000
38
- google_photo
39
- mv "~/your_another_folder/%Y/%m/%d"
40
- end
22
+ Sicily.generators.each do |generator|
23
+ File.write("./config/#{generator.filename}", generator.content)
24
+ end
41
25
 
42
- Sicily.on "~/your_folder2" do
43
- fit_if_photo 1000, 1000
44
- cp "~/your_another_folder/%Y/%m/%d"
45
- end
46
- EOF
47
-
48
- File.write("./config/.sicily.god", god_content)
49
- File.write("./config/.schedule.rb", schedule_content)
50
- File.write("./config/google_photo.rb", google_photo_content)
51
- File.write("./config/rules.rb", rules_content)
52
-
53
- puts "Try edit the following files:"
54
- puts " ./config/google_photo.rb"
55
- puts " ./config/rules.rb"
56
- puts ""
57
- puts "To upload to Google Photos,"
58
- puts " turn on \"Allowing less secure apps to access your account\""
59
- puts " : https://support.google.com/accounts/answer/6010255"
60
- puts " *USE AT YOUR OWN RISK*"
26
+ files_to_edit = Sicily.generators.map { |t| t.filename }.select { |t| not t.start_with?(".") }
27
+ messages_to_display = Sicily.generators.map { |t| t.post_generate_message }.select { |t| not t.to_s.empty? }
28
+
29
+ if files_to_edit.size > 0
30
+ puts "Try edit the following files:"
31
+ files_to_edit.each do |file|
32
+ puts " ./config/#{file}"
33
+ end
34
+ end
35
+
36
+ if messages_to_display.size > 0
37
+ puts ""
38
+ puts messages_to_display.join("\n")
39
+ end
61
40
  when "monitor"
62
41
  `echo test >> monitor.log`
63
42
  necessary_config_files = ["rules.rb"]
@@ -0,0 +1,13 @@
1
+ module Sicily
2
+ Sicily.register_generator do |generator|
3
+ generator.filename = ".sicily.god"
4
+ generator.content = <<-EOF
5
+ God.watch do |w|
6
+ w.name = "sicily"
7
+ w.start = "sicily monitor"
8
+ w.dir = File.expand_path("\#{File.dirname(__FILE__)}/..")
9
+ w.keepalive
10
+ end
11
+ EOF
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module Sicily
2
+ Sicily.register_generator do |generator|
3
+ generator.filename = "google_photo.rb"
4
+ generator.content = <<-EOF
5
+ Sicily.configure_google do |config|
6
+ config.id = "your id"
7
+ config.pw = "your pw"
8
+ end
9
+ EOF
10
+ generator.post_generate_message = <<-EOF
11
+ To upload to Google Photos,
12
+ turn on "Allowing less secure apps to access your account"
13
+ : https://support.google.com/accounts/answer/6010255
14
+ *USE AT YOUR OWN RISK*
15
+ EOF
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Sicily
2
+ Sicily.register_generator do |generator|
3
+ generator.filename = "rules.rb"
4
+ generator.content = <<-EOF
5
+ Sicily.on "~/your_folder" do
6
+ fit_if_photo 2000, 2000
7
+ google_photo
8
+ mv "~/your_another_folder/%Y/%m/%d"
9
+ end
10
+
11
+ Sicily.on "~/your_folder2" do
12
+ fit_if_photo 1000, 1000
13
+ cp "~/your_another_folder/%Y/%m/%d"
14
+ end
15
+ EOF
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Sicily
2
+ Sicily.register_generator do |generator|
3
+ generator.filename = ".schedule.rb"
4
+ generator.content = <<-EOF
5
+ every :hour do
6
+ god_file = File.expand_path("\#{File.dirname(__FILE__)}/.sicily.god")
7
+ command "god -c \#{god_file}"
8
+ end
9
+ EOF
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ module Sicily
2
+ class Generator
3
+ attr_accessor :filename, :content, :post_generate_message
4
+ end
5
+
6
+ class << self
7
+ attr_accessor :generators
8
+ end
9
+ Sicily.generators = []
10
+
11
+ def self.register_generator(&block)
12
+ return unless block_given?
13
+
14
+ generator = Generator.new
15
+ block.call generator
16
+ Sicily.generators << generator
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Sicily
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.bindir = "exe"
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
+ spec.required_ruby_version = '>= 2.2.5'
37
38
 
38
39
  spec.add_dependency "listen", "~> 3.1.5"
39
40
  spec.add_dependency "god", "~> 0.13.7"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sicily
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Lee
@@ -174,6 +174,7 @@ extra_rdoc_files: []
174
174
  files:
175
175
  - ".gitignore"
176
176
  - ".rspec"
177
+ - ".ruby-version"
177
178
  - ".travis.yml"
178
179
  - CHANGELOG.md
179
180
  - CODE_OF_CONDUCT.md
@@ -185,10 +186,15 @@ files:
185
186
  - bin/console
186
187
  - bin/setup
187
188
  - exe/sicily
189
+ - generator/god.rb
190
+ - generator/google_photo.rb
191
+ - generator/rules.rb
192
+ - generator/schedule.rb
188
193
  - lib/sicily.rb
189
194
  - lib/sicily/batch_processor.rb
190
195
  - lib/sicily/config.rb
191
196
  - lib/sicily/file_processor.rb
197
+ - lib/sicily/generator.rb
192
198
  - lib/sicily/monitor.rb
193
199
  - lib/sicily/task/dummy_task.rb
194
200
  - lib/sicily/task/file_task.rb
@@ -222,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
228
  requirements:
223
229
  - - ">="
224
230
  - !ruby/object:Gem::Version
225
- version: '0'
231
+ version: 2.2.5
226
232
  required_rubygems_version: !ruby/object:Gem::Requirement
227
233
  requirements:
228
234
  - - ">="