rails-dsl 0.4.1 → 0.5.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
2
  SHA1:
3
- metadata.gz: e002eeafc2ccfe491ccb4c9f159e88086a35a510
4
- data.tar.gz: 1d972d46a8325b825d544781d2ef61b232b55408
3
+ metadata.gz: 28ac803dffa3744ccce833bf85dcb49b2bc545cf
4
+ data.tar.gz: 425b7f21bfe2063cffea599e0cd5eddf5f312706
5
5
  SHA512:
6
- metadata.gz: 1628d1b0e72ddd6714c076e3b4eeb181d4a89d7490a0ce1736b2df6b1cb6d3b452c9284f6ae4787713ce5015d1a901258369121028ad2cbd5170d53e40c5faf6
7
- data.tar.gz: b5c0ca8fef074376e9903610c36e2d2ab6efc1403d282e37e8fd1f21bf7ead550015cb3f2523bd02643f3a321f1fee1c40f7db7aa732352a332c1284eef7f818
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/:hello.:format path
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
- mount_controller_as_api :pages
116
+ mount_controller_with_render :pages
113
117
 
114
118
  # or as alias
115
- mount_api :pages
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
- mount_api :pages, defaults: { format: :xml }
123
+ mount_rendered_controllers :pages, defaults: { format: :xml }
120
124
 
121
125
  end
122
126
 
123
- #> mount not private methods as apit from PagesController
127
+ ```
124
128
 
125
- ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -0,0 +1,5 @@
1
+ # in most of my project i use a boor.rb file in the libs folder for 3. party libs
2
+ Thread.new do
3
+ sleep(0.5) while Rails.root.nil?
4
+ require Rails.root.join('lib','boot.rb') if File.exist?(Rails.root.join('lib','boot.rb'))
5
+ end
@@ -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
- method_to_use ||= :get
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 mount_controller_as_api *args
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, { defaults: {format: :json} }
200
+ mount_controller *args,*conv_params #, { defaults: {format: :json} }
202
201
 
203
202
  return nil
204
203
 
205
204
  end
206
- alias mount_api mount_controller_as_api
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.1
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-23 00:00:00.000000000 Z
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