jabysoft-base 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f17919c27f0cc74b82f52ba6b387009d3ae59a7
4
- data.tar.gz: 725159bc10e219a37759cd92fdb8142e26d17a8c
3
+ metadata.gz: fee81c055ec53725205d25a9fafed8c617f6189d
4
+ data.tar.gz: 83e6acb7d7a26a643744164f094a11e3fe5d0faa
5
5
  SHA512:
6
- metadata.gz: b7e30299e7bcc7c911508dbba0402f86f18ca7ea80fbc8ab39a40377f7382fd6818546e5eb71ecf4684cbbccbe3b0d826b1bbdca167e6a86251501a984e328d7
7
- data.tar.gz: 4f6e6ad160decbb0a6c34465d57ce09409c24c8bab481fd5d566e25f915894cb4e99af969d4ec867afba1e41a0c37150d6d69f06052f0bf6f8490e61716bd52a
6
+ metadata.gz: a45cb6c985ac2cfc2722478d094ed85373177058bf3b916e44ff2818938bf61fcbed311dd42ab61c5edfce1efc14ff4c8e408972e66cd2c936136e1cba3b0d6a
7
+ data.tar.gz: 08ead797e3baf418c40cfd5660938a49d239b040e7fadfaa47837f5913666f2dd47c9913ea4faadb5cb5e3ee95346c863597e0be330a763b7d9e9ddaa57474b0
@@ -1,9 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jabysoft-base (0.1.1)
4
+ jabysoft-base (0.1.5)
5
+ codacy-coverage (~> 1.1)
5
6
  devise (~> 4.2)
6
7
  factory_girl_rails (~> 4.7)
8
+ haml-rails (~> 0.9)
7
9
  pry-byebug (~> 3.4)
8
10
  rails (~> 5.0)
9
11
  rake (~> 11.0)
@@ -49,10 +51,12 @@ GEM
49
51
  i18n (~> 0.7)
50
52
  minitest (~> 5.1)
51
53
  tzinfo (~> 1.1)
52
- arel (7.1.1)
54
+ arel (7.1.4)
53
55
  bcrypt (3.1.11)
54
56
  builder (3.2.2)
55
- byebug (9.0.5)
57
+ byebug (9.0.6)
58
+ codacy-coverage (1.1.0)
59
+ simplecov (>= 0.10.0)
56
60
  coderay (1.1.1)
57
61
  concurrent-ruby (1.0.2)
58
62
  devise (4.2.0)
@@ -71,6 +75,19 @@ GEM
71
75
  railties (>= 3.0.0)
72
76
  globalid (0.3.7)
73
77
  activesupport (>= 4.1.0)
78
+ haml (4.0.7)
79
+ tilt
80
+ haml-rails (0.9.0)
81
+ actionpack (>= 4.0.1)
82
+ activesupport (>= 4.0.1)
83
+ haml (>= 4.0.6, < 5.0)
84
+ html2haml (>= 1.0.1)
85
+ railties (>= 4.0.1)
86
+ html2haml (2.0.0)
87
+ erubis (~> 2.7.0)
88
+ haml (~> 4.0.0)
89
+ nokogiri (~> 1.6.0)
90
+ ruby_parser (~> 3.5)
74
91
  i18n (0.7.0)
75
92
  json (2.0.2)
76
93
  loofah (2.0.3)
@@ -82,13 +99,11 @@ GEM
82
99
  mime-types-data (~> 3.2015)
83
100
  mime-types-data (3.2016.0521)
84
101
  mini_portile2 (2.1.0)
85
- minitest (5.9.0)
102
+ minitest (5.9.1)
86
103
  nio4r (1.2.1)
87
- nokogiri (1.6.8)
104
+ nokogiri (1.6.8.1)
88
105
  mini_portile2 (~> 2.1.0)
89
- pkg-config (~> 1.1.7)
90
106
  orm_adapter (0.5.0)
91
- pkg-config (1.1.7)
92
107
  pry (0.10.4)
93
108
  coderay (~> 1.1.0)
94
109
  method_source (~> 0.8.1)
@@ -122,10 +137,10 @@ GEM
122
137
  method_source
123
138
  rake (>= 0.8.7)
124
139
  thor (>= 0.18.1, < 2.0)
125
- rake (11.2.2)
126
- responders (2.2.0)
140
+ rake (11.3.0)
141
+ responders (2.3.0)
127
142
  railties (>= 4.2.0, < 5.1)
128
- rspec-core (3.5.2)
143
+ rspec-core (3.5.4)
129
144
  rspec-support (~> 3.5.0)
130
145
  rspec-expectations (3.5.0)
131
146
  diff-lcs (>= 1.2.0, < 2.0)
@@ -133,7 +148,7 @@ GEM
133
148
  rspec-mocks (3.5.0)
134
149
  diff-lcs (>= 1.2.0, < 2.0)
135
150
  rspec-support (~> 3.5.0)
136
- rspec-rails (3.5.1)
151
+ rspec-rails (3.5.2)
137
152
  actionpack (>= 3.0)
138
153
  activesupport (>= 3.0)
139
154
  railties (>= 3.0)
@@ -142,6 +157,9 @@ GEM
142
157
  rspec-mocks (~> 3.5.0)
143
158
  rspec-support (~> 3.5.0)
144
159
  rspec-support (3.5.0)
160
+ ruby_parser (3.8.2)
161
+ sexp_processor (~> 4.1)
162
+ sexp_processor (4.7.0)
145
163
  simplecov (0.12.0)
146
164
  docile (~> 1.1.0)
147
165
  json (>= 1.8, < 3)
@@ -151,12 +169,13 @@ GEM
151
169
  sprockets (3.7.0)
152
170
  concurrent-ruby (~> 1.0)
153
171
  rack (> 1, < 3)
154
- sprockets-rails (3.1.1)
172
+ sprockets-rails (3.2.0)
155
173
  actionpack (>= 4.0)
156
174
  activesupport (>= 4.0)
157
175
  sprockets (>= 3.0.0)
158
176
  thor (0.19.1)
159
177
  thread_safe (0.3.5)
178
+ tilt (2.0.5)
160
179
  tzinfo (1.2.2)
161
180
  thread_safe (~> 0.1)
162
181
  warden (1.2.6)
@@ -169,7 +188,6 @@ PLATFORMS
169
188
  ruby
170
189
 
171
190
  DEPENDENCIES
172
- bundler (~> 1.12)
173
191
  jabysoft-base!
174
192
  simplecov (~> 0.12.0)
175
193
 
@@ -177,4 +195,4 @@ RUBY VERSION
177
195
  ruby 2.3.1p112
178
196
 
179
197
  BUNDLED WITH
180
- 1.12.1
198
+ 1.13.2
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Jabysoft-base
2
+ [ ![Codeship Status for Jabysoft/jabysoft-base](https://codeship.com/projects/e6e2f750-4dc3-0134-2149-266445f4b7e3/status?branch=master)](https://codeship.com/projects/170622)
3
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/9d41f1dbe5934ae0826fbb7ecf3a548b)](https://www.codacy.com/app/CQ-JABYSOFT/jabysoft-base?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Jabysoft/jabysoft-base&amp;utm_campaign=Badge_Grade)
4
+ [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/9d41f1dbe5934ae0826fbb7ecf3a548b)](https://www.codacy.com/app/CQ-JABYSOFT/jabysoft-base?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Jabysoft/jabysoft-base&amp;utm_campaign=Badge_Coverage)
2
5
  [![Gem Version](https://badge.fury.io/rb/jabysoft-base.svg)](https://badge.fury.io/rb/jabysoft-base)
3
6
 
4
7
  Set of utilities to build rails applications with style.
@@ -26,6 +29,21 @@ Execute jabysoft:setup to initialize your Rails project.
26
29
  $ rails generate jabysoft:setup
27
30
 
28
31
 
32
+ After that, your Rails scaffold generator should have been overriden by Jabysoft generator.
33
+
34
+ ## Configuration
35
+
36
+ We started some improvemnts to allow your rails app to configure our gem by using a initializer to set options.
37
+
38
+ ### Allowed options
39
+ * skip_authorize - The gem uses Cancancan to authorize action buttons. This option enables Cancancan to authorize.[default: true]
40
+
41
+ ```ruby
42
+ Jabysoft.configure do |config|
43
+ config.skip_authorize = false
44
+ end
45
+ ```
46
+
29
47
  ## Development
30
48
 
31
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -6,8 +6,8 @@ class BaseController < ApplicationController
6
6
  before_action :set_resource, only: [:show, :edit, :update, :destroy]
7
7
  before_action :disable_edition, only: [:show]
8
8
  before_action :load, except: [:index, :destroy]
9
-
10
- PER_PAGE = 5
9
+
10
+ PER_PAGE = 6
11
11
 
12
12
  def index
13
13
  if included_attributes
@@ -93,16 +93,23 @@ class BaseController < ApplicationController
93
93
  nil
94
94
  end
95
95
 
96
+ # to be used by subclasses
96
97
  def load
97
98
  end
98
99
 
99
100
  protected
100
101
  def model
101
- params[:controller].camelize.singularize.constantize if params[:controller]
102
+ get_model_name.singularize.constantize
102
103
  end
103
104
 
104
105
  def index_path
105
- Rails.application.routes.url_helpers.send("#{params[:controller].camelize.underscore}_path")
106
+ Rails.application.routes.url_helpers.send("#{get_model_name.underscore}_path")
107
+ end
108
+
109
+ def get_model_name
110
+ model_name = self.class.name
111
+ model_name.slice! 'Controller'
112
+ model_name
106
113
  end
107
114
 
108
115
  def disable_edition
@@ -1,15 +1,11 @@
1
1
  module BaseHelper
2
-
3
- def translate_attribute(model, attribute = nil, options = {})
2
+
3
+ def translate_attribute(model, attribute = nil)
4
4
  return model.human_attribute_name(attribute) if attribute
5
- if options.any?
6
- return model.model_name.human.pluralize if options[:pluralize]
7
- else
8
- model.model_name.human
9
- end
5
+ model.model_name.human
10
6
  end
11
7
 
12
- alias_method :ta, :translate_attribute
8
+ alias ta translate_attribute
13
9
 
14
10
  def edit_url_for(model)
15
11
  if model.id
@@ -55,6 +51,10 @@ module BaseHelper
55
51
  number_to_currency(value)
56
52
  end
57
53
 
54
+ def decorate(object, decorator)
55
+ yield decorator.new(object)
56
+ end
57
+
58
58
  private
59
59
  def collect_request_params(params)
60
60
  params.collect { |param| "#{param[0]}: #{param[1]}" }.join(", ")
@@ -57,6 +57,10 @@ module LinksHelper
57
57
  link_to t('back'), url, html_options
58
58
  end
59
59
 
60
+ def link_to_menu(model, url)
61
+ link_to model.model_name.human.pluralize, url
62
+ end
63
+
60
64
  def submit_or_edit_button(form, edit_path, is_edition)
61
65
  if is_edition && params[:action] != 'new'
62
66
  link_to_edit form.object, edit_path, class: "btn btn-primary btn-lg"
@@ -75,7 +79,7 @@ module LinksHelper
75
79
 
76
80
  private
77
81
  def authorize_button(action, model, options, button_class)
78
- return true #FIXME - to be removed
82
+ return true if Jabysoft.configuration.skip_authorize
79
83
  unless can? action, model
80
84
  options.merge!(class: button_class+" disabled ") and return false
81
85
  end
@@ -6,11 +6,9 @@ module ExtensionModelBehaviour
6
6
  scope :active, -> { where(active: true) }
7
7
  scope :scoped, -> { select(:id, scoped_attribute) }
8
8
 
9
- private
10
9
  def self.scoped_attribute
11
10
  return :code if column_names.include? 'code'
12
11
  :name
13
12
  end
14
-
15
13
  end
16
14
  end
@@ -1,5 +1,6 @@
1
1
  module SearchableBehaviour
2
2
  extend ActiveSupport::Concern
3
+ # It gives models search behaviour
3
4
 
4
5
  included do
5
6
  def self.search(params)
@@ -20,7 +21,6 @@ module SearchableBehaviour
20
21
  each_attr.join("OR ")
21
22
  end
22
23
 
23
- private
24
24
  def self.has_joins?
25
25
  select_hash_attributes.any?
26
26
  end
@@ -43,5 +43,4 @@ module SearchableBehaviour
43
43
  end
44
44
 
45
45
  end
46
-
47
46
  end
@@ -24,7 +24,6 @@ en:
24
24
  selection: Select
25
25
  search: Search
26
26
  not_authorized: Not Authorized
27
- admin_area: Administration
28
27
  toggle_sidebar: Sidebar
29
28
  send: Send
30
29
  contact: Contact
@@ -24,7 +24,6 @@ pt-BR:
24
24
  selection: Selecione
25
25
  search: Pesquisar
26
26
  not_authorized: Sem permissão
27
- admin_area: Administração
28
27
  toggle_sidebar: Menu Lateral
29
28
  send: Enviar
30
29
  contact: Contato
@@ -26,12 +26,13 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.add_development_dependency 'bundler', '~> 1.12'
30
29
  spec.add_development_dependency 'simplecov', '~> 0.12.0'
31
30
  spec.add_dependency 'rails', '~> 5.0'
31
+ spec.add_dependency 'haml-rails', '~> 0.9'
32
32
  spec.add_dependency 'rspec-rails', '~> 3.5'
33
33
  spec.add_dependency 'factory_girl_rails', '~> 4.7'
34
34
  spec.add_dependency 'rake', '~> 11.0'
35
35
  spec.add_dependency 'pry-byebug', '~> 3.4'
36
36
  spec.add_dependency 'devise', '~> 4.2'
37
+ spec.add_runtime_dependency 'codacy-coverage', '~> 1.1'
37
38
  end
@@ -21,8 +21,7 @@ module Haml
21
21
  end
22
22
  end
23
23
 
24
- protected
25
-
24
+ protected
26
25
  def available_views
27
26
  %w(index edit show new _index)
28
27
  end
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  ruby '2.3.1'
4
4
 
5
- # JabySoft
5
+ # JabySoft gem
6
6
  gem 'jabysoft-base', '~> 0.1'
7
7
 
8
8
  # RAILS DEPENDENCIES
@@ -17,13 +17,14 @@ gem 'turbolinks', '~> 5.0'
17
17
  gem 'jbuilder', '~> 2.6'
18
18
 
19
19
  # INCLUDED
20
- gem 'haml-rails', '~> 0.9.0'
21
- gem 'choices', '~> 0.4.0'
20
+ gem 'haml', '~> 4.0'
21
+ gem 'choices', '~> 0.4'
22
22
  gem 'will_paginate-bootstrap', '~> 1.0', '>= 1.0.1'
23
23
  gem 'rack-mini-profiler', '~> 0.10.1', require: false
24
24
  gem 'whenever', '~> 0.9.7', require: false
25
25
  gem 'after_party', '~> 1.10'
26
- gem 'rails-controller-testing', '~> 0.1.1'
26
+ gem 'rails-controller-testing', '~> 0.1'
27
+ gem 'codacy-coverage', '~> 1.1'
27
28
 
28
29
  group :development, :test do
29
30
  gem 'pry-byebug', '~> 3.4'
@@ -9,7 +9,7 @@
9
9
  %body
10
10
  %nav.navbar.navbar-default.navbar-fixed-top
11
11
  .container
12
- = link_to t('admin_area'), admin_root_path, class: 'navbar-brand'
12
+ = link_to t('title.administration'), admin_root_path, class: 'navbar-brand'
13
13
 
14
14
  %button{class: "navbar-toggle", "data-toggle" => "collapse", "data-target" => ".navHeaderCollapse"}
15
15
  %span.glyphicon.glyphicon-th
@@ -1,3 +1,7 @@
1
+ # It sends test coverage info to codacy.com
2
+ require 'codacy-coverage'
3
+ Codacy::Reporter.start
4
+
1
5
  require 'simplecov'
2
6
  SimpleCov.start :rails do
3
7
  add_filter 'config/initializers'
@@ -29,16 +29,6 @@ module Rspec
29
29
  template 'controller_spec.rb', template_file
30
30
  end
31
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
32
  def generate_routing_spec
43
33
  return unless options[:routing_specs]
44
34
 
@@ -1,12 +1,25 @@
1
1
  require 'devise'
2
2
  require 'jabysoft/base/version'
3
+ require 'jabysoft/base/configuration'
3
4
  require 'rails/engine'
4
5
 
5
6
  module Jabysoft
7
+ class << self
8
+ attr_writer :configuration
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Jabysoft::Base::Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield configuration if block_given?
17
+ end
18
+
6
19
  module Base
7
20
  class Engine < ::Rails::Engine
8
21
  config.app_generators do |g|
9
- g.templates.unshift File::expand_path('../../templates', __FILE__)
22
+ g.templates.unshift File.expand_path('../../templates', __FILE__)
10
23
  g.orm :active_record
11
24
  g.template_engine :haml
12
25
  g.test_framework :rspec, fixture: true
@@ -0,0 +1,10 @@
1
+ module Jabysoft
2
+ module Base
3
+ class Configuration
4
+ attr_accessor :skip_authorize
5
+ def initialize
6
+ @skip_authorize = true
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,5 @@
1
1
  module Jabysoft
2
2
  module Base
3
- VERSION = '0.1.4'
3
+ VERSION = '0.1.5'
4
4
  end
5
5
  end
@@ -4,7 +4,18 @@ require_dependency "<%= namespaced_path %>/application_controller"
4
4
  <% module_namespacing do -%>
5
5
  class <%= controller_class_name %>Controller < BaseController
6
6
  # This is a Jabysoft controller
7
+
8
+ # This method allows you to add associations using Model.includes(:object) to the main query on index action.
9
+ # def included_attributes
10
+ # :school
11
+ # end
7
12
 
13
+ # This method allows you to obtain dependencies and make them available in the controller.
14
+ # It is called 'before_action :load, except: [:index, :destroy]'
15
+ # def load
16
+ # @list = Model.all
17
+ # end
18
+
8
19
  # Only allow a trusted parameter "white list" through.
9
20
  def permit_params
10
21
  <%- if attributes_names.empty? -%>
@@ -13,17 +24,5 @@ class <%= controller_class_name %>Controller < BaseController
13
24
  params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
14
25
  <%- end -%>
15
26
  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
27
  end
29
28
  <% end -%>
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jabysoft-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emerson S. Xavier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: simplecov
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: 0.12.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: 0.12.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: simplecov
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.12.0
34
- type: :development
33
+ version: '5.0'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.12.0
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: haml-rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '0.9'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '0.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '4.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: codacy-coverage
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.1'
125
139
  description: Simple Jabysoft Rails-based code and scaffold generators.
126
140
  email:
127
141
  - msxavii@gmail.com
@@ -173,6 +187,7 @@ files:
173
187
  - lib/generators/jabysoft/setup/templates/spec/spec_helper.rb
174
188
  - lib/generators/rspec/scaffold/scaffold_generator.rb
175
189
  - lib/jabysoft/base.rb
190
+ - lib/jabysoft/base/configuration.rb
176
191
  - lib/jabysoft/base/version.rb
177
192
  - lib/templates/haml/scaffold/_form.html.haml
178
193
  - lib/templates/haml/scaffold/_index.html.haml