filtros_personalizados 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/filtros_personalizados.gemspec +40 -0
- data/lib/filtros_personalizados/controllers/personalizaveis_controller.rb +1 -1
- data/lib/filtros_personalizados/filtros_base.rb +14 -10
- data/lib/filtros_personalizados/version.rb +1 -1
- metadata +33 -15
- checksums.yaml +0 -7
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# FiltrosPersonalizados
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/filtros_personalizados`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'filtros_personalizados'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install filtros_personalizados
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/filtros_personalizados.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "filtros_personalizados"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "filtros_personalizados/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "filtros_personalizados"
|
9
|
+
spec.version = FiltrosPersonalizados::VERSION
|
10
|
+
spec.authors = ["Junior Libardoni"]
|
11
|
+
spec.email = ["junior@inovadora.com.br"]
|
12
|
+
|
13
|
+
spec.summary = %q{Filtros personalizados.}
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
# if spec.respond_to?(:metadata)
|
18
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
|
20
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
22
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
23
|
+
# else
|
24
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
# "public gem pushes."
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
32
|
+
end
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
class FiltrosPersonalizados::FiltrosBase
|
2
2
|
attr_accessor :require_fields, :open_fields
|
3
|
-
attr_accessor :errors, :consulta_personalizada, :consulta_outros, :modulo
|
3
|
+
attr_accessor :errors, :consulta_personalizada, :consulta_outros, :modulo, :current_user
|
4
4
|
|
5
5
|
def initialize args={}
|
6
6
|
self.modulo = $modulo.sigla.upcase
|
7
7
|
self.errors = ActiveModel::Errors.new(self)
|
8
|
+
self.current_user = args[:current_user]
|
9
|
+
|
8
10
|
rels_ultima_selecao_ativa = Parametro.where(nome: "rels_ultima_selecao_ativa").first
|
9
11
|
rels_ultima_selecao_ativa = Parametro.create(nome: "rels_ultima_selecao_ativa") if rels_ultima_selecao_ativa.blank?
|
10
12
|
if args[:consulta_personalizada_id].present?
|
@@ -14,8 +16,8 @@ class FiltrosPersonalizados::FiltrosBase
|
|
14
16
|
self.consulta_personalizada = ConsultaPersonalizada.ultima_selecao_feita(args[:current_user].try(:id), args[:controller_name], self.modulo).first rescue nil
|
15
17
|
end
|
16
18
|
end
|
17
|
-
self.require_fields = []
|
18
|
-
self.open_fields = []
|
19
|
+
self.require_fields = [] if self.require_fields.blank?
|
20
|
+
self.open_fields = [] if self.open_fields.blank?
|
19
21
|
carrega_consulta_personalizada(args)
|
20
22
|
self.consulta_outros = (eval(self.consulta_personalizada.try(:outros_filtros).to_s) || {}) if self.errors.blank?
|
21
23
|
self.consulta_outros = {} if self.consulta_outros.nil?
|
@@ -29,7 +31,7 @@ class FiltrosPersonalizados::FiltrosBase
|
|
29
31
|
if conversor.errors.present?
|
30
32
|
self.errors.add(:base, "Ocorreu um erro ao tentar carregar o filtro. Por favor, recrie esse filtro.")
|
31
33
|
else
|
32
|
-
fields_consulta = eval(self.consulta_personalizada.consulta_gerada)
|
34
|
+
fields_consulta = eval(self.consulta_personalizada.consulta_gerada) rescue nil
|
33
35
|
if fields_consulta.present?
|
34
36
|
montar_relatorio(fields_consulta)
|
35
37
|
fields_consulta.first.keys.each do |f|
|
@@ -46,7 +48,7 @@ class FiltrosPersonalizados::FiltrosBase
|
|
46
48
|
def all_fields
|
47
49
|
lista = []
|
48
50
|
self.instance_variable_names.each do |c|
|
49
|
-
lista << eval(c.gsub("@","")) unless ["require_fields", "open_fields", "errors", "consulta_personalizada", "consulta_outros"].include?(c.gsub("@",""))
|
51
|
+
lista << eval(c.gsub("@","")) unless ["require_fields", "open_fields", "errors", "consulta_personalizada", "consulta_outros", "modulo", "current_user"].include?(c.gsub("@",""))
|
50
52
|
end
|
51
53
|
lista
|
52
54
|
end
|
@@ -55,10 +57,6 @@ class FiltrosPersonalizados::FiltrosBase
|
|
55
57
|
unless args.blank?
|
56
58
|
filtro_tela = args.first
|
57
59
|
filtro_tela.each do |nome, opcoes|
|
58
|
-
p "+"*80
|
59
|
-
p self.send(nome)
|
60
|
-
p nome
|
61
|
-
p "+"*80
|
62
60
|
self.send(nome).dias = opcoes["dias"] if ["data_entrada","data_nascimento", "data_alta"].include?(nome)
|
63
61
|
self.send(nome).tipo_selecionado = opcoes["tipo_selecionado"]
|
64
62
|
values = opcoes["values"].reject{ |v| v.empty? } rescue nil
|
@@ -112,10 +110,16 @@ class FiltrosPersonalizados::FiltrosBase
|
|
112
110
|
end
|
113
111
|
|
114
112
|
def salva_selecao args={}
|
113
|
+
consulta_gerada = args[:consulta_gerada]
|
114
|
+
|
115
|
+
if consulta_gerada.try(:first).try(:class) == ActionController::Parameters
|
116
|
+
consulta_gerada = [consulta_gerada.first.to_unsafe_h]
|
117
|
+
end
|
118
|
+
|
115
119
|
ultima_selecao = FiltrosPersonalizados::UltimaSelecaoUser.new(
|
116
120
|
current_user: args[:current_user],
|
117
121
|
tela: args[:tela],
|
118
|
-
consulta_gerada:
|
122
|
+
consulta_gerada: consulta_gerada,
|
119
123
|
outros_filtros: args[:outros_filtros],
|
120
124
|
modulo: self.modulo
|
121
125
|
)
|
metadata
CHANGED
@@ -1,64 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filtros_personalizados
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Junior Libardoni
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2023-
|
12
|
+
date: 2023-04-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '1.16'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.16'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '10.0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '10.0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rspec
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '3.0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '3.0'
|
55
|
-
description:
|
62
|
+
description:
|
56
63
|
email:
|
57
64
|
- junior@inovadora.com.br
|
58
65
|
executables: []
|
59
66
|
extensions: []
|
60
67
|
extra_rdoc_files: []
|
61
68
|
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- .travis.yml
|
72
|
+
- Gemfile
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- filtros_personalizados.gemspec
|
62
78
|
- lib/filtros_personalizados.rb
|
63
79
|
- lib/filtros_personalizados/association.rb
|
64
80
|
- lib/filtros_personalizados/config.rb
|
@@ -96,24 +112,26 @@ files:
|
|
96
112
|
- lib/filtros_personalizados/views/filtros_personalizados/save_consulta.js.erb
|
97
113
|
homepage:
|
98
114
|
licenses: []
|
99
|
-
metadata: {}
|
100
115
|
post_install_message:
|
101
116
|
rdoc_options: []
|
102
117
|
require_paths:
|
103
118
|
- lib
|
104
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
105
121
|
requirements:
|
106
|
-
- -
|
122
|
+
- - ! '>='
|
107
123
|
- !ruby/object:Gem::Version
|
108
124
|
version: '0'
|
109
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
110
127
|
requirements:
|
111
|
-
- -
|
128
|
+
- - ! '>='
|
112
129
|
- !ruby/object:Gem::Version
|
113
130
|
version: '0'
|
114
131
|
requirements: []
|
115
|
-
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.8.23.2
|
116
134
|
signing_key:
|
117
|
-
specification_version:
|
118
|
-
summary:
|
135
|
+
specification_version: 3
|
136
|
+
summary: Filtros personalizados.
|
119
137
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA256:
|
3
|
-
metadata.gz: 4801d491733f16e05d4d9a6230a9454f23ca0d8611854e268a432588aa017410
|
4
|
-
data.tar.gz: 9768f5b345a8f8527e2685068b1411153d662aec58a54c7863a342465ee3d376
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 1e02d859bba497fc472c853b38ad24db4716209bd1f875c9cb2f6046a304caff661738cd094fe4611b3106808376c90f0444ca28fe59a83e46911e71470413cc
|
7
|
-
data.tar.gz: 4f3869ed754303114b0a17a5d56f68bf8573f213d7026f185757055831269bc238f8d70c122398d81230282303f8965d95f7e958eec3178d14877f90be675f1f
|