rails_simple_exposure 1.0.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
+ SHA1:
3
+ metadata.gz: 1bbd867bcb618ff7deeb40e655480fe907de13de
4
+ data.tar.gz: b3cb55e00764a97607862e6af0d9cbbd413eea81
5
+ SHA512:
6
+ metadata.gz: 9e7d4ca93699231ea22fd3c85e143e9e5c71f8e57182f352d4c1596dd496c34f9e89bf0b3750d5f11b2ddb22b9eb9866b8b72208665b6ad6a2c70e3bb8fc599f
7
+ data.tar.gz: 1d086bb4db6b7d7ddc70534d8b57969d3a8b08b7a2dfa28d8538a62df497e1a37d7f755c3f18398692bdd4e7f0900b541b3353f380751d57bab1f2fe99e26044
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Damian Baćkowski
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,81 @@
1
+ # RailsSimpleExposure
2
+ Cleanup your Rails controllers.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'rails_simple_exposure'
9
+ ```
10
+
11
+ And then execute:
12
+ ```bash
13
+ $ bundle
14
+ ```
15
+
16
+ Or install it yourself as:
17
+ ```bash
18
+ $ gem install rails_simple_exposure
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ Here's what a standard Rails CRUD controller using this plugin might look like:
24
+
25
+ ```ruby
26
+ class BooksController < ApplicationController
27
+ expose :books, -> { Book.all }
28
+ expose :book, -> { params[:id].present? ? Book.find(params[:id]) : Book.new }
29
+
30
+ def create
31
+ book.attributes = book_params
32
+
33
+ respond_to do |format|
34
+ if book.save
35
+ format.html { redirect_to book, notice: 'Book was successfully created.' }
36
+ format.json { render :show, status: :created, location: book }
37
+ else
38
+ format.html { render :new }
39
+ format.json { render json: book.errors, status: :unprocessable_entity }
40
+ end
41
+ end
42
+ end
43
+
44
+ def update
45
+ respond_to do |format|
46
+ if book.update(book_params)
47
+ format.html { redirect_to book, notice: 'Book was successfully updated.' }
48
+ format.json { render :show, status: :ok, location: book }
49
+ else
50
+ format.html { render :edit }
51
+ format.json { render json: book.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ def destroy
57
+ book.destroy
58
+ respond_to do |format|
59
+ format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
60
+ format.json { head :no_content }
61
+ end
62
+ end
63
+
64
+ private
65
+ def book_params
66
+ params.require(:book).permit(:title)
67
+ end
68
+ end
69
+
70
+ ```
71
+
72
+ ## Contributing
73
+
74
+ 1. Fork it
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create a new Pull Request
79
+
80
+ ## License
81
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,23 @@
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 = 'RailsSimpleExposure'
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
+ require 'rspec/core/rake_task'
19
+
20
+ RSpec::Core::RakeTask.new
21
+
22
+ task :default => :spec
23
+ task :test => :spec
@@ -0,0 +1,20 @@
1
+ module RailsSimpleExposure
2
+ def expose(name, value)
3
+ instance_variable_name = "@#{name}"
4
+
5
+ define_method name do
6
+ return instance_variable_get instance_variable_name if instance_variable_defined? instance_variable_name
7
+ instance_variable_set instance_variable_name, instance_eval(&value)
8
+ end
9
+
10
+
11
+ define_method :"#{name}=" do |value|
12
+ instance_variable_set instance_variable_name, value
13
+ end
14
+
15
+ private :"#{name}="
16
+ helper_method name
17
+ end
18
+ end
19
+
20
+ ActionController::Base.send :extend, RailsSimpleExposure
@@ -0,0 +1,3 @@
1
+ module RailsSimpleExposure
2
+ VERSION = '1.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_simple_exposure
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Damian Baćkowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-06 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: 4.0.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 4.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '12.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '12.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 3.5.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 3.5.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: capybara
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 2.14.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 2.14.0
75
+ description: Cleanup your Rails controllers.
76
+ email:
77
+ - damianbackowski@gmail.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - MIT-LICENSE
83
+ - README.md
84
+ - Rakefile
85
+ - lib/rails_simple_exposure.rb
86
+ - lib/rails_simple_exposure/version.rb
87
+ homepage: https://github.com/dbackowski/rails_simple_exposure
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.6.8
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Cleanup your Rails controllers.
111
+ test_files: []