admin_model 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ef9141566731d88bd5868d1be752919b86fa4e97662a554a1df85c38de5bb5c6
4
+ data.tar.gz: 9915a98b43483a6acc79dda6a1a28231e630fa6f38d623d42a1dfd0a46effbaf
5
+ SHA512:
6
+ metadata.gz: 3bff9add38c7193389a68608ab7d6e4c021372e5140e5d423fe8ed83148947fd720591ce1ab830f4125eae84110868d30161a6d9f6f5d2a1d3b3c7b5a239d163
7
+ data.tar.gz: cd53df0c7decfc8a193fdfd5821ea2d81e6b866b4ce255f3d6203801e56785a5a6490315d584fa4a9240b0cae9173fed53f4e45c25b7f100cc3a19c52d02d1d4
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Beto
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,23 @@
1
+ # AdminModels
2
+ Admin model is a rails gem who includes a generator to quickly create rails admin stuff for you
3
+
4
+ ## Usage
5
+ This gem use the same syntax as the rails model generator
6
+ ```sh
7
+ $ rails generate model ModelName FieldName:FieldType FieldName:FieldType
8
+ ```
9
+
10
+ ## Installation
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem "admin_model", git: "https://github.com/albertobazilio98/admin_model.git"
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ ## License
23
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,27 @@
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 = 'AdminModels'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1,5 @@
1
+ require "admin_model/railtie"
2
+
3
+ module AdminModels
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ module AdminModels
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module AdminModels
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,42 @@
1
+ class AdminModelGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('templates', __dir__)
3
+
4
+ argument :attributes, type: :array, default: []
5
+
6
+ def generate_model
7
+ generate('model', @_initializer[0].join(' '))
8
+ end
9
+
10
+ def crate_rails_admin_concern
11
+ @fields_list = ''
12
+ @attributes.each do |attribute|
13
+ @fields_list << "\n field :#{attribute.name}"
14
+ end
15
+ template 'admin_model.template', "app/models/concerns/rails_admin/#{file_name}.rb"
16
+ end
17
+
18
+ def include_rails_admin
19
+ inject_into_class "app/models/#{file_name}.rb", class_name, " include RailsAdmin::#{class_name}\n"
20
+ end
21
+
22
+ def create_translation_keys
23
+ inject_into_file 'config/locales/pt-BR.yml', after: "\n models:\n" do
24
+ <<-YML
25
+ #{name}:
26
+ one: please fill me
27
+ other: please fill me
28
+ YML
29
+ end
30
+ model_attriutes = ''
31
+ @attributes.each do |attribute|
32
+ model_attriutes << "\n #{attribute.name}: please fill me"
33
+ end
34
+ inject_into_file 'config/locales/pt-BR.yml', after: "\n attributes:\n" do
35
+ <<-YML
36
+ #{name}: please fill me#{model_attriutes}
37
+ YML
38
+ end
39
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,22 @@
1
+ module RailsAdmin::<%= @class_name %>
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ rails_admin do
6
+ list do<%= @fields_list %>
7
+ field :created_at
8
+ field :updated_at
9
+ end
10
+ create do<%= @fields_list %>
11
+ end
12
+
13
+ show do<%= @fields_list %>
14
+ field :created_at
15
+ field :updated_at
16
+ end
17
+
18
+ edit do<%= @fields_list %>
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :admin_model do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: admin_model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alberto Bazilio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.4
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.2.4.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.2.4
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.2.4.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: sqlite3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: Create concerns and I18n keys for rails admin
48
+ email:
49
+ - albertobazilio98@gmail.com.br
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - MIT-LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/admin_model.rb
58
+ - lib/admin_model/railtie.rb
59
+ - lib/admin_model/version.rb
60
+ - lib/generators/admin_model/admin_model_generator.rb
61
+ - lib/generators/admin_model/templates/admin_model.template
62
+ - lib/tasks/admin_model_tasks.rake
63
+ homepage: https://github.com/albertobazilio98/admin_model
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.0.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Quickly create rails admin stuff
86
+ test_files: []