apex 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/lib/apex/apex.rb +0 -1
- data/lib/apex/mime_types.rb +1 -1
- data/lib/apex/server.rb +21 -11
- data/lib/apex/version.rb +1 -1
- data/spec/unit/request_get_spec.rb +3 -3
- data/spec/unit/server_spec.rb +107 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24a9d0530a8e0f20a245e5f094cc057e48b3c65c
|
4
|
+
data.tar.gz: 92537d8ff5a9b0956defdbfdc322fece2b83ca17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf2408a5939d42e72484144006d4741bb27e48aba9c3f5f5f3be4024cc493041161d7107d767bb00737815cbd17c59dc743619be1fc4699d826eb64b22d11f2
|
7
|
+
data.tar.gz: e53dcbb163dbe738a47b06deb491eef898bb3af9da1894c6244cdd7d3a42cf3912c9101aca4a780fa3d2089fef3ec63d9fcfb3ed9371e5aab2baeb322cf743cb
|
data/README.md
CHANGED
@@ -7,11 +7,13 @@ router and DSL.
|
|
7
7
|
Apex is currently experimental and in development. Let me know
|
8
8
|
what you think [on Twitter](http://twitter.com/jamonholmgren).
|
9
9
|
|
10
|
+
Apex is a research project of [Infinite Red](http://infinite.red), a web and mobile development company based in Portland, OR and San Francisco, CA.
|
11
|
+
|
10
12
|
## Installation
|
11
13
|
|
12
14
|
```ruby
|
13
15
|
# In Gemfile:
|
14
|
-
gem 'apex', :git => 'https://github.com/
|
16
|
+
gem 'apex', :git => 'https://github.com/infinitered/apex.git'
|
15
17
|
|
16
18
|
# In Terminal:
|
17
19
|
bundle install
|
@@ -40,6 +42,12 @@ class AppDelegate < Apex::Server
|
|
40
42
|
"<p><a href='/about'>About Apex</a></p>"
|
41
43
|
end
|
42
44
|
|
45
|
+
# You can send an array and both paths
|
46
|
+
# will have the same response
|
47
|
+
get ["path1", "path2"] do |r|
|
48
|
+
"Path 1 and 2"
|
49
|
+
end
|
50
|
+
|
43
51
|
get "/about" do |r|
|
44
52
|
"<h1>About Apex</h1>" +
|
45
53
|
"<p><a href='/'>Home</a></p>"
|
@@ -77,7 +85,7 @@ class AboutController < Apex::Controller
|
|
77
85
|
def about
|
78
86
|
render :about
|
79
87
|
end
|
80
|
-
|
88
|
+
|
81
89
|
def me
|
82
90
|
render :me, name: "Jamon"
|
83
91
|
end
|
@@ -87,7 +95,7 @@ def AboutView < Apex::View
|
|
87
95
|
def about
|
88
96
|
"<h1>About</h1>"
|
89
97
|
end
|
90
|
-
|
98
|
+
|
91
99
|
def me(args={})
|
92
100
|
"<h1>Me #{args[:name]}</h1>"
|
93
101
|
end
|
@@ -102,7 +110,7 @@ def AboutLayout < Apex::Layout
|
|
102
110
|
"<body>#{content}</body>" +
|
103
111
|
"</html>"
|
104
112
|
end
|
105
|
-
|
113
|
+
|
106
114
|
# Potentially, a Ruby DSL for HTML:
|
107
115
|
def render
|
108
116
|
html do
|
data/lib/apex/apex.rb
CHANGED
data/lib/apex/mime_types.rb
CHANGED
data/lib/apex/server.rb
CHANGED
@@ -103,24 +103,34 @@ module Apex
|
|
103
103
|
|
104
104
|
# Class methods *************************
|
105
105
|
|
106
|
-
def self.get(
|
107
|
-
|
106
|
+
def self.get(paths, args={}, &block)
|
107
|
+
Array(paths).each do |path|
|
108
|
+
routes[:get][path] = { handler: block, layout: args[:layout], response_type: args[:response_type] }
|
109
|
+
end
|
108
110
|
end
|
109
111
|
|
110
|
-
def self.post(
|
111
|
-
|
112
|
+
def self.post(paths, args={}, &block)
|
113
|
+
Array(paths).each do |path|
|
114
|
+
routes[:post][path] = { handler: block, layout: args[:layout], response_type: args[:response_type] }
|
115
|
+
end
|
112
116
|
end
|
113
117
|
|
114
|
-
def self.put(
|
115
|
-
|
118
|
+
def self.put(paths, args={}, &block)
|
119
|
+
Array(paths).each do |path|
|
120
|
+
routes[:put][path] = { handler: block, layout: args[:layout], response_type: args[:response_type] }
|
121
|
+
end
|
116
122
|
end
|
117
123
|
|
118
|
-
def self.patch(
|
119
|
-
|
124
|
+
def self.patch(paths, args={}, &block)
|
125
|
+
Array(paths).each do |path|
|
126
|
+
routes[:patch][path] = { handler: block, layout: args[:layout], response_type: args[:response_type] }
|
127
|
+
end
|
120
128
|
end
|
121
129
|
|
122
|
-
def self.delete(
|
123
|
-
|
130
|
+
def self.delete(paths, args={}, &block)
|
131
|
+
Array(paths).each do |path|
|
132
|
+
routes[:delete][path] = { handler: block, layout: args[:layout], response_type: args[:response_type] }
|
133
|
+
end
|
124
134
|
end
|
125
135
|
|
126
136
|
def self.routes
|
@@ -145,4 +155,4 @@ module Apex
|
|
145
155
|
end
|
146
156
|
|
147
157
|
end
|
148
|
-
end
|
158
|
+
end
|
data/lib/apex/version.rb
CHANGED
@@ -41,9 +41,9 @@ describe "Apex::Request GET request" do
|
|
41
41
|
request.headers.should == headers
|
42
42
|
end
|
43
43
|
|
44
|
-
it "#content_length" do
|
45
|
-
|
46
|
-
end
|
44
|
+
# it "#content_length" do
|
45
|
+
# request.content_length.should == 9223372036854775807
|
46
|
+
# end
|
47
47
|
|
48
48
|
it "#query" do
|
49
49
|
request.query.should == query
|
@@ -0,0 +1,107 @@
|
|
1
|
+
describe "Apex::Server" do
|
2
|
+
|
3
|
+
class BlankServer < Apex::Server
|
4
|
+
end
|
5
|
+
|
6
|
+
class PortServer < Apex::Server
|
7
|
+
port 8085
|
8
|
+
end
|
9
|
+
|
10
|
+
class RouteServer < Apex::Server
|
11
|
+
get '/test' do |r|
|
12
|
+
"response"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class MultiRouteServer < Apex::Server
|
17
|
+
get ['/test', '/anothertest'] do |r|
|
18
|
+
"response"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
before do
|
23
|
+
@blank = BlankServer.new
|
24
|
+
@port = PortServer.new
|
25
|
+
@route = RouteServer.new
|
26
|
+
@multiroute = MultiRouteServer.new
|
27
|
+
|
28
|
+
@servers = [@blank, @port, @route, @multiroute]
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
# Stop and delete the servers.
|
33
|
+
@servers.each do |s|
|
34
|
+
s.stop
|
35
|
+
s = nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be a GCDWebServer" do
|
40
|
+
@blank.server.is_a?(GCDWebServer).should == true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should start the server" do
|
44
|
+
@blank.server.isRunning.should == false
|
45
|
+
@blank.start
|
46
|
+
wait 0.5 do
|
47
|
+
@blank.server.isRunning.should == true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should have a default port" do
|
52
|
+
@blank.port.should == 8080
|
53
|
+
@blank.start
|
54
|
+
wait 0.5 do
|
55
|
+
@blank.server.port.should == 8080
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have a customizable port" do
|
60
|
+
@port.port.should == 8085
|
61
|
+
@port.start
|
62
|
+
wait 0.5 do
|
63
|
+
@port.server.port.should == 8085
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have routes" do
|
68
|
+
routes = @route.routes[:get]
|
69
|
+
routes.is_a?(Hash).should == true
|
70
|
+
routes.count.should == 1
|
71
|
+
|
72
|
+
routes['/test'][:handler].call.should == "response"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should have multiple routes with the same responder" do
|
76
|
+
routes = @multiroute.routes[:get]
|
77
|
+
routes.count.should == 2
|
78
|
+
|
79
|
+
routes['/test'][:handler].call.should == "response"
|
80
|
+
routes['/anothertest'][:handler].call.should == "response"
|
81
|
+
end
|
82
|
+
|
83
|
+
# TODO - implement this test. It's failing for some reason because the
|
84
|
+
# the response is nil.
|
85
|
+
|
86
|
+
# it "should serve assets from resources/assets" do
|
87
|
+
# url = NSURL.URLWithString("http://localhost:8080/somefile.txt")
|
88
|
+
#
|
89
|
+
# session = NSURLSession.sharedSession
|
90
|
+
# session.dataTaskWithURL(url, completionHandler: -> data, response, error {
|
91
|
+
# @response = {
|
92
|
+
# string: NSString.alloc.initWithData(data, encoding:NSUTF8StringEncoding),
|
93
|
+
# data: data,
|
94
|
+
# response: response,
|
95
|
+
# erorr: error,
|
96
|
+
# }
|
97
|
+
# resume
|
98
|
+
# }).resume
|
99
|
+
#
|
100
|
+
# wait do
|
101
|
+
# @response[:error].should.be.nil
|
102
|
+
# @response[:string].should == "somefile contents\n"
|
103
|
+
# @response[:response].statusCode.should == 200
|
104
|
+
# end
|
105
|
+
# end
|
106
|
+
|
107
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamon Holmgren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: motion-cocoapods
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/apex/server.rb
|
56
56
|
- lib/apex/version.rb
|
57
57
|
- spec/unit/request_get_spec.rb
|
58
|
+
- spec/unit/server_spec.rb
|
58
59
|
homepage: https://github.com/clearsightstudio/apex
|
59
60
|
licenses:
|
60
61
|
- MIT
|
@@ -75,10 +76,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
76
|
version: '0'
|
76
77
|
requirements: []
|
77
78
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
79
|
+
rubygems_version: 2.2.2
|
79
80
|
signing_key:
|
80
81
|
specification_version: 4
|
81
82
|
summary: Apex is a RubyMotion web framework for OS X. It uses GCDWebServer under the
|
82
83
|
hood and provides a Sinatra-like router and DSL.
|
83
84
|
test_files:
|
84
85
|
- spec/unit/request_get_spec.rb
|
86
|
+
- spec/unit/server_spec.rb
|