writefully 0.5.1 → 0.6.2

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: a2543752436eb5338c777cea97ad0d3fdfc8cb1e
4
- data.tar.gz: eee8670891fe7404fb6db2f7353fb8e857eeb128
3
+ metadata.gz: 149f326e3911550cb5ef5cac21138f9129eaf526
4
+ data.tar.gz: aae249683286ce662929eaf6334565719f5957cb
5
5
  SHA512:
6
- metadata.gz: 72b0ecf4fb74a52159741d087e2fa65ed42b7931d29c6c99e4e8ce8798b2ad5e0c5ebbe07be8ec189133936012b65ac9ded303a64302af3f5d2653512cba62d4
7
- data.tar.gz: fbb202ff48a59cb0674c31367afeb8db30fdf685a8ff77e3d7ec0f9c5816d352bd084fe5ef1ed0d353eda9fb57f8f46d0b07c9643594fe45e61510685fc0df82
6
+ metadata.gz: 3670fca4f1caa0f244503c7bdcc11d7154b2f30a6698e863bd4ff61a17bad28ad8ec87692083e6d2dff443d5300f7ca3a8f3f2e308ece6417e96d9ee2c199079
7
+ data.tar.gz: 7994231c1257090ee029832060471dec9dd58c14f0d1b1fc6b2d87a01c05f04d1d63389971c64c9e5c2c5b7969c4f41c24d1bfa7aa95bd3b66084a77ff8da72d
@@ -2,7 +2,7 @@ module Writefully
2
2
  module Indices
3
3
  def self.build_from(modified)
4
4
  modified.map do |file_name|
5
- index_hash_from(index_name_from(remove_content_path(file_name)))
5
+ index_hash_from(index_name_from(remove_content_path(file_name)))
6
6
  end
7
7
  end
8
8
 
@@ -25,7 +25,7 @@ module Writefully
25
25
  end
26
26
 
27
27
  def publish_resource
28
- if publish
28
+ if publish and published_at.nil?
29
29
  self.published_at = Time.now
30
30
  else
31
31
  self.published_at = nil
@@ -78,7 +78,7 @@ module Writefully
78
78
  Proc.new do |modified, added, removed|
79
79
  queue_jobs(Indices.build_from(modified), :write)
80
80
  queue_jobs(Indices.build_from(added), :write)
81
- # queue_jobs(Indices.build_from(removed), :remove)
81
+ queue_jobs(Indices.build_from(removed), :remove)
82
82
  end
83
83
  end
84
84
 
@@ -94,7 +94,7 @@ module Writefully
94
94
 
95
95
  JOBS = {
96
96
  write: -> (index) { Writefully.add_job :journalists, index.merge({task: :publish}) },
97
- remove: -> (index) { Writefully.add_job :journalists, index.merge({task: :remove}), :top }
97
+ remove: -> (index) { Writefully.add_job :journalists, index.merge({task: :remove}) }
98
98
  }
99
99
 
100
100
  def queue_jobs indices, action
@@ -13,6 +13,10 @@ module Writefully
13
13
  })
14
14
  end
15
15
 
16
+ def remove_file(key)
17
+ directory.files.get(key).destroy
18
+ end
19
+
16
20
  def endpoint
17
21
  Writefully.options[:assets_host] || provider_endpoints[Writefully.options[:storage_provider].downcase.to_sym]
18
22
  end
@@ -3,14 +3,34 @@ module Writefully
3
3
  class Eraser < Stationery
4
4
 
5
5
  def use
6
- destroy
6
+ trash
7
+ remove_assets
8
+ destroyed = future.destroy
9
+ terminate if destroyed.value
7
10
  end
8
11
 
9
- def destroy
12
+ def trash
10
13
  compute_type.by_site(site_id)
11
14
  .where(slug: content.slug)
12
15
  .first.update_attributes(trashed: true)
13
16
  end
17
+
18
+ def remove_assets
19
+ Writefully::Storage.directory.files.map do |file|
20
+ file.key if file.key.match(::Regexp.new(index[:slug]))
21
+ end.compact.each do |key|
22
+ Celluloid::Actor[:pigeons].future.remove(key)
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ compute_type.by_site(site_id).where(slug: content.slug).first.destroy
28
+ end
29
+
30
+ def directory_exists?
31
+ File.directory?(File.join(Writefully.options[:content],
32
+ index[:site], index[:resource], index[:slug]))
33
+ end
14
34
  end
15
35
  end
16
36
  end
@@ -10,8 +10,10 @@ module Writefully
10
10
  nil
11
11
  end
12
12
 
13
- def remove endpoint, path, name
14
-
13
+ def remove key
14
+ Writefully::Storage.remove_file(key)
15
+ rescue StandardError => e
16
+ nil
15
17
  end
16
18
  end
17
19
  end
@@ -7,6 +7,7 @@ module Writefully
7
7
 
8
8
  class ContentModelNotFound < StandardError; end
9
9
  class SomeAssetsNotUploaded < StandardError; end
10
+ class SomeAssetsNotRemoved < StandardError; end
10
11
 
11
12
  def initialize(index)
12
13
  @site_id = Site.where(slug: index[:site]).first.id
@@ -1,3 +1,3 @@
1
1
  module Writefully
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -8,9 +8,13 @@ module Writefully
8
8
  end
9
9
 
10
10
  def remove
11
- Writefully.logger.info "Removing #{message[:resource]} #{message[:slug]}"
12
11
  eraser = Tools::Eraser.new_link(message)
13
- eraser.perform
12
+ unless eraser.directory_exists?
13
+ Writefully.logger.info "Removing #{message[:resource]} #{message[:slug]}"
14
+ eraser.perform
15
+ else
16
+ eraser.terminate
17
+ end
14
18
  end
15
19
 
16
20
  def message_with_tries
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: writefully
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zack Siri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails