mongo_mapper_ext 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. data/Rakefile +2 -2
  2. data/lib/mongo_mapper_ext/carrier_wave.rb +4 -2
  3. data/lib/mongo_mapper_ext/carrier_wave/mongo_mapper/plugins/mount_uploader.rb +31 -0
  4. data/lib/mongo_mapper_ext/carrier_wave/mongo_mapper/plugins/mount_uploaders.rb +137 -0
  5. data/lib/mongo_mapper_ext/gems.rb +6 -7
  6. data/lib/mongo_mapper_ext/mongo_mapper.rb +12 -9
  7. data/lib/mongo_mapper_ext/mongo_mapper/fixes.rb +13 -21
  8. data/lib/mongo_mapper_ext/mongo_mapper/hacks.rb +59 -0
  9. data/lib/mongo_mapper_ext/mongo_mapper/plugins/attribute_cache.rb +14 -18
  10. data/lib/mongo_mapper_ext/mongo_mapper/plugins/attribute_convertors.rb +69 -73
  11. data/lib/mongo_mapper_ext/mongo_mapper/plugins/belongs_to_with_counter_cache.rb +33 -37
  12. data/lib/mongo_mapper_ext/mongo_mapper/plugins/custom_scope.rb +67 -71
  13. data/lib/mongo_mapper_ext/mongo_mapper/plugins/db_config.rb +27 -24
  14. data/lib/mongo_mapper_ext/mongo_mapper/plugins/micelaneous.rb +46 -50
  15. data/lib/mongo_mapper_ext/rad.rb +3 -0
  16. data/lib/mongo_mapper_ext/rad/file_uploader.rb +21 -23
  17. data/readme.md +1 -1
  18. data/spec/carrier_wave/carrier_wave_spec.rb +82 -27
  19. data/spec/mongo_mapper/mongo_mapper_spec.rb +28 -27
  20. data/spec/rad/uploading_spec.rb +1 -1
  21. metadata +106 -112
  22. data/lib/mongo_mapper_ext/carrier_wave/mongo_mapper/plugins/carrier_wave.rb +0 -41
  23. data/lib/mongo_mapper_ext/mongo_mapper/locales/activemodel/ru.yml +0 -27
  24. data/lib/mongo_mapper_ext/mongo_mapper/locales/mongo_mapper/en.yml +0 -4
  25. data/lib/mongo_mapper_ext/mongo_mapper/locales/mongo_mapper/ru.yml +0 -4
  26. data/lib/mongo_mapper_ext/mongo_mapper/logging.rb +0 -75
@@ -1,41 +0,0 @@
1
- #
2
- # mount_uploader
3
- #
4
- module MongoMapper
5
- module Plugins
6
- module CarrierWave
7
- extend ActiveSupport::Concern
8
-
9
- module ClassMethods
10
- include ::CarrierWave::Mount
11
- ##
12
- # See +CarrierWave::Mount#mount_uploader+ for documentation
13
- #
14
- def mount_uploader(column, uploader, options={}, &block)
15
- define_key column, uploader, options
16
-
17
- super
18
-
19
- alias_method :read_uploader, :read_attribute
20
- alias_method :write_uploader, :write_attribute
21
-
22
- include ::CarrierWave::Validations::ActiveModel
23
-
24
- validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
25
- validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
26
-
27
- after_save "store_#{column}!".to_sym
28
- before_save "write_#{column}_identifier".to_sym
29
- after_destroy "remove_#{column}!".to_sym
30
- end
31
-
32
- protected
33
- def define_key column, uploader, options
34
- options[:mount_on] ||= "#{column}_filename"
35
- name = options[:mount_on]
36
- key name
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,27 +0,0 @@
1
- ru:
2
- errors:
3
- # The default format to use in full error messages.
4
- format: "%{attribute} %{message}"
5
-
6
- # The values :model, :attribute and :value are always available for interpolation
7
- # The value :count is available when applicable. Can be used for pluralization.
8
- messages:
9
- inclusion: "недопустимое значение"
10
- exclusion: "недопустимо"
11
- invalid: "неверно"
12
- confirmation: "не совпадает с подтверждением"
13
- accepted: "долно быть принято"
14
- empty: "не может быть пустым"
15
- blank: "не может быть пустым"
16
- too_long: "слишком длинно (максимально допустимо %{count})"
17
- too_short: "слищком коротко (минимально допустимо %{count})"
18
- wrong_length: "неверная длинна (должно быть %{count})"
19
- not_a_number: "не номер"
20
- not_an_integer: "долно быть целочисленно"
21
- greater_than: "должно быть больше чем %{count}"
22
- greater_than_or_equal_to: "должно быть больше чем или равно %{count}"
23
- equal_to: "должно быть равно %{count}"
24
- less_than: "должно быть меньше чем %{count}"
25
- less_than_or_equal_to: "должно быть меньше чем или равно %{count}"
26
- odd: "должно быть не четно"
27
- even: "должно быть четно"
@@ -1,4 +0,0 @@
1
- en:
2
- errors:
3
- messages:
4
- taken: "has already been taken"
@@ -1,4 +0,0 @@
1
- ru:
2
- errors:
3
- messages:
4
- taken: "уже занято"
@@ -1,75 +0,0 @@
1
- #
2
- # Custom Logger
3
- #
4
- MongoMapper.class_eval do
5
- class << self
6
-
7
- def logger
8
- unless @logger
9
- @logger = if "irb" == $0
10
- Logger.new(STDOUT)
11
- else
12
- if defined?(Rails)
13
- Rails.test? ? Logger.new(nil) : Rails.logger
14
- else
15
- Logger.new(STDOUT)
16
- end
17
- end
18
- end
19
- @logger
20
- end
21
-
22
- def logger= logger
23
- @logger = logger
24
- end
25
-
26
- end
27
- end
28
-
29
-
30
- #
31
- # silence logging
32
- #
33
- Mongo::Connection.class_eval do
34
- attr_writer :logger
35
- end
36
-
37
- MongoMapper.class_eval do
38
- def self.temporary_silince_logger &block
39
- logger, nil_logger = self.logger, Logger.new(nil)
40
-
41
- begin
42
- MongoMapper.logger = nil_logger
43
- connections.each do |name, connection|
44
- connection.logger = nil_logger
45
- end
46
- block.call
47
- ensure
48
- MongoMapper.logger = logger
49
- connections.each do |name, connection|
50
- connection.logger = logger
51
- end
52
- end
53
- end
54
-
55
- def self.use_database database_alias
56
- database_alias = database_alias.to_s
57
- raise "unknown database alias :#{database_alias}" unless MongoMapper.db_config.include? database_alias
58
- MongoMapper.connection = MongoMapper.connections['default']
59
- MongoMapper.database = MongoMapper.db_config['default']['name']
60
- end
61
- end
62
-
63
-
64
- #
65
- # Silence index creation
66
- #
67
- MongoMapper::Plugins::Indexes::ClassMethods.class_eval do
68
- def ensure_index_with_silent_logger *args
69
- MongoMapper.temporary_silince_logger do
70
- ensure_index_without_silent_logger *args
71
- end
72
- end
73
-
74
- alias_method_chain :ensure_index, :silent_logger
75
- end