lispy 0.0.1 → 0.0.2

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.
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
@@ -1,2 +1,10 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ task :default do
5
+ Rake::Task['run_tests'].invoke
6
+ end
7
+
8
+ task :run_tests do
9
+ require 'test/lispy_test'
10
+ end
data/lib/lispy.rb CHANGED
@@ -1,3 +1,26 @@
1
- module Lispy
2
- # Your code goes here...
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
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "lispy/version"
3
+ require "lispy"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "lispy"
@@ -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
- - 1
9
- version: 0.0.1
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
@@ -1,3 +0,0 @@
1
- module Lispy
2
- VERSION = "0.0.1"
3
- end