bootswatch_rails 3.1.1.10 → 3.1.1.11

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: 07d95e02e359636014ad1526bf7d9aefd0ec7793
4
- data.tar.gz: 995facc0d2f1a13e3a75194ff4f1c4588ca0b205
3
+ metadata.gz: d292cd0ac0502d539ba38469e004f251b674d568
4
+ data.tar.gz: 3e0147c90db10cbda94cd6fd83e253def48ab807
5
5
  SHA512:
6
- metadata.gz: 438bb65b155e53dcc666949c3c014d6676ff260b36a74c264733ab2e6a34ca6ae0a8921459c6e59c7036b7e6d1e2bea4f7a4c98e6aaa7fb0210b634439f39783
7
- data.tar.gz: e38e2cf9b143c50da825e8e958b14d375ec91aaa376d743f76d0036c853d2e59a1b528bffd594dea43606318b4cdd1c1774e0499383c241ca12d83a5114f1f23
6
+ metadata.gz: 9a01fcf1875935a31e1802631ced3df739e4a9c38e28f884c9bb2810e540786a87b4ad9a492e46f1495019152d9f2b06ab0054aa8abfcfd237e31d9e3a17978f
7
+ data.tar.gz: c3c17f7bbd24e92e2bf0d627f928d752963d3ff23b2ade8824e7eac12586ef764da0727ffdfcd3c227f1379d6e43aeb4bd3d62618ea7b3351100110738f5a864
@@ -1,5 +1,5 @@
1
1
  module BootswatchRails
2
- VERSION = "3.1.1.10"
2
+ VERSION = "3.1.1.11"
3
3
  THEMES = [:amelia, :cerulean, :cosmo, :custom, :cyborg, :darkly, :flatly, :journal, :lumen, :readable, :simplex, :slate, :spacelab, :superhero, :united, :yeti]
4
4
  DEFAULT = 1
5
5
  end
@@ -0,0 +1,73 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module BootswatchRails
4
+ module Generators
5
+ class CarrierwaveGenerator < ActiveRecord::Generators::Base
6
+ desc "Add carrierwave uploader to resource"
7
+ argument :name, type: :string,
8
+ desc: "The object that will have an attachment"
9
+ argument :column, type: :string,
10
+ desc: 'The column name for the attachment'
11
+ class_option :uploader, type: :boolean, default: true,
12
+ desc: 'Add an appropriate uploader'
13
+ class_option :migration, type: :boolean, default: false,
14
+ desc: 'Create a migration for added attributes'
15
+ class_option :permit, type: :boolean, default: false,
16
+ desc: 'Allow mass assignment for added attributes'
17
+ class_option :before, type: :boolean, default: false,
18
+ desc: 'Add a line before generated text in model'
19
+ class_option :after, type: :boolean, default: false,
20
+ desc: 'Add a line after generated text in model'
21
+ source_root File.expand_path('../templates', __FILE__)
22
+
23
+ def add_uploader
24
+ if picture?
25
+ template "picture_uploader.rb", "app/uploaders/#{column}_uploader.rb"
26
+ elsif document?
27
+ template "document_uploader.rb", "app/uploaders/#{column}_uploader.rb"
28
+ else
29
+ run "rails generate uploader #{column.camelize}"
30
+ end
31
+ end
32
+
33
+ def add_migration
34
+ return unless options.migration?
35
+ migration_template "carrierwave_migration.rb", "db/migrate/#{migration_name}.rb"
36
+ end
37
+
38
+ def add_to_model
39
+ inject_into_class "app/models/#{name}.rb", class_name do
40
+ text = options.before? ? "\n" : ""
41
+ text << " mount_uploader :#{column}, #{column.camelize}Uploader\n"
42
+ text << "\n" if options.after?
43
+ text
44
+ end
45
+ end
46
+
47
+ def add_to_permit
48
+ file = "app/controllers/#{table_name}_controller.rb"
49
+ if options.permit?
50
+ gsub_file file, /(permit\(.*)\)/, "\\1, :#{column})"
51
+ # Special case: no previous permit
52
+ gsub_file file, /^(\s*params)\[:#{name}\]$/, "\\1.require(:#{name}).permit(:#{column})"
53
+ end
54
+ gsub_file file, /(permit.*)(:#{column})(.*)/, "\\1\\2, :#{column}_cache, :remove_#{column}\\3"
55
+ end
56
+
57
+ protected
58
+
59
+ def picture?
60
+ column.include?("picture")
61
+ end
62
+
63
+ def document?
64
+ column.include?("document")
65
+ end
66
+
67
+ def migration_name
68
+ "add_#{column}_to_#{table_name}"
69
+ end
70
+ end
71
+ end
72
+ end
73
+
@@ -0,0 +1,5 @@
1
+ class <%= migration_name.camelize %> < ActiveRecord::Migration
2
+ def change
3
+ add_column :<%= table_name %>, :<%= column %>, :string
4
+ end
5
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ class <%= column.camelize %>Uploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+
9
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
10
+ ## Seems to be gone in Rails 4.0 ???
11
+ ## include Sprockets::Helpers::RailsHelper
12
+ ## include Sprockets::Helpers::IsolatedHelper
13
+
14
+ # Choose what kind of storage to use for this uploader:
15
+ storage :file
16
+ # storage :fog
17
+
18
+ # Override the directory where uploaded files will be stored.
19
+ # This is a sensible default for uploaders that are meant to be mounted:
20
+ def store_dir
21
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
22
+ end
23
+
24
+ # Provide a default URL as a default if there hasn't been a file uploaded:
25
+ # def default_url
26
+ # # For Rails 3.1+ asset pipeline compatibility:
27
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
28
+ #
29
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
30
+ # end
31
+
32
+ # Process files as they are uploaded:
33
+ # process :scale => [200, 300]
34
+ #
35
+ # def scale(width, height)
36
+ # # do something
37
+ # end
38
+
39
+ # Add a white list of extensions which are allowed to be uploaded.
40
+ # For images you might use something like this:
41
+ # def extension_white_list
42
+ # %w(jpg jpeg gif png)
43
+ # end
44
+
45
+ # Override the filename of the uploaded files:
46
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
47
+ # def filename
48
+ # "something.jpg" if original_filename
49
+ # end
50
+
51
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ class <%= column.camelize %>Uploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ include CarrierWave::MiniMagick
8
+
9
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
10
+ ## Seems to be gone in Rails 4.0 ???
11
+ ## include Sprockets::Helpers::RailsHelper
12
+ ## include Sprockets::Helpers::IsolatedHelper
13
+
14
+ # Choose what kind of storage to use for this uploader:
15
+ storage :file
16
+ # storage :fog
17
+
18
+ # Override the directory where uploaded files will be stored.
19
+ # This is a sensible default for uploaders that are meant to be mounted:
20
+ def store_dir
21
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
22
+ end
23
+
24
+ # Provide a default URL as a default if there hasn't been a file uploaded:
25
+ # def default_url
26
+ # # For Rails 3.1+ asset pipeline compatibility:
27
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
28
+ #
29
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
30
+ # end
31
+
32
+ # Process files as they are uploaded:
33
+ # process :scale => [200, 300]
34
+ #
35
+ # def scale(width, height)
36
+ # # do something
37
+ # end
38
+
39
+ # Create different versions of your uploaded files:
40
+ version :thumb do
41
+ process :resize_to_limit => [100, 100]
42
+ end
43
+ version :carousel do
44
+ process :resize_to_fill => [600, 400]
45
+ end
46
+ version :display do
47
+ process :resize_to_limit => [600, 600]
48
+ end
49
+
50
+ # Add a white list of extensions which are allowed to be uploaded.
51
+ # For images you might use something like this:
52
+ def extension_white_list
53
+ %w(jpg jpeg gif png)
54
+ end
55
+
56
+ # Override the filename of the uploaded files:
57
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
58
+ # def filename
59
+ # "something.jpg" if original_filename
60
+ # end
61
+
62
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootswatch_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1.10
4
+ version: 3.1.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Wiegand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -85,6 +85,10 @@ files:
85
85
  - lib/bootswatch_rails.rb
86
86
  - lib/bootswatch_rails/engine.rb
87
87
  - lib/bootswatch_rails/version.rb
88
+ - lib/generators/bootswatch_rails/carrierwave/carrierwave_generator.rb
89
+ - lib/generators/bootswatch_rails/carrierwave/templates/carrierwave_migration.rb
90
+ - lib/generators/bootswatch_rails/carrierwave/templates/document_uploader.rb
91
+ - lib/generators/bootswatch_rails/carrierwave/templates/picture_uploader.rb
88
92
  - lib/generators/bootswatch_rails/install/install_generator.rb
89
93
  - lib/generators/bootswatch_rails/install/templates/app/assets/images/Rails_logo_80.jpg
90
94
  - lib/generators/bootswatch_rails/install/templates/app/helpers/application_helper.rb