jabysoft-base 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +180 -0
  7. data/LICENSE +21 -0
  8. data/README.md +37 -0
  9. data/Rakefile +6 -0
  10. data/app/assets/javascripts/jabysoft.js +1 -0
  11. data/app/assets/stylesheets/jabysoft.sass +42 -0
  12. data/app/controllers/base_controller.rb +111 -0
  13. data/app/helpers/base_helper.rb +63 -0
  14. data/app/helpers/devise_helper.rb +17 -0
  15. data/app/helpers/links_helper.rb +84 -0
  16. data/app/helpers/render_helper.rb +19 -0
  17. data/app/models/concerns/extension_model_behaviour.rb +16 -0
  18. data/app/models/concerns/searchable_behaviour.rb +47 -0
  19. data/app/views/layouts/admin.html.haml +46 -0
  20. data/app/views/layouts/application.html.haml +31 -0
  21. data/app/views/shared/_datepicker_field.html.haml +9 -0
  22. data/app/views/shared/_layout.html.haml +7 -0
  23. data/app/views/shared/_messages.html.haml +7 -0
  24. data/app/views/shared/_panel.html.haml +5 -0
  25. data/app/views/shared/_search_form.html.haml +6 -0
  26. data/app/views/shared/form/_error_messages.html.haml +6 -0
  27. data/app/views/shared/modals/_delete_confirmation.html.haml +17 -0
  28. data/bin/console +14 -0
  29. data/bin/setup +8 -0
  30. data/config/locales/en.yml +35 -0
  31. data/config/locales/pt-BR.yml +35 -0
  32. data/jabysoft-base.gemspec +37 -0
  33. data/lib/generators/haml/scaffold/scaffold_generator.rb +36 -0
  34. data/lib/generators/jabysoft/setup/USAGE +19 -0
  35. data/lib/generators/jabysoft/setup/setup_generator.rb +57 -0
  36. data/lib/generators/jabysoft/setup/templates/.rspec +3 -0
  37. data/lib/generators/jabysoft/setup/templates/Gemfile +48 -0
  38. data/lib/generators/jabysoft/setup/templates/assets/stylesheets/base.scss +24 -0
  39. data/lib/generators/jabysoft/setup/templates/assets/stylesheets/bootstrap-variables.scss +875 -0
  40. data/lib/generators/jabysoft/setup/templates/layouts/admin.html.haml +46 -0
  41. data/lib/generators/jabysoft/setup/templates/layouts/application.html.haml +31 -0
  42. data/lib/generators/jabysoft/setup/templates/spec/rails_helper.rb +92 -0
  43. data/lib/generators/jabysoft/setup/templates/spec/spec_helper.rb +97 -0
  44. data/lib/generators/rspec/scaffold/scaffold_generator.rb +167 -0
  45. data/lib/jabysoft/base/version.rb +5 -0
  46. data/lib/jabysoft/base.rb +16 -0
  47. data/lib/templates/haml/scaffold/_form.html.haml +14 -0
  48. data/lib/templates/haml/scaffold/_index.html.haml +25 -0
  49. data/lib/templates/haml/scaffold/edit.html.haml +1 -0
  50. data/lib/templates/haml/scaffold/index.html.haml +1 -0
  51. data/lib/templates/haml/scaffold/new.html.haml +1 -0
  52. data/lib/templates/haml/scaffold/show.html.haml +1 -0
  53. data/lib/templates/rails/scaffold_controller/controller.rb +29 -0
  54. data/lib/templates/rspec/scaffold/controller_spec.rb +148 -0
  55. data/lib/templates/rspec/scaffold/model_spec.rb +14 -0
  56. data/lib/templates/rspec/scaffold/request_spec.rb +10 -0
  57. data/lib/templates/rspec/scaffold/routing_spec.rb +44 -0
  58. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
  59. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
  60. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  61. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
  62. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
  63. data/vendor/assets/images/.keep +0 -0
  64. data/vendor/assets/javascripts/bootstrap/affix.js +162 -0
  65. data/vendor/assets/javascripts/bootstrap/alert.js +94 -0
  66. data/vendor/assets/javascripts/bootstrap/button.js +120 -0
  67. data/vendor/assets/javascripts/bootstrap/carousel.js +237 -0
  68. data/vendor/assets/javascripts/bootstrap/collapse.js +211 -0
  69. data/vendor/assets/javascripts/bootstrap/dropdown.js +165 -0
  70. data/vendor/assets/javascripts/bootstrap/modal.js +337 -0
  71. data/vendor/assets/javascripts/bootstrap/popover.js +108 -0
  72. data/vendor/assets/javascripts/bootstrap/scrollspy.js +172 -0
  73. data/vendor/assets/javascripts/bootstrap/tab.js +155 -0
  74. data/vendor/assets/javascripts/bootstrap/tooltip.js +514 -0
  75. data/vendor/assets/javascripts/bootstrap/transition.js +59 -0
  76. data/vendor/assets/javascripts/bootstrap-sprockets.js +12 -0
  77. data/vendor/assets/javascripts/bootstrap.js +2363 -0
  78. data/vendor/assets/javascripts/bootstrap.min.js +7 -0
  79. data/vendor/assets/stylesheets/_bootstrap-compass.scss +9 -0
  80. data/vendor/assets/stylesheets/_bootstrap-mincer.scss +19 -0
  81. data/vendor/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
  82. data/vendor/assets/stylesheets/_bootstrap.scss +56 -0
  83. data/vendor/assets/stylesheets/bootstrap/_alerts.scss +73 -0
  84. data/vendor/assets/stylesheets/bootstrap/_badges.scss +68 -0
  85. data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +28 -0
  86. data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +244 -0
  87. data/vendor/assets/stylesheets/bootstrap/_buttons.scss +168 -0
  88. data/vendor/assets/stylesheets/bootstrap/_carousel.scss +270 -0
  89. data/vendor/assets/stylesheets/bootstrap/_close.scss +36 -0
  90. data/vendor/assets/stylesheets/bootstrap/_code.scss +69 -0
  91. data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +37 -0
  92. data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +216 -0
  93. data/vendor/assets/stylesheets/bootstrap/_forms.scss +617 -0
  94. data/vendor/assets/stylesheets/bootstrap/_glyphicons.scss +307 -0
  95. data/vendor/assets/stylesheets/bootstrap/_grid.scss +84 -0
  96. data/vendor/assets/stylesheets/bootstrap/_input-groups.scss +171 -0
  97. data/vendor/assets/stylesheets/bootstrap/_jumbotron.scss +54 -0
  98. data/vendor/assets/stylesheets/bootstrap/_labels.scss +66 -0
  99. data/vendor/assets/stylesheets/bootstrap/_list-group.scss +130 -0
  100. data/vendor/assets/stylesheets/bootstrap/_media.scss +66 -0
  101. data/vendor/assets/stylesheets/bootstrap/_mixins.scss +40 -0
  102. data/vendor/assets/stylesheets/bootstrap/_modals.scss +150 -0
  103. data/vendor/assets/stylesheets/bootstrap/_navbar.scss +662 -0
  104. data/vendor/assets/stylesheets/bootstrap/_navs.scss +242 -0
  105. data/vendor/assets/stylesheets/bootstrap/_normalize.scss +424 -0
  106. data/vendor/assets/stylesheets/bootstrap/_pager.scss +54 -0
  107. data/vendor/assets/stylesheets/bootstrap/_pagination.scss +89 -0
  108. data/vendor/assets/stylesheets/bootstrap/_panels.scss +271 -0
  109. data/vendor/assets/stylesheets/bootstrap/_popovers.scss +131 -0
  110. data/vendor/assets/stylesheets/bootstrap/_print.scss +101 -0
  111. data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +87 -0
  112. data/vendor/assets/stylesheets/bootstrap/_responsive-embed.scss +35 -0
  113. data/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +179 -0
  114. data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +161 -0
  115. data/vendor/assets/stylesheets/bootstrap/_tables.scss +234 -0
  116. data/vendor/assets/stylesheets/bootstrap/_theme.scss +291 -0
  117. data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +38 -0
  118. data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +101 -0
  119. data/vendor/assets/stylesheets/bootstrap/_type.scss +298 -0
  120. data/vendor/assets/stylesheets/bootstrap/_utilities.scss +55 -0
  121. data/vendor/assets/stylesheets/bootstrap/_variables.scss +874 -0
  122. data/vendor/assets/stylesheets/bootstrap/_wells.scss +29 -0
  123. data/vendor/assets/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
  124. data/vendor/assets/stylesheets/bootstrap/mixins/_background-variant.scss +12 -0
  125. data/vendor/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
  126. data/vendor/assets/stylesheets/bootstrap/mixins/_buttons.scss +65 -0
  127. data/vendor/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
  128. data/vendor/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
  129. data/vendor/assets/stylesheets/bootstrap/mixins/_forms.scss +88 -0
  130. data/vendor/assets/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
  131. data/vendor/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
  132. data/vendor/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
  133. data/vendor/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
  134. data/vendor/assets/stylesheets/bootstrap/mixins/_image.scss +33 -0
  135. data/vendor/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
  136. data/vendor/assets/stylesheets/bootstrap/mixins/_list-group.scss +32 -0
  137. data/vendor/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
  138. data/vendor/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
  139. data/vendor/assets/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
  140. data/vendor/assets/stylesheets/bootstrap/mixins/_pagination.scss +24 -0
  141. data/vendor/assets/stylesheets/bootstrap/mixins/_panels.scss +24 -0
  142. data/vendor/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
  143. data/vendor/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
  144. data/vendor/assets/stylesheets/bootstrap/mixins/_reset-text.scss +18 -0
  145. data/vendor/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
  146. data/vendor/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
  147. data/vendor/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
  148. data/vendor/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
  149. data/vendor/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
  150. data/vendor/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +12 -0
  151. data/vendor/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
  152. data/vendor/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -0
  153. metadata +308 -0
@@ -0,0 +1,46 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ %title= t('title.administration')
6
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
7
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
8
+ = csrf_meta_tags
9
+ %body
10
+ %nav.navbar.navbar-default.navbar-fixed-top
11
+ .container
12
+ = link_to t('admin_area'), admin_root_path, class: 'navbar-brand'
13
+
14
+ %button{class: "navbar-toggle", "data-toggle" => "collapse", "data-target" => ".navHeaderCollapse"}
15
+ %span.glyphicon.glyphicon-th
16
+ #navbar.collapse.navbar-collapse.navHeaderCollapse
17
+ %ul.nav.navbar-nav.navbar-left
18
+ %li= link_to 'Hello', '#'
19
+ %li= link_to 'About', '#'
20
+ %li.dropdown
21
+ %a.dropdown-toggle{src: '#', "data-toggle" => 'dropdown'}
22
+ = "Dropdown"
23
+ .glyphicon.glyphicon-chevron-down
24
+ %ul.dropdown-menu
25
+ %li= link_to 'First link', '#'
26
+
27
+ %ul.nav.navbar-nav.navbar-right
28
+ %li
29
+ .user-name User Name
30
+ .logout
31
+ = link_to 'Logout', '#', method: :delete, class: 'btn btn-default glyphicon glyphicon-off'
32
+ %li.user-avatar
33
+ = image_tag("icons/admin.png")
34
+
35
+ .container
36
+ .row
37
+ .col-lg-12
38
+ = render_flash_messages
39
+ .row
40
+ .col-lg-12
41
+ = yield
42
+
43
+ %footer.navbar.navbar-default.navbar-static-bottom
44
+ .container
45
+ %p.navbar-text
46
+ = "© Admin JabySoft - #{Date.today.year}".html_safe
@@ -0,0 +1,31 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ %title= t('title.application')
6
+ = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
7
+ = javascript_include_tag 'application', 'data-turbolinks-track' => true
8
+ = csrf_meta_tags
9
+ %body
10
+ %nav.navbar.navbar-default.navbar-fixed-top{role: 'navigation'}
11
+ .container
12
+ = link_to t('title.application'), '#', class: 'navbar-brand'
13
+ %button{class: "navbar-toggle", "data-toggle" => "collapse", "data-target" => ".navHeaderCollapse"}
14
+ %span.glyphicon.glyphicon-th
15
+ .collapse.navbar-collapse.navHeaderCollapse
16
+ %ul.nav.navbar-nav.navbar-left
17
+ %li= link_to 'Hello', '#'
18
+ %li= link_to 'About', '#'
19
+
20
+ .container
21
+ .row
22
+ .col-lg-12
23
+ = render_flash_messages
24
+ .row
25
+ .col-lg-12
26
+ = yield
27
+
28
+ %footer.navbar.navbar-default.navbar-static-bottom
29
+ .container
30
+ %p.navbar-text
31
+ = "© JabySoft - #{Date.today.year}".html_safe
@@ -0,0 +1,92 @@
1
+ require 'simplecov'
2
+ SimpleCov.start :rails do
3
+ add_filter 'config/initializers'
4
+ end
5
+
6
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
7
+ ENV['RAILS_ENV'] ||= 'test'
8
+ require File.expand_path('../../config/environment', __FILE__)
9
+ # Prevent database truncation if the environment is production
10
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
11
+ require 'spec_helper'
12
+ require 'rspec/rails'
13
+ # Add additional requires below this line. Rails is not loaded until this point!
14
+ require 'shoulda/matchers'
15
+ Shoulda::Matchers.configure do |config|
16
+ config.integrate do |with|
17
+ with.test_framework :rspec
18
+ with.library :rails
19
+ end
20
+ end
21
+
22
+ # Requires supporting ruby files with custom matchers and macros, etc, in
23
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
24
+ # run as spec files by default. This means that files in spec/support that end
25
+ # in _spec.rb will both be required and run as specs, causing the specs to be
26
+ # run twice. It is recommended that you do not name files matching this glob to
27
+ # end with _spec.rb. You can configure this pattern with the --pattern
28
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
29
+ #
30
+ # The following line is provided for convenience purposes. It has the downside
31
+ # of increasing the boot-up time by auto-requiring all files in the support
32
+ # directory. Alternatively, in the individual `*_spec.rb` files, manually
33
+ # require only the support files necessary.
34
+ #
35
+ # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
36
+
37
+ # Checks for pending migration and applies them before tests are run.
38
+ # If you are not using ActiveRecord, you can remove this line.
39
+ ActiveRecord::Migration.maintain_test_schema!
40
+
41
+ RSpec.configure do |config|
42
+
43
+ # DEVISE
44
+ config.include Devise::Test::ControllerHelpers, :type => :controller
45
+
46
+ # FACTORY-GIRL
47
+ config.include FactoryGirl::Syntax::Methods
48
+ # DatabaseCleaner
49
+ config.before(:suite) do
50
+ DatabaseCleaner.clean_with(:truncation)
51
+ end
52
+ config.before(:each) do
53
+ DatabaseCleaner.strategy = :transaction
54
+ end
55
+ config.before(:each, :js => true) do
56
+ DatabaseCleaner.strategy = :truncation
57
+ end
58
+ config.before(:each) do
59
+ DatabaseCleaner.start
60
+ end
61
+ config.after(:each) do
62
+ DatabaseCleaner.clean
63
+ end
64
+
65
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
66
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
67
+
68
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
69
+ # examples within a transaction, remove the following line or assign false
70
+ # instead of true.
71
+ config.use_transactional_fixtures = true
72
+
73
+ # RSpec Rails can automatically mix in different behaviours to your tests
74
+ # based on their file location, for example enabling you to call `get` and
75
+ # `post` in specs under `spec/controllers`.
76
+ #
77
+ # You can disable this behaviour by removing the line below, and instead
78
+ # explicitly tag your specs with their type, e.g.:
79
+ #
80
+ # RSpec.describe UsersController, :type => :controller do
81
+ # # ...
82
+ # end
83
+ #
84
+ # The different available types are documented in the features, such as in
85
+ # https://relishapp.com/rspec/rspec-rails/docs
86
+ config.infer_spec_type_from_file_location!
87
+
88
+ # Filter lines from Rails gems in backtraces.
89
+ config.filter_rails_from_backtrace!
90
+ # arbitrary gems may also be filtered via:
91
+ # config.filter_gems_from_backtrace("gem name")
92
+ end
@@ -0,0 +1,97 @@
1
+ require 'simplecov'
2
+ SimpleCov.start :rails do
3
+ add_filter 'config/initializers'
4
+ end
5
+
6
+ # This file was generated by the `rails generate rspec:install` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
9
+ # this file to always be loaded, without a need to explicitly require it in any
10
+ # files.
11
+ #
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # will add to the boot time of your test suite on EVERY test run, even for an
15
+ # individual file that may not need all of that loaded. Instead, consider making
16
+ # a separate helper file that requires the additional dependencies and performs
17
+ # the additional setup, and require it from the spec files that actually need
18
+ # it.
19
+ #
20
+ # The `.rspec` file also contains a few flags that are not defaults but that
21
+ # users commonly want.
22
+ #
23
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
+ RSpec.configure do |config|
25
+ # rspec-expectations config goes here. You can use an alternate
26
+ # assertion/expectation library such as wrong or the stdlib/minitest
27
+ # assertions if you prefer.
28
+ config.expect_with :rspec do |expectations|
29
+ # This option will default to `true` in RSpec 4. It makes the `description`
30
+ # and `failure_message` of custom matchers include text for helper methods
31
+ # defined using `chain`, e.g.:
32
+ # be_bigger_than(2).and_smaller_than(4).description
33
+ # # => "be bigger than 2 and smaller than 4"
34
+ # ...rather than:
35
+ # # => "be bigger than 2"
36
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
+ end
38
+
39
+ # rspec-mocks config goes here. You can use an alternate test double
40
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
41
+ config.mock_with :rspec do |mocks|
42
+ # Prevents you from mocking or stubbing a method that does not exist on
43
+ # a real object. This is generally recommended, and will default to
44
+ # `true` in RSpec 4.
45
+ mocks.verify_partial_doubles = true
46
+ end
47
+
48
+ # The settings below are suggested to provide a good initial experience
49
+ # with RSpec, but feel free to customize to your heart's content.
50
+ =begin
51
+ # This allows you to limit a spec run to individual examples or groups
52
+ # you care about by tagging them with `:focus` metadata. When nothing
53
+ # is tagged with `:focus`, all examples get run. RSpec also provides
54
+ # aliases for `it`, `describe`, and `context` that include `:focus`
55
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
+ config.filter_run_when_matching :focus
57
+
58
+ # Allows RSpec to persist some state between runs in order to support
59
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # you configure your source control system to ignore this file.
61
+ config.example_status_persistence_file_path = "spec/examples.txt"
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is
64
+ # recommended. For more details, see:
65
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ config.disable_monkey_patching!
69
+
70
+ # Many RSpec users commonly either run the entire suite or an individual
71
+ # file, and it's useful to allow more verbose output when running an
72
+ # individual spec file.
73
+ if config.files_to_run.one?
74
+ # Use the documentation formatter for detailed output,
75
+ # unless a formatter has already been configured
76
+ # (e.g. via a command-line flag).
77
+ config.default_formatter = 'doc'
78
+ end
79
+
80
+ # Print the 10 slowest examples and example groups at the
81
+ # end of the spec run, to help surface which specs are running
82
+ # particularly slow.
83
+ config.profile_examples = 10
84
+
85
+ # Run specs in random order to surface order dependencies. If you find an
86
+ # order dependency and want to debug it, you can fix the order by providing
87
+ # the seed, which is printed after each run.
88
+ # --seed 1234
89
+ config.order = :random
90
+
91
+ # Seed global randomization in this process using the `--seed` CLI option.
92
+ # Setting this allows you to use `--seed` to deterministically reproduce
93
+ # test failures related to randomization by passing the same `--seed` value
94
+ # as the one that triggered the failure.
95
+ Kernel.srand config.seed
96
+ =end
97
+ end
@@ -0,0 +1,167 @@
1
+ require 'generators/rspec'
2
+ require 'rails/generators/resource_helpers'
3
+
4
+ module Rspec
5
+ module Generators
6
+ # @private
7
+ class ScaffoldGenerator < Base
8
+ include ::Rails::Generators::ResourceHelpers
9
+ source_paths << File.expand_path("../../helper/templates", __FILE__)
10
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
11
+
12
+ class_option :orm, :desc => "ORM used to generate the controller"
13
+ class_option :template_engine, :desc => "Template engine to generate view files"
14
+ class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
15
+
16
+ class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
17
+ class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
18
+ class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
19
+ class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"
20
+
21
+ def generate_controller_spec
22
+ return unless options[:controller_specs]
23
+
24
+ template_file = File.join(
25
+ 'spec/controllers',
26
+ controller_class_path,
27
+ "#{controller_file_name}_controller_spec.rb"
28
+ )
29
+ template 'controller_spec.rb', template_file
30
+ end
31
+
32
+ # do not execute views
33
+ #def generate_view_specs
34
+ # return unless options[:view_specs] && options[:template_engine]
35
+ #
36
+ # copy_view :edit
37
+ # copy_view :index unless options[:singleton]
38
+ # copy_view :new
39
+ # copy_view :show
40
+ #end
41
+
42
+ def generate_routing_spec
43
+ return unless options[:routing_specs]
44
+
45
+ template_file = File.join(
46
+ 'spec/routing',
47
+ controller_class_path,
48
+ "#{controller_file_name}_routing_spec.rb"
49
+ )
50
+ template 'routing_spec.rb', template_file
51
+ end
52
+
53
+ hook_for :integration_tool, :as => :integration
54
+
55
+ protected
56
+
57
+ def copy_view(view)
58
+ template "#{view}_spec.rb",
59
+ File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
60
+ end
61
+
62
+ def formatted_hash(hash)
63
+ formatted = hash.inspect
64
+ formatted.gsub!("{", "{ ")
65
+ formatted.gsub!("}", " }")
66
+ formatted.gsub!("=>", " => ")
67
+ formatted
68
+ end
69
+
70
+ # support for namespaced-resources
71
+ def ns_file_name
72
+ ns_parts.empty? ? file_name : "#{ns_parts[0].underscore}_#{ns_parts[1].singularize.underscore}"
73
+ end
74
+
75
+ # support for namespaced-resources
76
+ def ns_table_name
77
+ ns_parts.empty? ? table_name : "#{ns_parts[0].underscore}/#{ns_parts[1].tableize}"
78
+ end
79
+
80
+ def ns_parts
81
+ @ns_parts ||= begin
82
+ matches = ARGV[0].to_s.match(/\A(\w+)(?:\/|::)(\w+)/)
83
+ matches ? [matches[1], matches[2]] : []
84
+ end
85
+ end
86
+
87
+ # Returns the name of the mock. For example, if the file name is user,
88
+ # it returns mock_user.
89
+ #
90
+ # If a hash is given, it uses the hash key as the ORM method and the
91
+ # value as response. So, for ActiveRecord and file name "User":
92
+ #
93
+ # mock_file_name(:save => true)
94
+ # #=> mock_user(:save => true)
95
+ #
96
+ # If another ORM is being used and another method instead of save is
97
+ # called, it will be the one used.
98
+ #
99
+ def mock_file_name(hash = nil)
100
+ if hash
101
+ method, and_return = hash.to_a.first
102
+ method = orm_instance.send(method).split('.').last.gsub(/\(.*?\)/, '')
103
+ "mock_#{ns_file_name}(:#{method} => #{and_return})"
104
+ else
105
+ "mock_#{ns_file_name}"
106
+ end
107
+ end
108
+
109
+ # Receives the ORM chain and convert to expects. For ActiveRecord:
110
+ #
111
+ # should! orm_class.find(User, "37")
112
+ # #=> User.should_receive(:find).with(37)
113
+ #
114
+ # For Datamapper:
115
+ #
116
+ # should! orm_class.find(User, "37")
117
+ # #=> User.should_receive(:get).with(37)
118
+ #
119
+ def should_receive(chain)
120
+ stub_or_should_chain(:should_receive, chain)
121
+ end
122
+
123
+ # Receives the ORM chain and convert to stub. For ActiveRecord:
124
+ #
125
+ # stub orm_class.find(User, "37")
126
+ # #=> User.stub(:find).with(37)
127
+ #
128
+ # For Datamapper:
129
+ #
130
+ # stub orm_class.find(User, "37")
131
+ # #=> User.stub(:get).with(37)
132
+ #
133
+ def stub(chain)
134
+ stub_or_should_chain(:stub, chain)
135
+ end
136
+
137
+ def stub_or_should_chain(mode, chain)
138
+ receiver, method = chain.split(".")
139
+ method.gsub!(/\((.*?)\)/, '')
140
+
141
+ response = "#{receiver}.#{mode}(:#{method})"
142
+ response << ".with(#{$1})" unless $1.blank?
143
+ response
144
+ end
145
+
146
+ def value_for(attribute)
147
+ raw_value_for(attribute).inspect
148
+ end
149
+
150
+ def raw_value_for(attribute)
151
+ case attribute.type
152
+ when :string
153
+ attribute.name.titleize
154
+ when :integer, :float
155
+ @attribute_id_map ||= {}
156
+ @attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next + attribute.default
157
+ else
158
+ attribute.default
159
+ end
160
+ end
161
+
162
+ def banner
163
+ self.class.banner
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,5 @@
1
+ module Jabysoft
2
+ module Base
3
+ VERSION = '0.1.4'
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'devise'
2
+ require 'jabysoft/base/version'
3
+ require 'rails/engine'
4
+
5
+ module Jabysoft
6
+ module Base
7
+ class Engine < ::Rails::Engine
8
+ config.app_generators do |g|
9
+ g.templates.unshift File::expand_path('../../templates', __FILE__)
10
+ g.orm :active_record
11
+ g.template_engine :haml
12
+ g.test_framework :rspec, fixture: true
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ = form_for @<%= singular_table_name %>, html: {class: 'form-horizontal'} do |f|
2
+ = error_messages_for @<%= singular_table_name %>
3
+
4
+ %fieldset{disabled: @readonly}
5
+ <% for attribute in attributes -%>
6
+ .form-group
7
+ = f.label :<%= attribute.name %>, class: 'col-sm-2 control-label'
8
+ .col-sm-10
9
+ = f.<%= attribute.field_type %> :<%= attribute.name %>, class: 'form-control'
10
+ <% end -%>
11
+ .form-group
12
+ .col-sm-offset-2.col-sm-10
13
+ = link_to_back <%= index_helper %>_path
14
+ = submit_or_edit_button f, edit_url_for(@<%= singular_table_name %>), @readonly
@@ -0,0 +1,25 @@
1
+ = search_form <%= index_helper %>_path
2
+ .table-responsive
3
+ %table.table.table-striped.table-bordered.table-hover
4
+ %thead
5
+ %tr
6
+ <% for attribute in attributes -%>
7
+ %th= ta(<%= class_name %>, :<%= attribute.name %>)
8
+ <% end -%>
9
+ %th
10
+
11
+ %tbody
12
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
13
+ %tr
14
+ <% for attribute in attributes -%>
15
+ %td= <%= singular_table_name %>.<%= attribute.name %>
16
+ <% end -%>
17
+ %td
18
+ = link_to_show <%= class_name %>, <%= singular_table_name %>_path(<%= singular_table_name %>)
19
+ = link_to_edit <%= class_name %>, edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
20
+ = link_to_destroy <%= class_name %>, '#'
21
+ = render 'shared/modals/delete_confirmation', resource: <%= singular_table_name %>
22
+
23
+ = will_paginate @<%= plural_table_name %>, renderer: BootstrapPagination::Rails
24
+ %br
25
+ = link_to_new <%= class_name %>, new_<%= singular_table_name %>_path
@@ -0,0 +1 @@
1
+ = render 'shared/panel', heading: t('editing', model: @<%= singular_table_name %>.name), partial_body: 'form'
@@ -0,0 +1 @@
1
+ = render 'shared/panel', heading: t('listing', model: <%= class_name %>.model_name.human.pluralize), partial_body: 'index'
@@ -0,0 +1 @@
1
+ = render 'shared/panel', heading: t('new', model: <%= class_name %>.model_name.human), partial_body: 'form'
@@ -0,0 +1 @@
1
+ = render 'shared/panel', heading: @<%= singular_table_name %>.name, partial_body: 'form'
@@ -0,0 +1,29 @@
1
+ <% if namespaced? -%>
2
+ require_dependency "<%= namespaced_path %>/application_controller"
3
+ <% end -%>
4
+ <% module_namespacing do -%>
5
+ class <%= controller_class_name %>Controller < BaseController
6
+ # This is a Jabysoft controller
7
+
8
+ # Only allow a trusted parameter "white list" through.
9
+ def permit_params
10
+ <%- if attributes_names.empty? -%>
11
+ params.fetch(:<%= singular_table_name %>, {})
12
+ <%- else -%>
13
+ params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
14
+ <%- end -%>
15
+ end
16
+
17
+ # This method allows you to add associations using Model.includes(:object) to the main query on index action.
18
+ #def included_attributes
19
+ # :school
20
+ #end
21
+
22
+ # This method allows you to obtain dependencies and make them available in the controller.
23
+ # It is called 'before_action :load, except: [:index, :destroy]'
24
+ #def load
25
+ # @list = Model.all
26
+ #end
27
+
28
+ end
29
+ <% end -%>