tramway-core 1.17.1 → 1.17.2.3

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +83 -2
  3. data/app/assets/javascripts/tramway/core/application.js +1 -1
  4. data/app/controllers/tramway/core/application_controller.rb +8 -12
  5. data/app/decorators/tramway/core/application_decorator.rb +16 -28
  6. data/app/decorators/tramway/core/associations/class_helper.rb +13 -13
  7. data/app/decorators/tramway/core/associations/object_helper.rb +31 -3
  8. data/app/decorators/tramway/core/attributes/view_helper.rb +26 -0
  9. data/app/decorators/tramway/core/concerns/attributes_decorator_helper.rb +47 -26
  10. data/app/decorators/tramway/core/delegating/class_helper.rb +9 -0
  11. data/app/forms/tramway/core/application_form.rb +83 -171
  12. data/app/forms/tramway/core/application_forms/association_object_helpers.rb +31 -0
  13. data/app/forms/tramway/core/application_forms/constant_class_actions.rb +7 -0
  14. data/app/forms/tramway/core/application_forms/constant_object_actions.rb +13 -0
  15. data/app/forms/tramway/core/application_forms/properties_object_helper.rb +23 -0
  16. data/app/forms/tramway/core/extendable_form.rb +3 -70
  17. data/app/forms/tramway/core/extendable_forms_helpers/class_builder.rb +34 -0
  18. data/app/forms/tramway/core/extendable_forms_helpers/ignored_properties_helper.rb +11 -0
  19. data/app/forms/tramway/core/extendable_forms_helpers/more_properties_helper.rb +27 -0
  20. data/app/forms/tramway/core/extendable_forms_helpers/properties_helper.rb +16 -0
  21. data/app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb +18 -0
  22. data/app/forms/tramway/core/extendable_forms_helpers/submit/object_helpers.rb +7 -0
  23. data/app/forms/tramway/core/extendable_forms_helpers/validators.rb +40 -0
  24. data/app/helpers/tramway/core/copy_to_clipboard_helper.rb +6 -10
  25. data/app/helpers/tramway/core/title_helper.rb +17 -22
  26. data/app/models/tramway/core/application_record.rb +38 -40
  27. data/app/uploaders/image_defaults.rb +2 -1
  28. data/app/uploaders/photo_uploader.rb +8 -8
  29. data/config/initializers/plurals.rb +2 -2
  30. data/lib/tramway/collection.rb +4 -6
  31. data/lib/tramway/collections.rb +4 -0
  32. data/lib/tramway/collections/helper.rb +15 -14
  33. data/lib/tramway/core.rb +22 -22
  34. data/lib/tramway/core/engine.rb +4 -8
  35. data/lib/tramway/core/generators.rb +4 -0
  36. data/lib/tramway/core/generators/install_generator.rb +17 -17
  37. data/lib/tramway/core/version.rb +1 -1
  38. data/lib/tramway/error.rb +12 -1
  39. data/lib/yaml/errors.yml +35 -0
  40. metadata +20 -3
@@ -5,14 +5,10 @@ require 'tramway/core/application'
5
5
  require 'simple_form'
6
6
  require 'enumerize'
7
7
 
8
- module Tramway
9
- module Core
10
- class Engine < ::Rails::Engine
11
- isolate_namespace Tramway::Core
8
+ class Tramway::Core::Engine < ::Rails::Engine
9
+ isolate_namespace Tramway::Core
12
10
 
13
- config.before_initialize do
14
- config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
15
- end
16
- end
11
+ config.before_initialize do
12
+ config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
17
13
  end
18
14
  end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tramway::Core::Generators
4
+ end
@@ -1,27 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails/generators'
4
+ require 'tramway/core/generators'
4
5
 
5
- module Tramway
6
- module Core
7
- module Generators
8
- class InstallGenerator < ::Rails::Generators::Base
9
- source_root File.expand_path('templates', __dir__)
6
+ class Tramway::Core::Generators::InstallGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path('templates', __dir__)
10
8
 
11
- def run_other_generators
12
- generate 'audited:install'
13
- end
9
+ def run_other_generators
10
+ generate 'audited:install'
11
+ end
14
12
 
15
- def self.next_migration_number(path)
16
- next_migration_number = current_migration_number(path) + 1
17
- ActiveRecord::Migration.next_migration_number next_migration_number
18
- end
13
+ def self.next_migration_number(path)
14
+ next_migration_number = current_migration_number(path) + 1
15
+ ActiveRecord::Migration.next_migration_number next_migration_number
16
+ end
19
17
 
20
- def copy_initializer
21
- copy_file "/#{File.dirname __dir__}/generators/templates/initializers/simple_form.rb", 'config/initializers/simple_form.rb'
22
- copy_file "/#{File.dirname __dir__}/generators/templates/initializers/simple_form_bootstrap.rb", 'config/initializers/simple_form_bootstrap.rb'
23
- end
24
- end
18
+ def copy_initializer
19
+ simple_form_files = %w[simple_form simple_form_bootstrap]
20
+ simple_form_files.each do |file|
21
+ copy_file(
22
+ "/#{File.dirname __dir__}/generators/templates/initializers/#{file}.rb",
23
+ "config/initializers/#{file}.rb"
24
+ )
25
25
  end
26
26
  end
27
27
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.17.1'
5
+ VERSION = '1.17.2.3'
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Tramway::Error < RuntimeError
4
4
  def initialize(*args, plugin: nil, method: nil, message: nil)
5
- @properties ||= {}
5
+ @properties = {}
6
6
  @properties[:plugin] = plugin
7
7
  @properties[:method] = method
8
8
  @properties[:message] = message
@@ -16,4 +16,15 @@ class Tramway::Error < RuntimeError
16
16
  def properties
17
17
  @properties ||= {}
18
18
  end
19
+
20
+ class << self
21
+ def raise_error(*coordinates, **options)
22
+ @errors ||= YAML.load_file("#{Tramway::Core.root}/yaml/errors.yml").with_indifferent_access
23
+ error = @errors.dig(*coordinates)
24
+ options.each do |pair|
25
+ error.gsub!("%{#{pair[0]}}", pair[1].to_s)
26
+ end
27
+ raise error
28
+ end
29
+ end
19
30
  end
@@ -0,0 +1,35 @@
1
+ tramway:
2
+ collections:
3
+ helper:
4
+ collection_list_by:
5
+ there_no_such_collection: "There no such collection named %{name_camelize}. Please create class with self method `list` and extended of `Tramway::Collection`. You should reload your server after creating this collection."
6
+ core:
7
+ title_helper:
8
+ title:
9
+ you_should_set_tramway_core_application: "You should set Tramway::Core::Application class using `::Tramway::Core.initialize_application model_class: #{model_class_name}` in config/initializers/tramway.rb OR maybe you don't have any records of application model"
10
+ application_form:
11
+ initialize:
12
+ polymorphic_class_is_nil: "Polymorphic association class is nil. Maybe, you should write `assocation #{association_name}` after `properties #{association_name}_id, #{association_name}_type`"
13
+ validates:
14
+ you_need_to_set_model_class: 'You need to set `model_class` name while using validations. Just write `self.model_class = YOUR_MODEL_NAME` in the class area.'
15
+ submit:
16
+ looks_like_you_have_method: "Looks like you have method `%{method_name}` in %{model_class}. You should rename it or rename property in %{class_name}"
17
+ params_should_not_be_nil: "ApplicationForm::Params should not be nil"
18
+ model_class:
19
+ there_is_not_model_class: "There is not model class name for %{name}. Should be %{model_class_name} or you can use another class to initialize form object or just initialize form with object."
20
+ concerns:
21
+ attribute_decorator_helper:
22
+ you_should_mount_photo_uploader: "You should mount PhotoUploader to your model. Just add `mount_uploader %{attribute_name}, PhotoUploader` to your model. %{message}"
23
+ associations:
24
+ object_helper:
25
+ please_specify_association_name: "Please, specify `%{association_name}` association class_name in %{object_class} model. For example: `has_many :%{association_name}, class_name: '%{association_class_name}'`"
26
+ class_helper:
27
+ model_does_not_have_association: "Model %{object_class} does not have association named `%{association_name}`"
28
+ application_decorator:
29
+ attributes:
30
+ method_is_reserved_word: "Method `%{attribute_name}` is reserved word. Please, create or delegate method in %{class_name} with another name."
31
+ title:
32
+ please_implement_title: "Please, implement `title` method in a %{class_name} or %{object_class}"
33
+ link:
34
+ method_link_uses_file_attribute: "Method `link` uses `file` attribute of the decorated object. If decorated object doesn't contain `file`, you shouldn't use `link` method."
35
+
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.17.1
4
+ version: 1.17.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
+ - moshiaan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-03-09 00:00:00.000000000 Z
12
+ date: 2020-03-19 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: audited
@@ -357,9 +358,22 @@ files:
357
358
  - app/decorators/tramway/core/application_decorator.rb
358
359
  - app/decorators/tramway/core/associations/class_helper.rb
359
360
  - app/decorators/tramway/core/associations/object_helper.rb
361
+ - app/decorators/tramway/core/attributes/view_helper.rb
360
362
  - app/decorators/tramway/core/concerns/attributes_decorator_helper.rb
363
+ - app/decorators/tramway/core/delegating/class_helper.rb
361
364
  - app/forms/tramway/core/application_form.rb
365
+ - app/forms/tramway/core/application_forms/association_object_helpers.rb
366
+ - app/forms/tramway/core/application_forms/constant_class_actions.rb
367
+ - app/forms/tramway/core/application_forms/constant_object_actions.rb
368
+ - app/forms/tramway/core/application_forms/properties_object_helper.rb
362
369
  - app/forms/tramway/core/extendable_form.rb
370
+ - app/forms/tramway/core/extendable_forms_helpers/class_builder.rb
371
+ - app/forms/tramway/core/extendable_forms_helpers/ignored_properties_helper.rb
372
+ - app/forms/tramway/core/extendable_forms_helpers/more_properties_helper.rb
373
+ - app/forms/tramway/core/extendable_forms_helpers/properties_helper.rb
374
+ - app/forms/tramway/core/extendable_forms_helpers/submit/class_helpers.rb
375
+ - app/forms/tramway/core/extendable_forms_helpers/submit/object_helpers.rb
376
+ - app/forms/tramway/core/extendable_forms_helpers/validators.rb
363
377
  - app/forms/tramway/core/extended_application_form.rb
364
378
  - app/forms/tramway/core/form_creator.rb
365
379
  - app/helpers/tramway/core/copy_to_clipboard_helper.rb
@@ -396,10 +410,12 @@ files:
396
410
  - lib/string.rb
397
411
  - lib/tasks/tramway/core_tasks.rake
398
412
  - lib/tramway/collection.rb
413
+ - lib/tramway/collections.rb
399
414
  - lib/tramway/collections/helper.rb
400
415
  - lib/tramway/core.rb
401
416
  - lib/tramway/core/application.rb
402
417
  - lib/tramway/core/engine.rb
418
+ - lib/tramway/core/generators.rb
403
419
  - lib/tramway/core/generators/install_generator.rb
404
420
  - lib/tramway/core/generators/templates/initializers/simple_form.rb
405
421
  - lib/tramway/core/generators/templates/initializers/simple_form_bootstrap.rb
@@ -407,7 +423,8 @@ files:
407
423
  - lib/tramway/error.rb
408
424
  - lib/tramway/helpers/class_name_helpers.rb
409
425
  - lib/validators/presence_validator.rb
410
- homepage: https://github.com/kalashnikovisme/tramway-core
426
+ - lib/yaml/errors.yml
427
+ homepage: https://github.com/purple-magic/tramway-core
411
428
  licenses:
412
429
  - MIT
413
430
  metadata: {}