moonrope 1.0.2 → 1.1.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: c8b593150a49e68ef4e6e65a53e85d5a0019dca6
4
- data.tar.gz: 3a66ef2835eab41db4c1e573aec64ce9e1b4a856
3
+ metadata.gz: c2c07e3a6cf5bed85f04b415aba7c0a93eaac01c
4
+ data.tar.gz: 54224342f109ced1f812419c23453d63538b3af3
5
5
  SHA512:
6
- metadata.gz: a5b02ff09a48fdb09103ad87a35dba4a0be1b9f9a6b41a020d710837ad9a9a2b1552767134cd04aa915c16bbfd075f7e13831554491e672fa0504ce37da8de44
7
- data.tar.gz: c936bdbfd4059fbf931fd0626deb45832e4e096ccc5024db8f359934bd7d71a99a5b918d6c4336481a6192876266999d77220872dc6b6361f4bdc153ccc0ee9d
6
+ metadata.gz: 6d10f3add6366036c7ed1355d9b03ad53629019a16bbb3689b0e70b0cc01e9740bcee698dcd0fc26a386609676bbff9e7852a4a4da5a81c89d26a0099e56bd96
7
+ data.tar.gz: 38d91c152c7208dcda97cf6e3ddb5ee95a5146c3790c4739b43da8513e45cfddd1951620379d7597a6eb1898716a0bcb74167f358043f3e463de4c7dbe4696a1
@@ -22,7 +22,7 @@ module Moonrope
22
22
  # @return [Array] a rack triplet
23
23
  #
24
24
  def call(env)
25
- if env['PATH_INFO'] =~ Moonrope::Request::PATH_REGEX
25
+ if env['PATH_INFO'] =~ Moonrope::Request.path_regex
26
26
 
27
27
  if @options[:reload_on_each_request]
28
28
  @base.load
@@ -9,12 +9,17 @@ module Moonrope
9
9
  if File.directory?(moonrope_directory)
10
10
  app.config.moonrope = Moonrope::Base.load(moonrope_directory)
11
11
  else
12
- $stderr.puts "Moonrope is installed but there is no API directory at ROOT/app/api."
12
+ $stderr.puts "Moonrope is installed but there is no API directory at ROOT/api."
13
13
  next
14
14
  end
15
15
 
16
16
  # Set the logger
17
17
  Moonrope.logger = Rails.logger
18
+
19
+ # Set the request regex if one has been set
20
+ if app.config.respond_to?(:moonrope_request_path_regex) && app.config.moonrope_request_path_regex.is_a?(Regexp)
21
+ Moonrope::Request.path_regex = app.config.moonrope_request_path_regex
22
+ end
18
23
 
19
24
  # Insert the Moonrope middleware into the application's middleware
20
25
  # stack (at the bottom).
@@ -1,9 +1,14 @@
1
1
  module Moonrope
2
2
  class Request
3
-
4
- # The path which will be intercepted by the Rack middleware
5
- # and that all reuqest will arrive on.
6
- PATH_REGEX = /\A\/api\/([\w\/\-\.]+)?/
3
+
4
+ class << self
5
+ attr_accessor :path_regex
6
+
7
+ # @return [Regex] the regex which should be matched for all API requests
8
+ def path_regex
9
+ @path_regex ||= /\A\/api\/([\w\/\-\.]+)?/
10
+ end
11
+ end
7
12
 
8
13
  # @return [Hash] the rack environment
9
14
  attr_reader :env
@@ -24,7 +29,7 @@ module Moonrope
24
29
  def initialize(base, env, path = nil)
25
30
  @base = base
26
31
  @env = env
27
- if path.nil? && env['PATH_INFO'] =~ PATH_REGEX
32
+ if path.nil? && env['PATH_INFO'] =~ self.class.path_regex
28
33
  path = $1
29
34
  end
30
35
  @version, @controller_name, @action_name = path ? path.split("/") : [nil, nil, nil]
@@ -1,3 +1,3 @@
1
1
  module Moonrope
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonrope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-07 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.8'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.5'
33
+ version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.5'
40
+ version: '1.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement