astaire 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/LICENSE +21 -0
  2. data/README +3 -0
  3. data/lib/astaire.rb +38 -0
  4. metadata +78 -0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Carl Lerche
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README ADDED
@@ -0,0 +1,3 @@
1
+ A first pass at the basic Sinatra DSL inside of a Rails controller. There is
2
+ still a lot to do obviously, but see examples/hello_world.ru for a starting
3
+ point.
data/lib/astaire.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'active_support/concern'
2
+ require 'action_controller'
3
+
4
+ module Astaire
5
+ module DSL
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ unless respond_to?(:_router)
10
+ def self._router
11
+ @_router ||= ActionDispatch::Routing::RouteSet.new
12
+ end
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ def call(env)
18
+ _router.call(env)
19
+ rescue ActionController::RoutingError
20
+ [404, {'Content-Type' => 'text/html', 'X-Cascade' => 'pass'}, []]
21
+ end
22
+
23
+ def mapper
24
+ @mapper ||= ActionDispatch::Routing::Mapper.new(_router)
25
+ end
26
+
27
+ %w(get post put delete).each do |method|
28
+ class_eval <<-R, __FILE__, __LINE__+1
29
+ def #{method}(path, opts = {}, &blk)
30
+ action_name = "[#{method}] \#{path}"
31
+ define_method action_name, &blk
32
+ mapper.match(path, :via => '#{method}', :to => action(action_name))
33
+ end
34
+ R
35
+ end
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: astaire
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Carl Lerche
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-01 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: actionpack
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 0
30
+ - 0
31
+ - beta2
32
+ version: 3.0.0.beta2
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Allows the use of get, post, put, and delete to define actions and then allows the controller constant to be used as a rack application.
36
+ email: clerche@engineyard.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README
45
+ - LICENSE
46
+ - lib/astaire.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/carllerche/astaire
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.6
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: The basic Sinatra DSL inside of ActionController
77
+ test_files: []
78
+