base_resource 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3e38d2791db6dc21af07087ddc3f78d8777187f4
4
- data.tar.gz: 72ebe538eb6c29ee180acd4171fd0f61a7595588
2
+ SHA256:
3
+ metadata.gz: 3a3716265be1d9e7f8b7dcbd3b139cc16861dddbd2df33d27bf6ee2c7a2ec8c5
4
+ data.tar.gz: 7b39521ef538297fa3012d33971d0d2886ef7ef09d7c7b9e177938fd2ba4c138
5
5
  SHA512:
6
- metadata.gz: 518a4406819af0ae6e634ef8b357a48c33a85748b6ed650689719cc4c5a599b1f45df76d302d61d677661899c511ca5a284e98c7bea7887eb120f56aca11cdb3
7
- data.tar.gz: 7257c83bfa11b03609fa1a69940b4b4ed5b5887ba6265d11c59cc6acfb08a4feb04dd01df51b798e7781fcd887f1cad0280d3a10cd499018582be657be358adc
6
+ metadata.gz: '088fcb8b184bd55144951cc0459bd0f77827c5a4f06709b02b9d4c6fc86badc41842f61c47f7849367b8d284ac83e498f5d6c0a1ce17dc82dc275b50f0797d7a'
7
+ data.tar.gz: 9bf56067e9830f45fdf3bb925a3d5821a1290750173326b93c0014b52290b7405d377ff53cdeb26d1c946d489d55cb04945e60fa838944d2461ba6c492900a55
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at hdy9515@dingtalk.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://gems.ruby-china.com"
4
+
5
+ # Specify your gem's dependencies in base_resource.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ base_resource (0.2.0)
5
+
6
+ GEM
7
+ remote: https://gems.ruby-china.com/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (13.0.6)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.1)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.2)
24
+
25
+ PLATFORMS
26
+ x86_64-darwin-18
27
+
28
+ DEPENDENCIES
29
+ base_resource!
30
+ rake (~> 13.0)
31
+ rspec (~> 3.0)
32
+
33
+ BUNDLED WITH
34
+ 2.2.30
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 sen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -3,7 +3,7 @@ Base Controller Resource Query
3
3
 
4
4
  ## dependences
5
5
  ```
6
- # gem 'jbuilder', '~> 2.5'
6
+ # gem 'jbuilder'
7
7
  # 表单
8
8
  gem 'reform'
9
9
  gem 'reform-rails'
@@ -37,4 +37,4 @@ end
37
37
  Contribution directions go here.
38
38
 
39
39
  ## License
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,33 +1,8 @@
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
1
+ # frozen_string_literal: true
6
2
 
7
- require 'rdoc/task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
8
5
 
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'BaseResource'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
6
+ RSpec::Core::RakeTask.new(:spec)
16
7
 
17
-
18
-
19
-
20
-
21
-
22
- require 'bundler/gem_tasks'
23
-
24
- require 'rake/testtask'
25
-
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'test'
28
- t.pattern = 'test/**/*_test.rb'
29
- t.verbose = false
30
- end
31
-
32
-
33
- task default: :test
8
+ task default: :spec
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/base_resource/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "base_resource"
7
+ spec.version = BaseResource::VERSION
8
+ spec.authors = ["sen"]
9
+ spec.email = ["hdy9515@dingtalk.com"]
10
+
11
+ spec.summary = "controller base resource"
12
+ spec.description = "controller base resource"
13
+ spec.homepage = "https://github.com/rails-gems/base-resource"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ # spec.metadata["allowed_push_host"] = ""
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://rubygems.org/gems/base_resource"
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "base_resource"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,110 +1,144 @@
1
- require('base_resource/instance_methods')
2
- require('base_resource/pagination')
3
- require('base_resource/search')
1
+ require_relative('search')
2
+ require_relative('pagination')
3
+ require_relative('instance_methods')
4
4
  module BaseResource
5
5
  module Actions
6
- include InstanceMethods
7
- include Pagination
8
6
  include Search
7
+ include Pagination
8
+ include InstanceMethods
9
9
 
10
- def index resources = nil
11
- resources = find_base_resources resources
10
+ def br_index(resources: nil, distinct: false, var_name: nil)
11
+ resources = get_params_resources(distinct: distinct, resources: resources)
12
12
  if block_given?
13
13
  resources = yield(resources)
14
14
  end
15
- instance_variable_set("@#{resources_name(resources)}", paginate(resources.order(id: :desc)))
15
+ var_name ||= "@#{resources_name(resources: resources)}"
16
+ instance_variable_set(var_name, paginate(resources: resources))
16
17
  end
17
- alias_method :br_index, :index
18
- # or in ruby > 2.2, child can call parent method use below method
19
- # method(:index).super_method.call
18
+ # alias_method :br_index, :index
20
19
 
21
- def show
22
- resource = find_base_resource
23
- instance_variable_set("@#{resource_name(resource)}", resource)
20
+ def br_show(resources: nil, var_name: nil)
21
+ resource = get_params_resource(resources: resources)
22
+ var_name ||= "@#{resource_name(resource: resource)}"
23
+ instance_variable_set(var_name, resource)
24
24
  if block_given?
25
25
  yield(resource)
26
26
  end
27
27
  end
28
- alias_method :br_show, :show
28
+ # alias_method :br_show, :show
29
29
 
30
- def create options = {}
31
- options = {auto_render_success: true, auto_render_error: true, custom_save: false}.merge!(options || {})
32
- form = form_const.new(resource_klass.new)
33
- instance_variable_set("@#{resource_name(form.model)}", form.model)
34
- if form.validate(params)
35
- if options[:custom_save]
36
- form.save do |hash|
37
- yield hash, form
38
- end if block_given?
39
- else
40
- if form.save
41
- yield true if block_given?
42
- render json: { msg: :successfully_create }, status: 200 and return if options[:auto_render_success]
30
+ # form_class默认根据controller路径规则寻找
31
+ # model_class默认根据controller命令来 eg: UsersController -> User
32
+ def br_create(auto_save: true, form_class: nil, model_class: nil, var_name: nil, auto_render_success: true)
33
+ model_class ||= resource_klass
34
+ form_class ||= resource_form_const(model_class: model_class)
35
+ form = form_class.new(model_class.new)
36
+ var_name ||= "@#{resource_name(resource: form.model)}"
37
+ instance_variable_set(var_name, form.model)
38
+ begin
39
+ if form.validate(params)
40
+ if auto_save
41
+ if form.save
42
+ yield true if block_given?
43
+ render json: { message: :successfully_create }, status: 200 and return if auto_render_success
44
+ else
45
+ yield false if block_given?
46
+ render json: { message: format_error(form.model) }, status: 422 and return
47
+ end
43
48
  else
44
- yield false if block_given?
45
- render json: { msg: form.errors.full_messages.first || form.model.errors.full_messages.first }, status: 422 and return if options[:auto_render_error]
49
+ form.sync
50
+ form.save do |hash|
51
+ yield hash, form.model
52
+ end if block_given?
46
53
  end
54
+ else
55
+ # yield false if block_given?
56
+ render json: { message: format_error(form) }, status: 422 and return
47
57
  end
48
- else
49
- yield false if block_given? && !options[:custom_save]
50
- render json: { msg: form.errors.full_messages.first }, status: 422 and return if options[:auto_render_error]
58
+ rescue Exception => e
59
+ render json: { message: e.message }, status: 422 and return
51
60
  end
52
61
  end
53
- alias_method :br_create, :create
62
+ # alias_method :br_create, :create
54
63
 
55
- def update resource = nil
56
- form = form_const.new(resource || resource_klass.find(params[:id]))
57
- if form.validate(params) && form.save
58
- resource = form.model
59
- instance_variable_set("@#{resource_name(resource)}", resource)
60
- if block_given?
61
- yield resource
64
+ def br_update(auto_save: true, form_class: nil, model: nil, var_name: nil, auto_render_success: false)
65
+ resource = model || get_params_resource
66
+ if resource.blank?
67
+ render json: { message: :not_found }, status: 422 and return
68
+ end
69
+ form_class ||= resource_form_const(model_class: resource.class)
70
+ form = form_class.new(resource)
71
+ var_name ||= "@#{resource_name(resource: resource)}"
72
+ instance_variable_set(var_name, resource)
73
+ if form.validate(params)
74
+ if auto_save
75
+ begin
76
+ if form.save
77
+ yield true if block_given?
78
+ render json: { message: :successfully_update }, status: 200 and return if auto_render_success
79
+ else
80
+ yield false if block_given?
81
+ render json: { message: format_error(form.model) }, status: 422 and return
82
+ end
83
+ rescue Exception => e
84
+ render json: { message: e.message }, status: 422 and return
85
+ end
62
86
  else
63
- render json: { msg: :successfully_update }, status: 200
87
+ form.sync
88
+ form.save do |hash|
89
+ yield hash, form.model
90
+ end if block_given?
64
91
  end
65
92
  else
66
- render json: { msg: form.errors.full_messages.first || form.model.errors.full_messages.first }, status: 422
93
+ render json: { message: format_error(form) }, status: 422 and return
67
94
  end
68
95
  end
69
- alias_method :br_update, :update
96
+ # alias_method :br_update, :update
70
97
 
71
- def destroy
72
- resource = destroy_resource
73
- instance_variable_set("@#{resource_name(resource)}", resource)
98
+ def br_destroy(resources: nil, model: nil, var_name: nil)
99
+ resource = model || get_params_resource(resources: resources)
100
+ if resource.blank?
101
+ render json: { message: :not_found }, status: 422 and return
102
+ end
103
+ var_name ||= "@#{resource_name(resource: resource)}"
104
+ instance_variable_set(var_name, resource)
74
105
  if block_given?
75
106
  yield resource
76
107
  else
77
- render json: { msg: :successfully_destroy }, status: 200
108
+ render json: { message: :successfully_destroy }, status: 200
78
109
  end
79
110
  end
80
- alias_method :br_destroy, :destroy
111
+ # alias_method :br_destroy, :destroy
81
112
 
82
113
  protected
83
114
 
84
- def find_base_resources resources = nil
85
- search = (resources || resource_klass).ransack(prepare_search_condition)
86
- search.sorts = prepare_search_sorts if search.sorts.empty? && prepare_search_sorts.present?
87
- search.result(distinct: true)
115
+ def format_error(instance)
116
+ instance.errors.full_messages.join(',')
88
117
  end
89
118
 
90
- def find_base_resource(id = nil)
91
- id ||= respond_to?(:params) && params.is_a?(ActionController::Parameters) && params[:id]
92
- resource_klass.find id
119
+ private
120
+
121
+ def get_params_resources(resources: nil, distinct: true)
122
+ search = (resources || resource_klass).ransack(prepare_search_condition)
123
+ search.sorts = prepare_search_sorts if search.sorts.empty? && prepare_search_sorts.present?
124
+ search.result(distinct: distinct)
93
125
  end
94
126
 
95
- def destroy_resource(id = nil)
96
- id ||= respond_to?(:params) && params.is_a?(ActionController::Parameters) && params[:id]
97
- resource_klass.destroy id
127
+ def get_params_resource(resources: nil, field: :id)
128
+ field_value = respond_to?(:params) && params.is_a?(ActionController::Parameters) && params[field]
129
+ (resources || resource_klass).find_by(field => field_value)
98
130
  end
99
131
 
100
- def form_const
132
+ def resource_form_const(model_class:)
133
+ klass_name = model_class.to_s || resource_klass_name
101
134
  namespaces = self.class.to_s.split("::")
102
135
  const = while namespaces.present?
103
- const = "#{namespaces.join('::')}::#{resource_klass_name}Form::#{action_name.classify}".constantize rescue nil
136
+ const = "#{namespaces.join('::')}::#{klass_name}Form::#{action_name.classify}".safe_constantize
137
+ # p "#{namespaces.join('::')}::#{klass_name}Form::#{action_name.classify}"
104
138
  break const if const
105
139
  namespaces.pop
106
140
  end
107
- const || "#{resource_klass_name}Form::#{action_name.classify}".try(:constantize)
141
+ const || "#{klass_name}Form::#{action_name.classify}".try(:constantize)
108
142
  end
109
143
  end
110
- end
144
+ end
@@ -1,13 +1,16 @@
1
1
  module BaseResource
2
2
  module InstanceMethods
3
+
4
+ private
5
+
3
6
  # name of the singular resource eg: 'user'
4
- def resource_name(resource = nil)
5
- resource ? resource.class.to_s.singularize.underscore : controller_name.singularize.underscore
7
+ def resource_name(resource: nil)
8
+ resource ? resource.class.to_s.singularize.underscore.gsub('/', '_') : controller_name.singularize.underscore.gsub('/', '_')
6
9
  end
7
10
 
8
11
  # name of the resource collection eg: 'users'
9
- def resources_name(resources = nil)
10
- resources ? resources.model.to_s.pluralize.underscore : controller_name.pluralize.underscore
12
+ def resources_name(resources: nil)
13
+ resources ? resources.model.to_s.pluralize.underscore.gsub('/', '_') : controller_name.pluralize.underscore.gsub('/', '_')
11
14
  end
12
15
 
13
16
  # eg: return 'User' string
@@ -3,12 +3,10 @@ module BaseResource
3
3
 
4
4
  protected
5
5
 
6
- def paginate resources = nil
7
- resources = (resources || @resources).page(params[:page] || 1)
6
+ def paginate(resources:)
7
+ resources = resources.page(params[:page] || 1)
8
8
  # default per_page is 25
9
- if params[:per_page]
10
- resources = resources.per(params[:per_page])
11
- end
9
+ resources = resources.per(params[:per_page] || 20)
12
10
  resources
13
11
  end
14
12
  end
@@ -1,3 +1,3 @@
1
1
  module BaseResource
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/base_resource.rb CHANGED
@@ -1,8 +1,4 @@
1
- require('base_resource/actions')
1
+ require_relative('base_resource/actions')
2
2
  module BaseResource
3
3
  include Actions
4
- end
5
-
6
- # class ActionController::API
7
- # include BaseResource
8
- # end
4
+ end
metadata CHANGED
@@ -1,121 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - mars
8
- autorequire:
9
- bindir: bin
7
+ - sen
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-30 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: '6'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "<"
25
- - !ruby/object:Gem::Version
26
- version: '6'
27
- - !ruby/object:Gem::Dependency
28
- name: reform
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: reform-rails
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: kaminari
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: ransack
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: sqlite3
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- description: Controller base Resource.
11
+ date: 2021-10-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: controller base resource
98
14
  email:
99
- - 578595193@qq.com
15
+ - hdy9515@dingtalk.com
100
16
  executables: []
101
17
  extensions: []
102
18
  extra_rdoc_files: []
103
19
  files:
104
- - MIT-LICENSE
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
105
26
  - README.md
106
27
  - Rakefile
28
+ - base_resource.gemspec
29
+ - bin/console
30
+ - bin/setup
107
31
  - lib/base_resource.rb
108
32
  - lib/base_resource/actions.rb
109
33
  - lib/base_resource/instance_methods.rb
110
34
  - lib/base_resource/pagination.rb
111
35
  - lib/base_resource/search.rb
112
36
  - lib/base_resource/version.rb
113
- - lib/tasks/base_resource_tasks.rake
114
- homepage: https://github.com/wuyuedefeng/base-resource
37
+ homepage: https://github.com/rails-gems/base-resource
115
38
  licenses:
116
39
  - MIT
117
- metadata: {}
118
- post_install_message:
40
+ metadata:
41
+ homepage_uri: https://github.com/rails-gems/base-resource
42
+ source_code_uri: https://rubygems.org/gems/base_resource
43
+ post_install_message:
119
44
  rdoc_options: []
120
45
  require_paths:
121
46
  - lib
@@ -123,16 +48,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
48
  requirements:
124
49
  - - ">="
125
50
  - !ruby/object:Gem::Version
126
- version: '0'
51
+ version: 2.4.0
127
52
  required_rubygems_version: !ruby/object:Gem::Requirement
128
53
  requirements:
129
54
  - - ">="
130
55
  - !ruby/object:Gem::Version
131
56
  version: '0'
132
57
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.6.13
135
- signing_key:
58
+ rubygems_version: 3.2.22
59
+ signing_key:
136
60
  specification_version: 4
137
- summary: Controller base Resource.
61
+ summary: controller base resource
138
62
  test_files: []
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright 2018 mars
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.
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :base_resource do
3
- # # Task goes here
4
- # end