dynamic_paperclip 1.0.0a.1 → 1.0.0a.2

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.
@@ -5,5 +5,7 @@ module DynamicPaperclip
5
5
  initializer 'dynamic_paperclip.insert_middleware' do |app|
6
6
  app.config.middleware.use "DynamicPaperclip::AttachmentStyleGenerator"
7
7
  end
8
+
9
+ rake_tasks { load 'tasks/dynamic_paperclip.rake' }
8
10
  end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module DynamicPaperclip
2
- VERSION = "1.0.0a.1"
2
+ VERSION = "1.0.0a.2"
3
3
  end
@@ -0,0 +1,33 @@
1
+ namespace :dynamic_paperclip do
2
+ desc 'Removes the given dynamic DEFINITION from the given CLASS and ATTACHMENT'
3
+ task :remove_style => :environment do
4
+ class_name = ENV['CLASS'] || ENV['class']
5
+ attachment_name = ENV['ATTACHMENT'] || ENV['attachment']
6
+ definition = ENV['DEFINITION'] || ENV['definition']
7
+
8
+ raise 'must specify a DEFINITION' unless definition.present?
9
+ raise 'must specify a CLASS' unless class_name.present?
10
+ raise 'must specify an ATTACHMENT' unless attachment_name.present?
11
+
12
+ raise "'#{attachment_name}' is not a dynamic attachment on the #{class_name} class" unless DynamicPaperclip::AttachmentRegistry.names_for(class_name.constantize).include?(attachment_name.to_sym)
13
+
14
+ total_deletes = 0
15
+
16
+ Paperclip.each_instance_with_attachment(class_name, attachment_name) do |instance|
17
+ attachment = instance.send(attachment_name)
18
+ style_name = DynamicPaperclip::StyleNaming.dynamic_style_name_from_definition(definition)
19
+
20
+ # Only proceed if this attachment has generated the given definition
21
+ if attachment.dynamic_styles.keys.include?(style_name)
22
+ total_deletes += 1
23
+
24
+ puts "Deleting: #{attachment.path(style_name)}"
25
+
26
+ attachment.send :queue_some_for_delete, style_name
27
+ attachment.flush_deletes
28
+ end
29
+ end
30
+
31
+ puts "**Deleted #{total_deletes} instances of the '#{definition}' dynamic style for the #{class_name} #{attachment_name} attachment**"
32
+ end
33
+ end
Binary file
@@ -23310,3 +23310,90 @@ Command :: file -b --mime '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rail
23310
23310
   (0.0ms) rollback transaction
23311
23311
   (0.1ms) begin transaction
23312
23312
   (0.1ms) rollback transaction
23313
+ Connecting to database specified by database.yml
23314
+  (27.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23315
+ Migrating to CreatePhotos (20131102002336)
23316
+  (0.1ms) begin transaction
23317
+ Fixture Delete (0.5ms) DELETE FROM "photos"
23318
+ Fixture Insert (0.4ms) INSERT INTO "photos" ("id", "image_file_name", "image_content_type", "created_at", "updated_at") VALUES (1, 'rails.png', 'image/png', '2014-08-13 20:51:28', '2014-08-13 20:51:28')
23319
+  (0.6ms) commit transaction
23320
+  (0.0ms) begin transaction
23321
+ Photo Load (0.3ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23322
+  (0.1ms) rollback transaction
23323
+  (0.1ms) begin transaction
23324
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23325
+  (0.1ms) rollback transaction
23326
+  (0.0ms) begin transaction
23327
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23328
+  (0.1ms) rollback transaction
23329
+  (0.0ms) begin transaction
23330
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23331
+  (0.1ms) rollback transaction
23332
+  (0.0ms) begin transaction
23333
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23334
+  (0.1ms) rollback transaction
23335
+  (0.0ms) begin transaction
23336
+  (0.1ms) rollback transaction
23337
+  (0.1ms) begin transaction
23338
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23339
+ Started GET "/system/photos/images/000/000/001/dynamic_100x100/rails.png?s=d2dcb69d514d1030ce01404ebc422423eccf1b02" for 127.0.0.1 at 2014-08-13 16:51:29 -0400
23340
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23341
+ Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk.png[0]'
23342
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk.png[0]'
23343
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk.png[0]'
23344
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk.png[0]'
23345
+ Command :: convert '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk.png[0]' -auto-orient -resize "100x100" '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk20140813-38714-au8n9b'
23346
+ Command :: file -b --mime '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38714-1qcilzk20140813-38714-au8n9b'
23347
+  (0.1ms) SAVEPOINT active_record_1
23348
+  (0.3ms) UPDATE "photos" SET "image_file_size" = 6646, "image_updated_at" = '2014-08-13 20:51:29.546459', "image_file_name" = 'rails.png', "updated_at" = '2014-08-13 20:51:29.681071' WHERE "photos"."id" = 1
23349
+  (0.1ms) RELEASE SAVEPOINT active_record_1
23350
+  (0.6ms) rollback transaction
23351
+  (0.1ms) begin transaction
23352
+  (0.0ms) rollback transaction
23353
+  (0.1ms) begin transaction
23354
+  (0.1ms) rollback transaction
23355
+ Connecting to database specified by database.yml
23356
+  (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23357
+ Migrating to CreatePhotos (20131102002336)
23358
+ Connecting to database specified by database.yml
23359
+  (17.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
23360
+ Migrating to CreatePhotos (20131102002336)
23361
+  (0.1ms) begin transaction
23362
+ Fixture Delete (0.3ms) DELETE FROM "photos"
23363
+ Fixture Insert (0.1ms) INSERT INTO "photos" ("id", "image_file_name", "image_content_type", "created_at", "updated_at") VALUES (1, 'rails.png', 'image/png', '2014-08-13 20:52:22', '2014-08-13 20:52:22')
23364
+  (0.5ms) commit transaction
23365
+  (0.0ms) begin transaction
23366
+ Photo Load (0.2ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23367
+  (0.1ms) rollback transaction
23368
+  (0.0ms) begin transaction
23369
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23370
+  (0.0ms) rollback transaction
23371
+  (0.0ms) begin transaction
23372
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23373
+  (0.0ms) rollback transaction
23374
+  (0.0ms) begin transaction
23375
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23376
+  (0.0ms) rollback transaction
23377
+  (0.0ms) begin transaction
23378
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23379
+  (0.0ms) rollback transaction
23380
+  (0.0ms) begin transaction
23381
+  (0.0ms) rollback transaction
23382
+  (0.0ms) begin transaction
23383
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23384
+ Started GET "/system/photos/images/000/000/001/dynamic_100x100/rails.png?s=d2dcb69d514d1030ce01404ebc422423eccf1b02" for 127.0.0.1 at 2014-08-13 16:52:22 -0400
23385
+ Photo Load (0.1ms) SELECT "photos".* FROM "photos" WHERE "photos"."id" = ? LIMIT 1 [["id", 1]]
23386
+ Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva.png[0]'
23387
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva.png[0]'
23388
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva.png[0]'
23389
+ Command :: identify -format %m '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva.png[0]'
23390
+ Command :: convert '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva.png[0]' -auto-orient -resize "100x100" '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva20140813-38914-u8fp6l'
23391
+ Command :: file -b --mime '/var/folders/sd/669fr45168q7jsmsp132kqfr0000gn/T/rails20140813-38914-1j3slva20140813-38914-u8fp6l'
23392
+  (0.1ms) SAVEPOINT active_record_1
23393
+  (0.3ms) UPDATE "photos" SET "image_file_size" = 6646, "image_updated_at" = '2014-08-13 20:52:22.354099', "image_file_name" = 'rails.png', "updated_at" = '2014-08-13 20:52:22.442267' WHERE "photos"."id" = 1
23394
+  (0.0ms) RELEASE SAVEPOINT active_record_1
23395
+  (0.3ms) rollback transaction
23396
+  (0.1ms) begin transaction
23397
+  (0.0ms) rollback transaction
23398
+  (0.0ms) begin transaction
23399
+  (0.0ms) rollback transaction
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ # require 'rake'
3
+ load 'tasks/paperclip.rake'
4
+
5
+ class RakeTest < Test::Unit::TestCase
6
+ context "calling `rake dynamic_paperclip:remove_style`" do
7
+ setup do
8
+
9
+ end
10
+
11
+ should 'queue dynamic style for delete and flush deletes' do
12
+ ::Rake::Task['dynamic_paperclip:remove_style'].execute
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0a.1
4
+ version: 1.0.0a.2
5
5
  prerelease: 5
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-21 00:00:00.000000000 Z
12
+ date: 2014-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -160,6 +160,7 @@ files:
160
160
  - lib/dynamic_paperclip/version.rb
161
161
  - lib/dynamic_paperclip.rb
162
162
  - lib/generators/dynamic_paperclip/install_generator.rb
163
+ - lib/tasks/dynamic_paperclip.rake
163
164
  - MIT-LICENSE
164
165
  - Rakefile
165
166
  - README.md
@@ -201,6 +202,7 @@ files:
201
202
  - test/unit/attachment_style_generator_test.rb
202
203
  - test/unit/attachment_test.rb
203
204
  - test/unit/has_attached_file_test.rb
205
+ - test/unit/rake_test.rb
204
206
  homepage: http://github.com/room118solutions/dynamic_paperclip
205
207
  licenses: []
206
208
  post_install_message:
@@ -215,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
217
  version: '0'
216
218
  segments:
217
219
  - 0
218
- hash: 2045189592495985284
220
+ hash: 3168233451025285427
219
221
  required_rubygems_version: !ruby/object:Gem::Requirement
220
222
  none: false
221
223
  requirements:
@@ -267,3 +269,4 @@ test_files:
267
269
  - test/unit/attachment_style_generator_test.rb
268
270
  - test/unit/attachment_test.rb
269
271
  - test/unit/has_attached_file_test.rb
272
+ - test/unit/rake_test.rb