carrierwave 0.4.10 → 0.5.0.beta2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of carrierwave might be problematic. Click here for more details.

@@ -14,6 +14,7 @@ upload files.
14
14
  * Please {report any issues}[http://github.com/jnicklas/carrierwave/issues] on GitHub
15
15
  * Please direct any questions at the {mailing list}[http://groups.google.com/group/carrierwave]
16
16
  * Check out the {example app}[http://github.com/jnicklas/carrierwave-example-app]
17
+ * Instructions for setting up a development environment are at the bottom of this file
17
18
 
18
19
  == Getting Started
19
20
 
@@ -275,7 +276,7 @@ It's a good idea to test you uploaders in isolation. In order to speed up your
275
276
  tests, it's recommended to switch off processing in your tests, and to use the
276
277
  file storage. In Rails you could do that by adding an initializer with:
277
278
 
278
- if Rails.env.test?
279
+ if Rails.env.test? or Rails.env.cucumber?
279
280
  CarrierWave.configure do |config|
280
281
  config.storage = :file
281
282
  config.enable_processing = false
@@ -302,7 +303,7 @@ CarrierWave comes with some RSpec matchers which you may find useful:
302
303
 
303
304
  context 'the thumb version' do
304
305
  it "should scale down a landscape image to be exactly 64 by 64 pixels" do
305
- @uploader.thumb.should have_dimensions(200, 200)
306
+ @uploader.thumb.should have_dimensions(64, 64)
306
307
  end
307
308
  end
308
309
 
@@ -313,7 +314,7 @@ CarrierWave comes with some RSpec matchers which you may find useful:
313
314
  end
314
315
 
315
316
  it "should make the image readable only to the owner and not executable" do
316
- @uploader.should have_premissions(0600)
317
+ @uploader.should have_permissions(0600)
317
318
  end
318
319
  end
319
320
 
@@ -507,6 +508,9 @@ These people have contributed their time and effort to CarrierWave:
507
508
  * Trevor Turk
508
509
  * Nicklas Ramhöj
509
510
  * Matt Hooks
511
+ * Andreas Haller
512
+ * Lars Pind
513
+ * Ramon Soares
510
514
 
511
515
  == License
512
516
 
@@ -533,14 +537,17 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
533
537
 
534
538
  == Development
535
539
 
536
- If you want to run the tests (and you should) it might be convenient to install
537
- the development dependencies, you can do that with:
540
+ In order to setup a development environment and run the specs, you'll
541
+ need to install bundler:
538
542
 
539
- sudo gem install carrierwave --development
543
+ gem install bundler --pre
540
544
 
541
- CarrierWave is still young, but most of it is pretty well documented. It is also
542
- extensively specced, and there are cucumber features for some common use cases.
543
- Just dig in and look at the source for more in-depth explanation of what things
544
- are doing.
545
+ And then install the dependencies:
546
+
547
+ bundle install
548
+
549
+ You should now be able to run the tests:
550
+
551
+ bundle exec rake spec
545
552
 
546
553
  Issues are reported on GitHub, pull requests are very welcome!
@@ -1,13 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'fileutils'
4
- require 'carrierwave/core_ext/blank'
5
- require 'carrierwave/core_ext/module_setup'
6
- require 'carrierwave/core_ext/inheritable_attributes'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'active_support/core_ext/class/inheritable_attributes'
6
+ require 'active_support/concern'
7
7
 
8
8
  module CarrierWave
9
9
 
10
- VERSION = "0.4.10"
10
+ VERSION = "0.4.5"
11
11
 
12
12
  class << self
13
13
  attr_accessor :root
@@ -80,8 +80,13 @@ if defined?(Merb)
80
80
 
81
81
  elsif defined?(Rails)
82
82
 
83
- CarrierWave.root = File.join(Rails.root, 'public')
84
- ActiveSupport::Dependencies.load_paths << File.join(Rails.root, "app", "uploaders")
83
+ module CarrierWave
84
+ class Railtie < Rails::Railtie
85
+ initializer "carrierwave.setup_paths" do
86
+ CarrierWave.root = Rails.root.join(Rails.public_path).to_s
87
+ end
88
+ end
89
+ end
85
90
 
86
91
  elsif defined?(Sinatra)
87
92
 
@@ -15,6 +15,8 @@ module CarrierWave
15
15
 
16
16
  alias_method :read_uploader, :read_attribute
17
17
  alias_method :write_uploader, :write_attribute
18
+ public :read_uploader
19
+ public :write_uploader
18
20
 
19
21
  validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
20
22
  validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
@@ -4,6 +4,21 @@ require "image_science"
4
4
 
5
5
  module CarrierWave
6
6
  module ImageScience
7
+ extend ActiveSupport::Concern
8
+
9
+ module ClassMethods
10
+ def resize_to_limit(width, height)
11
+ process :resize_to_limit => [width, height]
12
+ end
13
+
14
+ def resize_to_fit(width, height)
15
+ process :resize_to_fit => [width, height]
16
+ end
17
+
18
+ def resize_to_fill(width, height)
19
+ process :resize_to_fill => [width, height]
20
+ end
21
+ end
7
22
 
8
23
  ##
9
24
  # Resize the image to fit within the specified dimensions while retaining
@@ -56,11 +56,7 @@ module CarrierWave
56
56
  #
57
57
  #
58
58
  module MiniMagick
59
-
60
- def self.included(base)
61
- super
62
- base.extend(ClassMethods)
63
- end
59
+ extend ActiveSupport::Concern
64
60
 
65
61
  module ClassMethods
66
62
  def convert(format)
@@ -103,7 +99,7 @@ module CarrierWave
103
99
  #
104
100
  def convert(format)
105
101
  manipulate! do |img|
106
- img.format(format.to_s.upcase)
102
+ img.format(format.to_s.downcase)
107
103
  img = yield(img) if block_given?
108
104
  img
109
105
  end
@@ -68,11 +68,7 @@ module CarrierWave
68
68
  # http://rubyforge.org/forum/forum.php?thread_id=1374&forum_id=1618
69
69
  #
70
70
  module RMagick
71
-
72
- def self.included(base)
73
- super
74
- base.extend(ClassMethods)
75
- end
71
+ extend ActiveSupport::Concern
76
72
 
77
73
  module ClassMethods
78
74
  def convert(format)
@@ -111,10 +111,10 @@ module CarrierWave
111
111
 
112
112
  class ImageLoader # :nodoc:
113
113
  def self.load_image(filename)
114
- if defined? MiniMagick
114
+ if defined? ::MiniMagick
115
115
  MiniMagickWrapper.new(filename)
116
116
  else
117
- unless defined? Magick
117
+ unless defined? ::Magick
118
118
  begin
119
119
  require 'rmagick'
120
120
  rescue LoadError
@@ -25,19 +25,19 @@ module CarrierWave
25
25
  class Base
26
26
  attr_reader :file
27
27
 
28
- use CarrierWave::Uploader::Callbacks
29
- use CarrierWave::Uploader::Proxy
30
- use CarrierWave::Uploader::Url
31
- use CarrierWave::Uploader::Mountable
32
- use CarrierWave::Uploader::Cache
33
- use CarrierWave::Uploader::Store
34
- use CarrierWave::Uploader::Download
35
- use CarrierWave::Uploader::Remove
36
- use CarrierWave::Uploader::ExtensionWhitelist
37
- use CarrierWave::Uploader::Processing
38
- use CarrierWave::Uploader::Versions
39
- use CarrierWave::Uploader::DefaultUrl
40
- use CarrierWave::Uploader::Configuration
28
+ include CarrierWave::Uploader::Callbacks
29
+ include CarrierWave::Uploader::Proxy
30
+ include CarrierWave::Uploader::Url
31
+ include CarrierWave::Uploader::Mountable
32
+ include CarrierWave::Uploader::Cache
33
+ include CarrierWave::Uploader::Store
34
+ include CarrierWave::Uploader::Download
35
+ include CarrierWave::Uploader::Remove
36
+ include CarrierWave::Uploader::ExtensionWhitelist
37
+ include CarrierWave::Uploader::Processing
38
+ include CarrierWave::Uploader::Versions
39
+ include CarrierWave::Uploader::DefaultUrl
40
+ include CarrierWave::Uploader::Configuration
41
41
  end # Base
42
42
 
43
43
  end # Uploader
@@ -21,9 +21,10 @@ module CarrierWave
21
21
 
22
22
  module Uploader
23
23
  module Cache
24
+ extend ActiveSupport::Concern
24
25
 
25
- depends_on CarrierWave::Uploader::Callbacks
26
- depends_on CarrierWave::Uploader::Configuration
26
+ include CarrierWave::Uploader::Callbacks
27
+ include CarrierWave::Uploader::Configuration
27
28
 
28
29
  module ClassMethods
29
30
 
@@ -38,7 +39,7 @@ module CarrierWave
38
39
  # === Note
39
40
  #
40
41
  # This only works as long as you haven't done anything funky with your cache_dir.
41
- # It's recommended that you keen cache files in one place only.
42
+ # It's recommended that you keep cache files in one place only.
42
43
  #
43
44
  def clean_cached_files!
44
45
  Dir.glob(File.expand_path(File.join(cache_dir, '*'), CarrierWave.root)).each do |dir|
@@ -3,9 +3,10 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module Callbacks
6
+ extend ActiveSupport::Concern
6
7
 
7
- setup do
8
- extlib_inheritable_accessor :_before_callbacks, :_after_callbacks
8
+ included do
9
+ class_inheritable_accessor :_before_callbacks, :_after_callbacks
9
10
  end
10
11
 
11
12
  def with_callbacks(kind, *args)
@@ -17,26 +18,24 @@ module CarrierWave
17
18
  module ClassMethods
18
19
 
19
20
  def _before_callbacks_for(kind) #:nodoc:
20
- self._before_callbacks ||= {}
21
- self._before_callbacks[kind] ||= []
22
- self._before_callbacks[kind]
21
+ (self._before_callbacks || { kind => [] })[kind] || []
23
22
  end
24
23
 
25
24
  def _after_callbacks_for(kind) #:nodoc:
26
- self._after_callbacks ||= {}
27
- self._after_callbacks[kind] ||= []
28
- self._after_callbacks[kind]
25
+ (self._after_callbacks || { kind => [] })[kind] || []
29
26
  end
30
27
 
31
- def before(kind, callback)
32
- _before_callbacks_for(kind) << callback
28
+ def before(kind, callback)
29
+ self._before_callbacks ||= {}
30
+ self._before_callbacks[kind] = _before_callbacks_for(kind) + [callback]
33
31
  end
34
32
 
35
33
  def after(kind, callback)
36
- _after_callbacks_for(kind) << callback
34
+ self._after_callbacks ||= {}
35
+ self._after_callbacks[kind] = _after_callbacks_for(kind) + [callback]
37
36
  end
38
37
  end # ClassMethods
39
38
 
40
39
  end # Callbacks
41
40
  end # Uploader
42
- end # CarrierWave
41
+ end # CarrierWave
@@ -2,7 +2,9 @@ module CarrierWave
2
2
 
3
3
  module Uploader
4
4
  module Configuration
5
- setup do
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
6
8
  add_config :root
7
9
  add_config :permissions
8
10
  add_config :storage_engines
@@ -5,10 +5,11 @@ require 'net/http'
5
5
  module CarrierWave
6
6
  module Uploader
7
7
  module Download
8
+ extend ActiveSupport::Concern
8
9
 
9
- depends_on CarrierWave::Uploader::Callbacks
10
- depends_on CarrierWave::Uploader::Configuration
11
- depends_on CarrierWave::Uploader::Cache
10
+ include CarrierWave::Uploader::Callbacks
11
+ include CarrierWave::Uploader::Configuration
12
+ include CarrierWave::Uploader::Cache
12
13
 
13
14
  class RemoteFile
14
15
  def initialize(uri)
@@ -3,8 +3,9 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module ExtensionWhitelist
6
+ extend ActiveSupport::Concern
6
7
 
7
- setup do
8
+ included do
8
9
  before :cache, :check_whitelist!
9
10
  end
10
11
 
@@ -34,4 +35,4 @@ module CarrierWave
34
35
 
35
36
  end # ExtensionWhitelist
36
37
  end # Uploader
37
- end # CarrierWave
38
+ end # CarrierWave
@@ -3,10 +3,11 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module Processing
6
+ extend ActiveSupport::Concern
6
7
 
7
- depends_on CarrierWave::Uploader::Callbacks
8
+ include CarrierWave::Uploader::Callbacks
8
9
 
9
- setup do
10
+ included do
10
11
  after :cache, :process!
11
12
  after :recreate_versions, :process!
12
13
  end
@@ -81,4 +82,4 @@ module CarrierWave
81
82
 
82
83
  end # Processing
83
84
  end # Uploader
84
- end # CarrierWave
85
+ end # CarrierWave
@@ -3,8 +3,9 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module Remove
6
+ extend ActiveSupport::Concern
6
7
 
7
- depends_on CarrierWave::Uploader::Callbacks
8
+ include CarrierWave::Uploader::Callbacks
8
9
 
9
10
  ##
10
11
  # Removes the file and reset it
@@ -19,4 +20,4 @@ module CarrierWave
19
20
 
20
21
  end # Remove
21
22
  end # Uploader
22
- end # CarrierWave
23
+ end # CarrierWave
@@ -3,10 +3,11 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module Store
6
+ extend ActiveSupport::Concern
6
7
 
7
- depends_on CarrierWave::Uploader::Callbacks
8
- depends_on CarrierWave::Uploader::Configuration
9
- depends_on CarrierWave::Uploader::Cache
8
+ include CarrierWave::Uploader::Callbacks
9
+ include CarrierWave::Uploader::Configuration
10
+ include CarrierWave::Uploader::Cache
10
11
 
11
12
  ##
12
13
  # Override this in your Uploader to change the filename.
@@ -86,4 +87,4 @@ module CarrierWave
86
87
 
87
88
  end # Store
88
89
  end # Uploader
89
- end # CarrierWave
90
+ end # CarrierWave
@@ -3,10 +3,11 @@
3
3
  module CarrierWave
4
4
  module Uploader
5
5
  module Versions
6
+ extend ActiveSupport::Concern
6
7
 
7
- depends_on CarrierWave::Uploader::Callbacks
8
+ include CarrierWave::Uploader::Callbacks
8
9
 
9
- setup do
10
+ included do
10
11
  after :cache, :cache_versions!
11
12
  after :store, :store_versions!
12
13
  after :remove, :remove_versions!
@@ -153,4 +154,4 @@ module CarrierWave
153
154
 
154
155
  end # Versions
155
156
  end # Uploader
156
- end # CarrierWave
157
+ end # CarrierWave
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/named_base'
3
+
4
+ class UploaderGenerator < Rails::Generators::NamedBase
5
+ def create_uploader_file
6
+ template 'uploader.rb', File.join('app/uploaders', class_path, "#{file_name}.rb")
7
+ end
8
+
9
+ def self.source_root
10
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
+ end
12
+ end
13
+
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 10
9
- version: 0.4.10
7
+ - 5
8
+ - 0
9
+ - beta2
10
+ version: 0.5.0.beta2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jonas Nicklas
@@ -14,10 +15,25 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-24 00:00:00 +02:00
18
+ date: 2010-07-21 00:00:00 +02:00
18
19
  default_executable:
19
- dependencies: []
20
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activesupport
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 3
31
+ - 0
32
+ - 0
33
+ - beta4
34
+ version: 3.0.0.beta4
35
+ type: :runtime
36
+ version_requirements: *id001
21
37
  description: Upload files in your Ruby applications, map them to a range of ORMs, store them on different backends.
22
38
  email:
23
39
  - jonas.nicklas@gmail.com
@@ -29,9 +45,6 @@ extra_rdoc_files:
29
45
  - README.rdoc
30
46
  files:
31
47
  - lib/carrierwave/compatibility/paperclip.rb
32
- - lib/carrierwave/core_ext/blank.rb
33
- - lib/carrierwave/core_ext/inheritable_attributes.rb
34
- - lib/carrierwave/core_ext/module_setup.rb
35
48
  - lib/carrierwave/mount.rb
36
49
  - lib/carrierwave/orm/activerecord.rb
37
50
  - lib/carrierwave/orm/datamapper.rb
@@ -63,12 +76,9 @@ files:
63
76
  - lib/carrierwave/uploader/versions.rb
64
77
  - lib/carrierwave/uploader.rb
65
78
  - lib/carrierwave.rb
66
- - rails_generators/uploader/templates/uploader.rb
67
- - rails_generators/uploader/uploader_generator.rb
68
- - rails_generators/uploader/USAGE
69
- - merb_generators/uploader_generator.rb
79
+ - lib/generators/templates/uploader.rb
80
+ - lib/generators/uploader_generator.rb
70
81
  - README.rdoc
71
- - Generators
72
82
  has_rdoc: true
73
83
  homepage: http://carrierwave.rubyforge.org
74
84
  licenses: []
@@ -90,11 +100,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
100
  required_rubygems_version: !ruby/object:Gem::Requirement
91
101
  none: false
92
102
  requirements:
93
- - - ">="
103
+ - - ">"
94
104
  - !ruby/object:Gem::Version
95
105
  segments:
96
- - 0
97
- version: "0"
106
+ - 1
107
+ - 3
108
+ - 1
109
+ version: 1.3.1
98
110
  requirements: []
99
111
 
100
112
  rubyforge_project: carrierwave
data/Generators DELETED
@@ -1,4 +0,0 @@
1
- scope 'merb-gen' do
2
- dir = File.join(File.dirname(__FILE__), 'merb_generators/')
3
- Merb.add_generators dir + 'uploader_generator'
4
- end
@@ -1,46 +0,0 @@
1
- # encoding: utf-8
2
-
3
- unless "".respond_to?(:blank?)
4
- # blank? methods for several different class types
5
- class Object
6
- # Returns true if the object is nil or empty (if applicable)
7
- def blank?
8
- nil? || (respond_to?(:empty?) && empty?)
9
- end
10
- end # class Object
11
-
12
- class Numeric
13
- # Numerics can't be blank
14
- def blank?
15
- false
16
- end
17
- end # class Numeric
18
-
19
- class NilClass
20
- # Nils are always blank
21
- def blank?
22
- true
23
- end
24
- end # class NilClass
25
-
26
- class TrueClass
27
- # True is not blank.
28
- def blank?
29
- false
30
- end
31
- end # class TrueClass
32
-
33
- class FalseClass
34
- # False is always blank.
35
- def blank?
36
- true
37
- end
38
- end # class FalseClass
39
-
40
- class String
41
- # Strips out whitespace then tests if the string is empty.
42
- def blank?
43
- strip.empty?
44
- end
45
- end # class String
46
- end
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # Stolen from Rails 3
4
-
5
- # Copyright (c) 2005-2009 David Heinemeier Hansson
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining
8
- # a copy of this software and associated documentation files (the
9
- # "Software"), to deal in the Software without restriction, including
10
- # without limitation the rights to use, copy, modify, merge, publish,
11
- # distribute, sublicense, and/or sell copies of the Software, and to
12
- # permit persons to whom the Software is furnished to do so, subject to
13
- # the following conditions:
14
- #
15
- # The above copyright notice and this permission notice shall be
16
- # included in all copies or substantial portions of the Software.
17
- #
18
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
-
26
- # Retain for backward compatibility. Methods are now included in Class.
27
- class Class
28
- # Defines class-level inheritable attribute reader. Attributes are available to subclasses,
29
- # each subclass has a copy of parent's attribute.
30
- #
31
- # @param *syms<Array[#to_s]> Array of attributes to define inheritable reader for.
32
- # @return <Array[#to_s]> Array of attributes converted into inheritable_readers.
33
- #
34
- # @api public
35
- #
36
- # @todo Do we want to block instance_reader via :instance_reader => false
37
- # @todo It would be preferable that we do something with a Hash passed in
38
- # (error out or do the same as other methods above) instead of silently
39
- # moving on). In particular, this makes the return value of this function
40
- # less useful.
41
- def extlib_inheritable_reader(*ivars)
42
- instance_reader = ivars.pop[:reader] if ivars.last.is_a?(Hash)
43
-
44
- ivars.each do |ivar|
45
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
46
- def self.#{ivar}
47
- return @#{ivar} if self.object_id == #{self.object_id} || defined?(@#{ivar})
48
- ivar = superclass.#{ivar}
49
- return nil if ivar.nil? && !#{self}.instance_variable_defined?("@#{ivar}")
50
- @#{ivar} = ivar && !ivar.is_a?(Module) && !ivar.is_a?(Numeric) && !ivar.is_a?(TrueClass) && !ivar.is_a?(FalseClass) ? ivar.dup : ivar
51
- end
52
- RUBY
53
- unless instance_reader == false
54
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
55
- def #{ivar}
56
- self.class.#{ivar}
57
- end
58
- RUBY
59
- end
60
- end
61
- end unless Class.respond_to?(:extlib_inheritable_reader)
62
-
63
- # Defines class-level inheritable attribute writer. Attributes are available to subclasses,
64
- # each subclass has a copy of parent's attribute.
65
- #
66
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
67
- # define inheritable writer for.
68
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
69
- # @return <Array[#to_s]> An Array of the attributes that were made into inheritable writers.
70
- #
71
- # @api public
72
- #
73
- # @todo We need a style for class_eval <<-HEREDOC. I'd like to make it
74
- # class_eval(<<-RUBY, __FILE__, __LINE__), but we should codify it somewhere.
75
- def extlib_inheritable_writer(*ivars)
76
- instance_writer = ivars.pop[:writer] if ivars.last.is_a?(Hash)
77
- ivars.each do |ivar|
78
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
79
- def self.#{ivar}=(obj)
80
- @#{ivar} = obj
81
- end
82
- RUBY
83
- unless instance_writer == false
84
- self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
85
- def #{ivar}=(obj) self.class.#{ivar} = obj end
86
- RUBY
87
- end
88
- end
89
- end unless Class.respond_to?(:extlib_inheritable_writer)
90
-
91
- # Defines class-level inheritable attribute accessor. Attributes are available to subclasses,
92
- # each subclass has a copy of parent's attribute.
93
- #
94
- # @param *syms<Array[*#to_s, Hash{:instance_writer => Boolean}]> Array of attributes to
95
- # define inheritable accessor for.
96
- # @option syms :instance_writer<Boolean> if true, instance-level inheritable attribute writer is defined.
97
- # @return <Array[#to_s]> An Array of attributes turned into inheritable accessors.
98
- #
99
- # @api public
100
- def extlib_inheritable_accessor(*syms)
101
- extlib_inheritable_reader(*syms)
102
- extlib_inheritable_writer(*syms)
103
- end unless Class.respond_to?(:extlib_inheritable_accessor)
104
- end
@@ -1,51 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # Stolen from Rails 3
4
-
5
- # Copyright (c) 2005-2009 David Heinemeier Hansson
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining
8
- # a copy of this software and associated documentation files (the
9
- # "Software"), to deal in the Software without restriction, including
10
- # without limitation the rights to use, copy, modify, merge, publish,
11
- # distribute, sublicense, and/or sell copies of the Software, and to
12
- # permit persons to whom the Software is furnished to do so, subject to
13
- # the following conditions:
14
- #
15
- # The above copyright notice and this permission notice shall be
16
- # included in all copies or substantial portions of the Software.
17
- #
18
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
-
26
- class Module
27
- attr_accessor :_setup_block
28
- attr_accessor :_dependencies
29
-
30
- def setup(&blk)
31
- @_setup_block = blk
32
- end
33
-
34
- def use(mod)
35
- return if self < mod
36
-
37
- (mod._dependencies || []).each do |dep|
38
- use dep
39
- end
40
- # raise "Circular dependencies" if self < mod
41
- include mod
42
- extend mod.const_get("ClassMethods") if mod.const_defined?("ClassMethods")
43
- class_eval(&mod._setup_block) if mod._setup_block
44
- end
45
-
46
- def depends_on(mod)
47
- return if self < mod
48
- @_dependencies ||= []
49
- @_dependencies << mod
50
- end
51
- end
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Merb
4
- module Generators
5
- class UploaderGenerator < NamedGenerator
6
-
7
- def self.source_root
8
- File.join(File.dirname(__FILE__), '..', '..', 'rails_generators', 'uploader', 'templates')
9
- end
10
-
11
- first_argument :name, :required => true, :desc => "The name of this uploader"
12
-
13
- template :uploader do |t|
14
- t.source = 'uploader.rb'
15
- t.destination = "app/uploaders/#{file_name}_uploader.rb"
16
- end
17
- end
18
-
19
- add :uploader, UploaderGenerator
20
-
21
- end
22
- end
@@ -1,2 +0,0 @@
1
- Description:
2
- Generates a skeleton for a new uploader.
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class UploaderGenerator < Rails::Generator::NamedBase
4
-
5
- def manifest
6
- record do |m|
7
- m.directory 'app/uploaders'
8
- m.template 'uploader.rb', "app/uploaders/#{name.underscore}_uploader.rb"
9
- end
10
- end
11
-
12
- def class_name
13
- name.camelize
14
- end
15
-
16
- protected
17
-
18
- def banner
19
- "Usage: #{$0} uploader UploaderName"
20
- end
21
- end