lispy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +19 -0
- data/Rakefile +8 -0
- data/lib/lispy.rb +25 -2
- data/lispy.gemspec +1 -1
- data/test/lispy_test.rb +31 -0
- metadata +6 -5
- data/lib/lispy/version.rb +0 -3
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Ryan Allen, Envato Pty Ltd
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
data/lib/lispy.rb
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
class Lispy
|
2
|
+
VERSION = '0.0.2'
|
3
|
+
class Builder
|
4
|
+
def _(&block)
|
5
|
+
@output = []
|
6
|
+
@scope = [@output]
|
7
|
+
instance_exec(&block)
|
8
|
+
@output
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(sym, *args, &block)
|
12
|
+
args = (args.length == 1 ? args.first : args)
|
13
|
+
@scope.last << [sym, args]
|
14
|
+
if block
|
15
|
+
@scope.last << []
|
16
|
+
@scope.push(@scope.last.last)
|
17
|
+
instance_exec(&block)
|
18
|
+
@scope.pop
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_data(&block)
|
24
|
+
Builder.new._(&block)
|
25
|
+
end
|
3
26
|
end
|
data/lispy.gemspec
CHANGED
data/test/lispy_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'lispy'
|
3
|
+
|
4
|
+
class LispyTest < Test::Unit::TestCase
|
5
|
+
def test_lispy
|
6
|
+
output = Lispy.new.to_data do
|
7
|
+
setup :workers => 30, :connections => 1024
|
8
|
+
http :access_log => :off do
|
9
|
+
server :listen => 80 do
|
10
|
+
location '/' do
|
11
|
+
doc_root '/var/www/website'
|
12
|
+
end
|
13
|
+
location '~ .php$' do
|
14
|
+
fcgi :port => 8877
|
15
|
+
script_root '/var/www/website'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
expected_output = [[:setup, {:workers=>30, :connections=>1024}],
|
22
|
+
[:http, {:access_log=>:off}],
|
23
|
+
[[:server, {:listen=>80}],
|
24
|
+
[[:location, "/"],
|
25
|
+
[[:doc_root, "/var/www/website"]],
|
26
|
+
[:location, "~ .php$"],
|
27
|
+
[[:fcgi, {:port=>8877}], [:script_root, "/var/www/website"]]]]]
|
28
|
+
|
29
|
+
assert_equal output, expected_output
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Allen
|
@@ -30,10 +30,11 @@ extra_rdoc_files: []
|
|
30
30
|
files:
|
31
31
|
- .gitignore
|
32
32
|
- Gemfile
|
33
|
+
- MIT-LICENSE
|
33
34
|
- Rakefile
|
34
35
|
- lib/lispy.rb
|
35
|
-
- lib/lispy/version.rb
|
36
36
|
- lispy.gemspec
|
37
|
+
- test/lispy_test.rb
|
37
38
|
has_rdoc: true
|
38
39
|
homepage: http://rubygems.org/gems/lispy
|
39
40
|
licenses: []
|
@@ -66,5 +67,5 @@ rubygems_version: 1.3.7
|
|
66
67
|
signing_key:
|
67
68
|
specification_version: 3
|
68
69
|
summary: Code as data in Ruby, without the metaprogramming madness.
|
69
|
-
test_files:
|
70
|
-
|
70
|
+
test_files:
|
71
|
+
- test/lispy_test.rb
|
data/lib/lispy/version.rb
DELETED