Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
H
heroku-buildpack-static
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Python-Dev
heroku-buildpack-static
Commits
0c419eec
Commit
0c419eec
authored
Jun 25, 2015
by
Terence Lee
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from ojacobson/to_regex-tests
Verify to_regex in tests.
parents
5ebdbba7
fc128f43
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
make-config
scripts/config/make-config
+6
-6
glob_to_regex_spec.rb
spec/glob_to_regex_spec.rb
+18
-0
No files found.
scripts/config/make-config
View file @
0c419eec
...
...
@@ -25,7 +25,7 @@ class NginxConfig
end
json
[
"clean_urls"
]
||=
false
json
[
"routes"
]
||=
{}
json
[
"routes"
]
=
Hash
[
json
[
"routes"
].
map
{
|
route
,
target
|
[
to_regex
(
route
),
target
]
}]
json
[
"routes"
]
=
Hash
[
json
[
"routes"
].
map
{
|
route
,
target
|
[
self
.
class
.
to_regex
(
route
),
target
]
}]
json
[
"redirects"
]
||=
{}
json
[
"error_page"
]
||=
nil
json
.
each
do
|
key
,
value
|
...
...
@@ -37,8 +37,7 @@ class NginxConfig
binding
end
private
def
to_regex
(
path
)
def
self
.
to_regex
(
path
)
segments
=
[]
while
!
path
.
empty?
if
path
[
0
...
2
]
==
'**'
...
...
@@ -57,6 +56,7 @@ class NginxConfig
end
end
erb
=
ERB
.
new
(
File
.
read
(
TEMPLATE
)).
result
(
NginxConfig
.
new
(
USER_CONFIG
).
context
)
File
.
write
(
NGINX_CONFIG
,
erb
)
if
__FILE__
==
$0
erb
=
ERB
.
new
(
File
.
read
(
TEMPLATE
)).
result
(
NginxConfig
.
new
(
USER_CONFIG
).
context
)
File
.
write
(
NGINX_CONFIG
,
erb
)
end
spec/glob_to_regex_spec.rb
0 → 100644
View file @
0c419eec
require_relative
"spec_helper"
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'../scripts/config/make-config'
)
RSpec
.
describe
"NginxConfig#to_regex"
do
samples
=
[
[
'/foo/'
,
'/foo/'
],
[
'/foo/*'
,
'/foo/[^/]*'
],
[
'/foo/**'
,
'/foo/.*'
],
[
'/cache/*'
,
'/cache/[^/]*'
],
]
samples
.
each
do
|
(
input
,
output
)
|
it
"converts
#{
input
}
to
#{
output
}
"
do
result
=
NginxConfig
.
to_regex
(
input
)
expect
(
result
).
to
eq
output
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment