rails_rad 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2fddbfd8dcca6dad44e1b00f58681d1c8b93c95e
4
+ data.tar.gz: de50132ad32654b5ff5b8505a83eb7bad8da0661
5
+ SHA512:
6
+ metadata.gz: 863ecde808fa3121a1a407e1aaa024626f6862b57b3d8f2b8663ebf35d4d5e619f51e302cd83c3c43e6626007bf301a5b749c76a1dabcf89cf8a95fe7fc613d8
7
+ data.tar.gz: 7a72d25a06c2d04f0f6916ec8a172b1e645f20931a1ff82ce20d0a5430d040a401e8f51ec2b7c9c11435e7741e39a6d005b896b5e41ec95635b3537925d3d63c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Roberto Vasquez Angel
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.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = RailsRad
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
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 = 'RailsRad'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,9 @@
1
+ module Controller
2
+ module JsonApiConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ respond_to :json
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module Controller
2
+ module ResourceConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :resource_class
7
+ end
8
+
9
+ class_methods do
10
+ def resource_class
11
+ name.gsub('Controller', '').constantize
12
+ end
13
+ end
14
+
15
+ def resource_class
16
+ self.class.resource_class
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module Controller
2
+ module ResourceInflectionsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :inflections
7
+ end
8
+
9
+ private
10
+
11
+ def inflections
12
+ {
13
+ resource_name: resource_class.model_name.human(count: 1),
14
+ collection_name: resource_class.model_name.human(count: 2)
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ module Controller
2
+ module ResourceUrlsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :collection_path,
7
+ :edit_resource_path,
8
+ :new_resource_path,
9
+ :resource_path
10
+ end
11
+
12
+ def collection_path
13
+ url_for(controller: controller_path, action: :index)
14
+ end
15
+
16
+ def new_resource_path
17
+ url_for(controller: controller_path, action: :new)
18
+ end
19
+
20
+ def edit_resource_path(resource)
21
+ url_for(controller: controller_path, action: :edit, id: resource.to_param)
22
+ end
23
+
24
+ def resource_path(resource)
25
+ url_for(controller: controller_path, action: :show, id: resource.to_param)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,68 @@
1
+ module Controller
2
+ module RestActionsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ respond_to :html
7
+ responders :flash
8
+ end
9
+
10
+ abstract_method :permitted_params
11
+
12
+ def index
13
+ @collection = load_collection
14
+ respond_with @collection
15
+ end
16
+
17
+ def new
18
+ @resource = initialize_resource
19
+ respond_with @resource
20
+ end
21
+
22
+ def create
23
+ @resource = resource_class.new(permitted_params)
24
+ @resource.save
25
+ respond_with @resource, location: collection_path
26
+ end
27
+
28
+ def show
29
+ @resource = load_resource
30
+ respond_with @resource
31
+ end
32
+
33
+ def edit
34
+ @resource = load_resource
35
+ respond_with @resource
36
+ end
37
+
38
+ def update
39
+ @resource = load_resource
40
+ @resource.update_attributes(permitted_params)
41
+ respond_with @resource, location: collection_path
42
+ end
43
+
44
+ def destroy
45
+ @resource = load_resource
46
+ @resource.destroy
47
+ respond_with @resource, location: collection_path
48
+ end
49
+
50
+ private
51
+
52
+ def collection_scope
53
+ resource_class
54
+ end
55
+
56
+ def initialize_resource
57
+ resource_class.new
58
+ end
59
+
60
+ def load_collection
61
+ collection_scope
62
+ end
63
+
64
+ def load_resource
65
+ resource_class.find(params[:id])
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,38 @@
1
+ module Controller
2
+ module ServiceActionsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ respond_to :html
7
+ responders :flash
8
+ end
9
+
10
+ def index
11
+ end
12
+
13
+ def invoke
14
+ @service = initialize_service
15
+ respond_with @service
16
+ end
17
+
18
+ def call
19
+ @service = prepare_service
20
+ @response = @service.do_work
21
+ if @response.success?
22
+ render :success
23
+ else
24
+ render :invoke
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def initialize_service
31
+ service_class.new
32
+ end
33
+
34
+ def prepare_service
35
+ service_class.new(permitted_params)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module Controller
2
+ module ServiceInflectionsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :inflections
7
+ end
8
+
9
+ private
10
+
11
+ def inflections
12
+ {
13
+ service_name: t("classes.#{service_class.name.underscore}")
14
+ }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ module Controller
2
+ module ServiceUrlsConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ helper_method :collection_path,
7
+ :call_service_path,
8
+ :invoke_service_path
9
+ end
10
+
11
+ def collection_path
12
+ url_for(controller: controller_path, action: :index)
13
+ end
14
+
15
+ def invoke_service_path
16
+ url_for(controller: controller_path, action: :invoke)
17
+ end
18
+
19
+ def call_service_path
20
+ url_for(controller: controller_path, action: :call)
21
+ end
22
+
23
+ # def edit_service_path(service)
24
+ # url_for(controller: controller_path, action: :edit, id: service.to_param)
25
+ # end
26
+
27
+ # def service_path(service)
28
+ # url_for(controller: controller_path, action: :show, id: service.to_param)
29
+ # end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ module RailsRad
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsRad
2
+ VERSION = '1.0.0'
3
+ end
data/lib/rails_rad.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'abstract_method'
2
+ require 'responders'
3
+ require 'rails_rad/engine'
4
+
5
+ module RailsRad
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_rad do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_rad
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Vasquez Angel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-28 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: abstract_method
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: responders
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: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Rails Rapid Application Development Tools.
70
+ email:
71
+ - roberto@vasquez-angel.de
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - MIT-LICENSE
77
+ - README.rdoc
78
+ - Rakefile
79
+ - app/controllers/concerns/controller/json_api_concern.rb
80
+ - app/controllers/concerns/controller/resource_concern.rb
81
+ - app/controllers/concerns/controller/resource_inflections_concern.rb
82
+ - app/controllers/concerns/controller/resource_urls_concern.rb
83
+ - app/controllers/concerns/controller/rest_actions_concern.rb
84
+ - app/controllers/concerns/controller/service_actions_concern.rb
85
+ - app/controllers/concerns/controller/service_inflections_concern.rb
86
+ - app/controllers/concerns/controller/service_urls_concern.rb
87
+ - lib/rails_rad.rb
88
+ - lib/rails_rad/engine.rb
89
+ - lib/rails_rad/version.rb
90
+ - lib/tasks/rails_rad_tasks.rake
91
+ homepage: https://github.com/robotex82/rails_rad
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Rails Rapid Application Development Tools
115
+ test_files: []
116
+ has_rdoc: