rails-dsl 0.4.1 → 0.5.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.
- checksums.yaml +4 -4
- data/README.md +10 -7
- data/VERSION +1 -1
- data/lib/rails-dsl/lib_boot.rb +5 -0
- data/lib/rails-dsl/routes_ext.rb +19 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ac803dffa3744ccce833bf85dcb49b2bc545cf
|
4
|
+
data.tar.gz: 425b7f21bfe2063cffea599e0cd5eddf5f312706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8270415bedbca72fb39c2bba9a0f86725310519a83b6179682ab64ae7655acb36de4f12c270f93b7074614caa8e9d6f38b597a22d6fdf34782c935b64043dc4
|
7
|
+
data.tar.gz: dfb45f90b3ee7901f0a1702e1892affc740a2e9db030b725bf2ff0f3c038c9945523968d023af8e4b3ff21c1008d00b9fd2c351dd7ac4d17ad75dea777286f69
|
data/README.md
CHANGED
@@ -3,6 +3,8 @@ rails-dsl
|
|
3
3
|
|
4
4
|
Provide Rails with some extra helpers,
|
5
5
|
|
6
|
+
### Controller
|
7
|
+
|
6
8
|
For example for to ActionController::Base a 'duck_params' that parse string values into the right obj,
|
7
9
|
like:
|
8
10
|
|
@@ -13,6 +15,8 @@ like:
|
|
13
15
|
* "2011-03-12" to Date obj
|
14
16
|
* etc etc etc
|
15
17
|
|
18
|
+
### Terminal
|
19
|
+
|
16
20
|
if you call rails with 'kill' / 'k' command from now on, it will kill the application by it's pid file
|
17
21
|
|
18
22
|
$ rails kill
|
@@ -92,15 +96,15 @@ in this mount options
|
|
92
96
|
{hello: hello }
|
93
97
|
end
|
94
98
|
|
95
|
-
#> this generate /test2
|
99
|
+
#> this generate /test2.:format path
|
96
100
|
def test2
|
97
101
|
{hello: 'hello' }
|
98
102
|
end
|
99
103
|
|
104
|
+
#> POST /test.:format -> default json
|
100
105
|
def test2_post
|
101
106
|
{hello: 'blabla' }
|
102
107
|
end
|
103
|
-
#> POST /test.:format -> default json
|
104
108
|
|
105
109
|
end
|
106
110
|
|
@@ -109,17 +113,16 @@ in this mount options
|
|
109
113
|
HeartShoot::Application.routes.draw do
|
110
114
|
|
111
115
|
# you can still use the Class name too
|
112
|
-
|
116
|
+
mount_controller_with_render :pages
|
113
117
|
|
114
118
|
# or as alias
|
115
|
-
|
119
|
+
mount_rendered_controllers :pages
|
116
120
|
|
117
121
|
# or you can use well defaults key to set up parameters
|
118
122
|
# if you prefer the XML as default over JSON output
|
119
|
-
|
123
|
+
mount_rendered_controllers :pages, defaults: { format: :xml }
|
120
124
|
|
121
125
|
end
|
122
126
|
|
123
|
-
|
127
|
+
```
|
124
128
|
|
125
|
-
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/rails-dsl/routes_ext.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module Rails
|
2
2
|
module DSL
|
3
|
-
|
4
3
|
module ActionDispatchRouteEXT
|
5
4
|
|
6
5
|
module Helpers
|
@@ -113,7 +112,6 @@ module Rails
|
|
113
112
|
|
114
113
|
end
|
115
114
|
|
116
|
-
|
117
115
|
end
|
118
116
|
end
|
119
117
|
|
@@ -138,7 +136,8 @@ module Rails
|
|
138
136
|
method_to_use ||= pre_spec_method_call_type
|
139
137
|
end
|
140
138
|
end
|
141
|
-
|
139
|
+
|
140
|
+
method_to_use ||= :match
|
142
141
|
|
143
142
|
url_path = opts[:urls][method_name].nil? ? "/#{method_name}" : opts[:urls][method_name].to_s
|
144
143
|
|
@@ -163,7 +162,7 @@ module Rails
|
|
163
162
|
|
164
163
|
end
|
165
164
|
|
166
|
-
def
|
165
|
+
def mount_controller_with_render *args
|
167
166
|
|
168
167
|
opts= Rails::DSL::ActionDispatchRouteEXT::Helpers.process_args(*args)
|
169
168
|
conv_params= []
|
@@ -198,12 +197,26 @@ module Rails
|
|
198
197
|
end
|
199
198
|
|
200
199
|
# mount controller methods
|
201
|
-
mount_controller *args,*conv_params
|
200
|
+
mount_controller *args,*conv_params #, { defaults: {format: :json} }
|
202
201
|
|
203
202
|
return nil
|
204
203
|
|
205
204
|
end
|
206
|
-
alias
|
205
|
+
alias mount_rendered_controller mount_controller_with_render
|
206
|
+
|
207
|
+
def get_controller_names *path
|
208
|
+
path += ['app','controllers','*_controller.{ru,rb}'] if path.empty?
|
209
|
+
return Dir.glob(::Rails.root.join(*path)).map{|p| p.split(File::Separator).last.split('_controller')[0].to_sym }
|
210
|
+
end
|
211
|
+
|
212
|
+
def mount_controllers
|
213
|
+
get_controller_names.each { |cn| mount_controller(cn) }
|
214
|
+
end
|
215
|
+
|
216
|
+
def mount_controllers_with_render
|
217
|
+
get_controller_names.each{ |cn| mount_controller_with_render(cn) }
|
218
|
+
end
|
219
|
+
alias mount_rendered_controllers mount_controllers_with_render
|
207
220
|
|
208
221
|
end
|
209
222
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-dsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- lib/rails-dsl.rb
|
82
82
|
- lib/rails-dsl/duck_params.rb
|
83
83
|
- lib/rails-dsl/kill_server.rb
|
84
|
+
- lib/rails-dsl/lib_boot.rb
|
84
85
|
- lib/rails-dsl/routes_ext.rb
|
85
86
|
- rails-dsl.gemspec
|
86
87
|
homepage: https://github.com/adamluzsi/rails-dsl
|