cmor_core_frontend 0.0.8.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +19 -0
  4. data/lib/cmor/core/frontend/configuration.rb +11 -0
  5. data/lib/cmor/core/frontend/engine.rb +9 -0
  6. data/lib/cmor/core/frontend/gemspec.rb +41 -0
  7. data/lib/cmor/core/frontend/version.rb +9 -0
  8. data/lib/cmor/core/frontend.rb +10 -0
  9. data/lib/cmor_core_frontend.rb +5 -0
  10. data/lib/generators/cmor/core/frontend/bootstrap4/bootstrap4_generator.rb +31 -0
  11. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/images/frontend/logos/square.svg +34 -0
  12. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/javascripts/frontend/application/keep.js +0 -0
  13. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/javascripts/frontend/application.js +4 -0
  14. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/javascripts/frontend.js +1 -0
  15. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/stylesheets/frontend/application/fonts.css +3 -0
  16. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/stylesheets/frontend/application/layout.css +3 -0
  17. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/stylesheets/frontend/application.css +6 -0
  18. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/stylesheets/frontend/vendor/modern-business.css +27 -0
  19. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/assets/stylesheets/frontend.css +3 -0
  20. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/controllers/frontend/application_controller.rb +22 -0
  21. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/view_helpers/frontend/application_view_helper.rb +62 -0
  22. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_about_us.html.haml +8 -0
  23. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_call_to_action.html.haml +5 -0
  24. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_inline_gallery.html.haml +6 -0
  25. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_our_team.html.haml +29 -0
  26. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_pricing.html.haml +37 -0
  27. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/frontend/application_view_helper/_target_groups.html.haml +27 -0
  28. data/lib/generators/cmor/core/frontend/bootstrap4/templates/app/views/layouts/frontend/application.html.haml +62 -0
  29. data/lib/generators/cmor/core/frontend/bootstrap4/templates/config/initializers/assets.rb +4 -0
  30. data/lib/generators/cmor/core/frontend/bootstrap4/templates/config/locales/de.yml +9 -0
  31. data/lib/generators/cmor/core/frontend/bootstrap4/templates/config/locales/en.yml +9 -0
  32. data/lib/generators/cmor/core/frontend/bootstrap4/templates/config/routes.rb +3 -0
  33. data/lib/generators/cmor/core/frontend/bootstrap4/templates/frontend.gemspec +18 -0
  34. data/lib/generators/cmor/core/frontend/bootstrap4/templates/lib/frontend/engine.rb +6 -0
  35. data/lib/generators/cmor/core/frontend/bootstrap4/templates/lib/frontend/version.rb +4 -0
  36. data/lib/generators/cmor/core/frontend/bootstrap4/templates/lib/frontend.rb +5 -0
  37. data/lib/generators/cmor/core/frontend/install/install_generator.rb +28 -0
  38. data/lib/generators/cmor/core/frontend/install/templates/frontend_controller.rb +2 -0
  39. data/lib/generators/cmor/core/frontend/install/templates/initializer.rb +2 -0
  40. data/lib/generators/cmor/core/frontend/navigation/navigation_generator.rb +70 -0
  41. data/lib/generators/cmor/core/frontend/new/new_generator.rb +80 -0
  42. data/lib/generators/cmor/core/frontend/new/templates/Gemfile +15 -0
  43. data/lib/generators/cmor/core/frontend/new/templates/Guardfile +82 -0
  44. data/lib/generators/cmor/core/frontend/new/templates/MIT-LICENSE +20 -0
  45. data/lib/generators/cmor/core/frontend/new/templates/README.md +28 -0
  46. data/lib/generators/cmor/core/frontend/new/templates/Rakefile +19 -0
  47. data/lib/generators/cmor/core/frontend/new/templates/app/assets/config/foo_bar_manifest.js +1 -0
  48. data/lib/generators/cmor/core/frontend/new/templates/app/assets/javascripts/foo_bar/application/keep.js +0 -0
  49. data/lib/generators/cmor/core/frontend/new/templates/app/assets/javascripts/foo_bar/application.js +2 -0
  50. data/lib/generators/cmor/core/frontend/new/templates/app/assets/javascripts/foo_bar.js +2 -0
  51. data/lib/generators/cmor/core/frontend/new/templates/app/assets/stylesheets/foo_bar/application/keep.css +0 -0
  52. data/lib/generators/cmor/core/frontend/new/templates/app/assets/stylesheets/foo_bar/application.css +3 -0
  53. data/lib/generators/cmor/core/frontend/new/templates/app/assets/stylesheets/foo_bar.css +3 -0
  54. data/lib/generators/cmor/core/frontend/new/templates/app/controllers/foo_bar/application_controller.rb +5 -0
  55. data/lib/generators/cmor/core/frontend/new/templates/app/view_helpers/foo_bar/application_view_helper.rb +4 -0
  56. data/lib/generators/cmor/core/frontend/new/templates/bin/rails +25 -0
  57. data/lib/generators/cmor/core/frontend/new/templates/config/locales/de.yml +1 -0
  58. data/lib/generators/cmor/core/frontend/new/templates/config/locales/en.yml +1 -0
  59. data/lib/generators/cmor/core/frontend/new/templates/config/routes.rb +2 -0
  60. data/lib/generators/cmor/core/frontend/new/templates/foo_bar.gemspec +50 -0
  61. data/lib/generators/cmor/core/frontend/new/templates/initialize_dummy.sh +31 -0
  62. data/lib/generators/cmor/core/frontend/new/templates/lib/foo_bar/configuration.rb +9 -0
  63. data/lib/generators/cmor/core/frontend/new/templates/lib/foo_bar/engine.rb +5 -0
  64. data/lib/generators/cmor/core/frontend/new/templates/lib/foo_bar/version.rb +1 -0
  65. data/lib/generators/cmor/core/frontend/new/templates/lib/foo_bar.rb +6 -0
  66. data/lib/generators/cmor/core/frontend/new/templates/lib/generators/foo_bar/install/install_generator.rb +25 -0
  67. data/lib/generators/cmor/core/frontend/new/templates/lib/generators/foo_bar/install/templates/initializer.rb +7 -0
  68. data/lib/generators/cmor/core/frontend/new/templates/lib/generators/foo_bar/install/templates/routes.source +3 -0
  69. data/lib/generators/cmor/core/frontend/new/templates/lib/tasks/foo_bar_tasks.rake +4 -0
  70. data/lib/generators/cmor/core/frontend/new/templates/spec/lib/foo_bar/version_spec.rb +5 -0
  71. data/lib/generators/cmor/core/frontend/new/templates/spec/rails_helper.rb +62 -0
  72. data/lib/generators/cmor/core/frontend/new/templates/spec/spec_helper.rb +98 -0
  73. data/lib/generators/cmor/core/frontend/new/templates/spec/support/capybara.rb +1 -0
  74. data/lib/generators/cmor/core/frontend/new/templates/spec/support/factory_bot.rb +9 -0
  75. data/lib/generators/cmor/core/frontend/new/templates/spec/support/rao-shoulda_matchers.rb +5 -0
  76. data/lib/generators/cmor/core/frontend/resource_controller/resource_controller_generator.rb +46 -0
  77. data/lib/generators/cmor/core/frontend/resource_controller/templates/resource_controller.rb +18 -0
  78. data/lib/generators/cmor/core/frontend/resources_controller/resources_controller_generator.rb +54 -0
  79. data/lib/generators/cmor/core/frontend/resources_controller/templates/resources_controller.rb +18 -0
  80. data/lib/generators/cmor/core/frontend/service_controller/service_controller_generator.rb +42 -0
  81. data/lib/generators/cmor/core/frontend/service_controller/templates/service_controller.rb +18 -0
  82. metadata +403 -0
@@ -0,0 +1,28 @@
1
+ module Cmor
2
+ module Core
3
+ module Frontend
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ desc 'Installs the initializer, routes and itsf_backend integration'
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ attr_reader :base_controller_class_name
11
+
12
+ def initialize(*args)
13
+ super
14
+ @base_controller_class_name = ENV.fetch('CMOR_CORE_FRONTEND_BASE_CONTROLLER_CLASS_NAME') { '::ApplicationController' }
15
+ end
16
+
17
+ def generate_controller
18
+ copy_file 'frontend_controller.rb', 'app/controllers/frontend_controller.rb'
19
+ end
20
+
21
+ def generate_initializer
22
+ template 'initializer.rb', 'config/initializers/cmor_core_frontend.rb'
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,2 @@
1
+ class FrontendController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ Cmor::Core::Frontend.configure do |config|
2
+ end
@@ -0,0 +1,70 @@
1
+ module Cmor
2
+ module Core
3
+ module Frontend
4
+ module Generators
5
+ class NavigationGenerator < Rails::Generators::Base
6
+ desc 'Creates a navigation'
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ class_option :name, type: 'string', default: 'main', aliases: '-n'
11
+ class_option :locales, type: 'array', default: I18n.available_locales, aliases: '-l'
12
+ class_option :force, type: 'boolean', default: false, aliases: '-f'
13
+ class_option :modules, type: 'array', default: %w(Cmor::Blog::Engine Cmor::Galleries::Engine Cmor::Files::Engine Cmor::Tags::Engine Cmor::Contact::Engine), aliases: '-m'
14
+
15
+
16
+ def generate_navigation
17
+ ActiveRecord::Base.transaction do
18
+ remove_navigation if force?
19
+ locales.each do |locale|
20
+ navigation = find_or_create_navigation(locale)
21
+ modules.each do |modyule|
22
+ find_or_create_navigation_item(navigation, modyule)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def modules
31
+ @modules ||= options[:modules]
32
+ end
33
+
34
+ def force?
35
+ options[:force]
36
+ end
37
+
38
+ def remove_navigation
39
+ Cmor::Cms::Navigation.where(name: name, locale: locales).destroy_all
40
+ end
41
+
42
+ def locales
43
+ @locales ||= options['locales']
44
+ end
45
+
46
+ def name
47
+ @name ||= options['name']
48
+ end
49
+
50
+ def find_or_create_navigation(locale)
51
+ Cmor::Cms::Navigation.find_or_create_by!(name: name, locale: locale)
52
+ end
53
+
54
+ def find_or_create_navigation_item(navigation, modyule)
55
+ name = nil
56
+ url = nil
57
+ I18n.with_locale(navigation.locale) do
58
+ name = I18n.t("classes.#{modyule.underscore}")
59
+ url = "/" + I18n.locale.to_s + "/" + I18n.t("routes.#{modyule.underscore}".gsub('/', '_'))
60
+ end
61
+ Cmor::Cms::NavigationItem.where(navigation: navigation, name: name, key: modyule).first_or_initialize.tap do |ni|
62
+ ni.url = url
63
+ ni.save!
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,80 @@
1
+ module Cmor
2
+ module Core
3
+ module Frontend
4
+ module Generators
5
+ class NewGenerator < Rails::Generators::Base
6
+ desc 'Installs the initializer, routes and itsf_backend integration'
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ class_option :name, type: 'string', aliases: '-n' # Cmor::Faq
11
+ class_option :author, type: 'string', aliases: '-ga'
12
+ class_option :email, type: 'string', aliases: '-gn'
13
+
14
+ def generate_engine
15
+ empty_directory "engines/#{flat_path}"
16
+ templates_dir = "#{__dir__}/templates/"
17
+ Dir.glob("#{templates_dir}**/*").each do |f|
18
+ next unless File.file?(f)
19
+ f.gsub!(templates_dir, '')
20
+ target = build_target_filename(f)
21
+ template f, "engines/#{flat_path}/#{target}"
22
+ end
23
+ end
24
+
25
+ def set_permissions
26
+ chmod "engines/#{flat_path}/initialize_dummy.sh", 0755
27
+ end
28
+
29
+ private
30
+
31
+ def build_target_filename(f)
32
+ if flat_filename_exceptions.include?(f)
33
+ f.gsub("foo_bar", flat_path)
34
+ else
35
+ f.gsub('foo_bar', nested_path)
36
+ end
37
+ end
38
+
39
+ def name
40
+ @name ||= options[:name]
41
+ end
42
+
43
+ def nested_modules(options = nil)
44
+ content = options.delete(:content)
45
+ nm = ''
46
+ s = name.split('::')
47
+ nm << s.each_with_index.collect { |p,i| "#{ ' ' * (2 * i) }module #{p}\n" }.join
48
+ nm << content.indent(s.size * 2) if content.present?
49
+ (s.size - 1).downto(0) { |i| nm << "#{ ' ' * (2 * i) }end\n" }
50
+ return nm
51
+ end
52
+
53
+ def nested_path
54
+ @nested_path ||= name.underscore
55
+ end
56
+
57
+ def flat_path
58
+ @flat_path ||= name.underscore.gsub('/', '_')
59
+ end
60
+
61
+ def flat_filename_exceptions
62
+ %w(foo_bar.gemspec app/assets/javascripts/foo_bar.js app/assets/stylesheets/foo_bar.css lib/foo_bar.rb)
63
+ end
64
+
65
+ def gemspec
66
+ {
67
+ name: flat_path,
68
+ authors: "[\"#{options[:author] || `git config user.name`.chomp }\"]",
69
+ email: "[\"#{options[:email] || `git config user.email`.chomp }\"]"
70
+ }
71
+ end
72
+
73
+ def cmor_version
74
+ Cmor::VERSION
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in <%= name.underscore %>.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
@@ -0,0 +1,82 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :bundler do
19
+ require 'guard/bundler'
20
+ require 'guard/bundler/verify'
21
+ helper = Guard::Bundler::Verify.new
22
+
23
+ files = ['Gemfile']
24
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
25
+
26
+ # Assume files are symlinked from somewhere
27
+ files.each { |file| watch(helper.real_path(file)) }
28
+ end
29
+
30
+ # Note: The cmd option is now required due to the increasing number of ways
31
+ # rspec may be run, below are examples of the most common uses.
32
+ # * bundler: 'bundle exec rspec'
33
+ # * bundler binstubs: 'bin/rspec'
34
+ # * spring: 'bin/rspec' (This will use spring if running and you have
35
+ # installed the spring binstubs per the docs)
36
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
37
+ # * 'just' rspec: 'rspec'
38
+
39
+ guard :rspec, cmd: "bundle exec rspec" do
40
+ require "guard/rspec/dsl"
41
+ dsl = Guard::RSpec::Dsl.new(self)
42
+
43
+ # Feel free to open issues for suggestions and improvements
44
+
45
+ # RSpec files
46
+ rspec = dsl.rspec
47
+ watch(rspec.spec_helper) { rspec.spec_dir }
48
+ watch(rspec.spec_support) { rspec.spec_dir }
49
+ watch(rspec.spec_files)
50
+
51
+ # Ruby files
52
+ ruby = dsl.ruby
53
+ dsl.watch_spec_files_for(ruby.lib_files)
54
+
55
+ # Rails files
56
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
57
+ dsl.watch_spec_files_for(rails.app_files)
58
+ dsl.watch_spec_files_for(rails.views)
59
+
60
+ watch(rails.controllers) do |m|
61
+ [
62
+ rspec.spec.call("routing/#{m[1]}_routing"),
63
+ rspec.spec.call("controllers/#{m[1]}_controller"),
64
+ rspec.spec.call("acceptance/#{m[1]}")
65
+ ]
66
+ end
67
+
68
+ # Rails config changes
69
+ watch(rails.spec_helper) { rspec.spec_dir }
70
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
71
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
72
+
73
+ # Capybara features specs
74
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
75
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
76
+
77
+ # Turnip features and steps
78
+ watch(%r{^spec/acceptance/(.+)\.feature$})
79
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
80
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
81
+ end
82
+ end
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Roberto Vasquez Angel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # <%= name %>
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem '<%= name.underscore %>'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install <%= name.underscore %>
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = '<%= name %>'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ require 'rails/dummy/tasks'
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/<%= name.underscore %> .css
@@ -0,0 +1,2 @@
1
+ //= require ./<%= nested_path %>/application
2
+
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require ./<%= nested_path %>/application
3
+ */
@@ -0,0 +1,5 @@
1
+ module <%= name %>
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module <%= name %>
2
+ class ApplicationViewHelper < Rao::ViewHelper::Base
3
+ end
4
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/<%= name.underscore %>/engine', __dir__)
7
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require "rails"
14
+ # Pick the frameworks you want:
15
+ require "active_model/railtie"
16
+ require "active_job/railtie"
17
+ require "active_record/railtie"
18
+ require "active_storage/engine"
19
+ require "action_controller/railtie"
20
+ require "action_mailer/railtie"
21
+ require "action_view/railtie"
22
+ require "action_cable/engine"
23
+ require "sprockets/railtie"
24
+ # require "rails/test_unit/railtie"
25
+ require 'rails/engine/commands'
@@ -0,0 +1,2 @@
1
+ <%= name %>::Engine.routes.draw do
2
+ end
@@ -0,0 +1,50 @@
1
+ $:.push File.expand_path("lib", __dir__)
2
+
3
+ # Maintain your gem's version:
4
+ require "<%= name.underscore %>/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "<%= gemspec[:name] %>"
9
+ spec.version = <%= name %>::VERSION
10
+ spec.authors = <%= gemspec[:authors] %>
11
+ spec.email = <%= gemspec[:email] %>
12
+ spec.homepage = "https://content-management-on-rails/cmor"
13
+ spec.summary = "<%= name %> Module."
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = 'https://rubygems.com'
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
+ end
24
+
25
+ spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
26
+
27
+ # Defaults
28
+ spec.add_dependency "rails", ">= 5.2.0"
29
+ spec.add_dependency "cmor", "= <%= cmor_version %>"
30
+ spec.add_dependency "cmor_core_frontend", "= <%= cmor_version %>"
31
+
32
+ spec.add_development_dependency "sqlite3", '~> 1.3.6'
33
+
34
+ spec.add_development_dependency 'capybara'
35
+ spec.add_development_dependency 'coveralls'
36
+ spec.add_development_dependency 'git_log_generator'
37
+ spec.add_development_dependency 'guard-bundler'
38
+ spec.add_development_dependency 'guard-rails'
39
+ spec.add_development_dependency 'guard-rspec'
40
+ spec.add_development_dependency 'pry-rails'
41
+ spec.add_development_dependency 'rao-shoulda_matchers'
42
+ spec.add_development_dependency 'rails-dummy'
43
+ spec.add_development_dependency 'rails-i18n'
44
+ spec.add_development_dependency 'rspec-rails'
45
+ spec.add_development_dependency 'factory_bot_rails' # This has to be after rspec-rails
46
+ spec.add_development_dependency 'rubocop'
47
+ spec.add_development_dependency 'shoulda-matchers'
48
+ spec.add_development_dependency 'simplecov'
49
+ spec.add_development_dependency 'simplecov-console'
50
+ end
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+ GEM_NAME=${PWD##*/}
3
+ INSTALL_NAME=${GEM_NAME//cmor_/cmor\:}
4
+
5
+ # Delete old dummy app
6
+ rm -rf spec/dummy
7
+
8
+ # Generate new dummy app
9
+ DISABLE_MIGRATE=true rake dummy:app
10
+ rm spec/dummy/.ruby-version
11
+
12
+ # Satisfy prerequisites
13
+ cd spec/dummy
14
+
15
+ # Add ActiveStorage
16
+ rails active_storage:install
17
+
18
+ # I18n configuration
19
+ touch config/initializers/i18n.rb
20
+ echo "Rails.application.config.i18n.available_locales = [:en, :de]" >> config/initializers/i18n.rb
21
+ echo "Rails.application.config.i18n.default_locale = :de" >> config/initializers/i18n.rb
22
+
23
+ # I18n routing
24
+ touch config/initializers/route_translator.rb
25
+ echo "RouteTranslator.config do |config|" >> config/initializers/route_translator.rb
26
+ echo " config.force_locale = true" >> config/initializers/route_translator.rb
27
+ echo "end" >> config/initializers/route_translator.rb
28
+
29
+ # Install
30
+ rails generate $INSTALL_NAME:install
31
+ rails $GEM_NAME:install:migrations db:migrate db:test:prepare
@@ -0,0 +1,9 @@
1
+ module <%= name %>
2
+ module Configuration
3
+ def configure
4
+ yield self
5
+ end
6
+
7
+ mattr_accessor(:base_controller) { '::FrontendController' }
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module <%= name %>
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace <%= name %>
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ <%= nested_modules(content: "VERSION = '0.0.1'.freeze\n") %>
@@ -0,0 +1,6 @@
1
+ require "cmor_core_frontend"
2
+
3
+ require "<%= name.underscore %>/configuration"
4
+ require "<%= name.underscore %>/engine"
5
+
6
+ <%= nested_modules(content: "extend Configuration\n") %>
@@ -0,0 +1,25 @@
1
+ module <%= name %>
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Generates the initializer'
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ attr_reader :base_controller_class_name
9
+
10
+ def initialize(*args)
11
+ super
12
+ @base_controller_class_name = ENV.fetch('BASE_CONTROLLER_CLASS_NAME') { '::ApplicationController' }
13
+ end
14
+
15
+ def generate_initializer
16
+ template 'initializer.rb', 'config/initializers/<%= flat_path %>.rb'
17
+ end
18
+
19
+ def generate_routes
20
+ route File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
21
+ end
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,7 @@
1
+ <%= name %>.configure do |config|
2
+ # Set the base controller for the page controller
3
+ #
4
+ # Default: config.base_controller = '<%%= base_controller_class_name %>'
5
+ #
6
+ config.base_controller = '<%%= base_controller_class_name %>'
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :<%= name.underscore %> do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe <%= name %> do
4
+ it { expect(described_class).to be_const_defined('VERSION') }
5
+ end
@@ -0,0 +1,62 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ require 'spec_helper'
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+ require File.expand_path('../dummy/config/environment', __FILE__)
5
+ # Prevent database truncation if the environment is production
6
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
7
+ require 'rspec/rails'
8
+ # Add additional requires below this line. Rails is not loaded until this point!
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc, in
11
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
12
+ # run as spec files by default. This means that files in spec/support that end
13
+ # in _spec.rb will both be required and run as specs, causing the specs to be
14
+ # run twice. It is recommended that you do not name files matching this glob to
15
+ # end with _spec.rb. You can configure this pattern with the --pattern
16
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
17
+ #
18
+ # The following line is provided for convenience purposes. It has the downside
19
+ # of increasing the boot-up time by auto-requiring all files in the support
20
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
+ # require only the support files necessary.
22
+ #
23
+ # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
24
+ Dir[<%= name %>::Engine.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
25
+
26
+ # Checks for pending migrations and applies them before tests are run.
27
+ # If you are not using ActiveRecord, you can remove these lines.
28
+ # begin
29
+ # ActiveRecord::Migration.maintain_test_schema!
30
+ # rescue ActiveRecord::PendingMigrationError => e
31
+ # puts e.to_s.strip
32
+ # exit 1
33
+ # end
34
+ RSpec.configure do |config|
35
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
36
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
37
+
38
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
39
+ # examples within a transaction, remove the following line or assign false
40
+ # instead of true.
41
+ config.use_transactional_fixtures = true
42
+
43
+ # RSpec Rails can automatically mix in different behaviours to your tests
44
+ # based on their file location, for example enabling you to call `get` and
45
+ # `post` in specs under `spec/controllers`.
46
+ #
47
+ # You can disable this behaviour by removing the line below, and instead
48
+ # explicitly tag your specs with their type, e.g.:
49
+ #
50
+ # RSpec.describe UsersController, :type => :controller do
51
+ # # ...
52
+ # end
53
+ #
54
+ # The different available types are documented in the features, such as in
55
+ # https://relishapp.com/rspec/rspec-rails/docs
56
+ config.infer_spec_type_from_file_location!
57
+
58
+ # Filter lines from Rails gems in backtraces.
59
+ config.filter_rails_from_backtrace!
60
+ # arbitrary gems may also be filtered via:
61
+ # config.filter_gems_from_backtrace("gem name")
62
+ end