florida 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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +7 -0
- data/Guardfile +33 -0
- data/README.md +7 -3
- data/lib/florida.rb +1 -0
- data/lib/florida/application.rb +1 -9
- data/lib/florida/application/base.rb +11 -0
- data/lib/florida/controller/base.rb +13 -0
- data/lib/florida/router.rb +14 -0
- data/lib/florida/sinatra_server.rb +34 -0
- data/lib/florida/sinatra_server/router.rb +42 -0
- data/lib/florida/version.rb +1 -1
- data/spec/florida/request_spec.rb +64 -0
- data/test/application_test.rb +14 -4
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 790c8e349e5160cb793028d3231fb10a6feacf60
|
4
|
+
data.tar.gz: 135a9d5d0842e18a075222f737cafd4566922ee8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57e5331ce69da69f4adb1d379686a9a123f7bc3529c46ed8a61f5c0c22e69aadab9fb4cd57aa0a92ed717973d6ccf21540f1ee6de64b9e1c692f76385ac1e600
|
7
|
+
data.tar.gz: 7efbe79e64e0c6baab155022514940c75741d642e37de888fc4783a34eb071fe1e38ead6762876af86bc7a292ce1a5563d97b27b04add8410c05a34d1ca13e03
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
5
|
+
# rspec may be run, below are examples of the most common uses.
|
6
|
+
# * bundler: 'bundle exec rspec'
|
7
|
+
# * bundler binstubs: 'bin/rspec'
|
8
|
+
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
9
|
+
# installed the spring binstubs per the docs)
|
10
|
+
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
11
|
+
# * 'just' rspec: 'rspec'
|
12
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
13
|
+
watch(%r{^spec/.+_spec\.rb$})
|
14
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
15
|
+
watch('spec/spec_helper.rb') { "spec" }
|
16
|
+
|
17
|
+
# Rails example
|
18
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
19
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
20
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
21
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
22
|
+
watch('config/routes.rb') { "spec/routing" }
|
23
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
24
|
+
watch('spec/rails_helper.rb') { "spec" }
|
25
|
+
|
26
|
+
# Capybara features specs
|
27
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
28
|
+
|
29
|
+
# Turnip features and steps
|
30
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
31
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
32
|
+
end
|
33
|
+
|
data/README.md
CHANGED
@@ -25,13 +25,17 @@ write application ruby script.
|
|
25
25
|
```ruby
|
26
26
|
require 'florida'
|
27
27
|
|
28
|
-
class
|
29
|
-
|
28
|
+
class HomeController < Florida::Controller::Base
|
29
|
+
def index
|
30
30
|
'Hello Florida!!'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
MyApplication
|
34
|
+
class MyApplication < Florida::Application::Base
|
35
|
+
routings do
|
36
|
+
path "/", to: HomeController
|
37
|
+
end
|
38
|
+
end
|
35
39
|
```
|
36
40
|
|
37
41
|
and script execute in ruby.
|
data/lib/florida.rb
CHANGED
data/lib/florida/application.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
class Florida::SinatraServer; end
|
5
|
+
require 'florida/sinatra_server/router'
|
6
|
+
|
7
|
+
module Florida
|
8
|
+
class SinatraServer
|
9
|
+
attr_reader :sinatra_app
|
10
|
+
|
11
|
+
def initialize(app, params = {})
|
12
|
+
@sinatra_app = Class.new(Sinatra::Base)
|
13
|
+
@params = params
|
14
|
+
setup(app)
|
15
|
+
end
|
16
|
+
|
17
|
+
def application
|
18
|
+
@sinatra_app
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
Rack::Server.start(app: @sinatra_app.new, Port: @params[:port] || 4567)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.run(app, params = {})
|
26
|
+
self.new(app, params).run
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def setup(app)
|
31
|
+
Router.setup(app, @sinatra_app)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class Florida::SinatraServer::Router
|
2
|
+
def initialize(app, sinatra)
|
3
|
+
@app = app
|
4
|
+
@sinatra = sinatra
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.setup(app, sinatra)
|
8
|
+
self.new(app, sinatra).routing!
|
9
|
+
end
|
10
|
+
|
11
|
+
def routing!
|
12
|
+
@app.routings.each do |path, data|
|
13
|
+
setup_routing(path, data)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def setup_routing(path, params)
|
19
|
+
controller_class = params[:to]
|
20
|
+
controller = controller_class.new
|
21
|
+
|
22
|
+
if controller.respond_to? :index
|
23
|
+
@sinatra.get self.class.index_routing_matcher(path) do
|
24
|
+
controller_class.new(self).index
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if controller.respond_to? :show
|
29
|
+
@sinatra.get(self.class.show_routing_matcher(path)) do
|
30
|
+
controller_class.new(self).show(self.params[:captures].first)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.index_routing_matcher(path)
|
36
|
+
%r{\A#{path}(\.[\w]+)?/?\z}
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.show_routing_matcher(path)
|
40
|
+
%r{\A#{path}/(\w+)(\.[\w]+)?/?\z}
|
41
|
+
end
|
42
|
+
end
|
data/lib/florida/version.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'florida'
|
2
|
+
|
3
|
+
ENV['RACK_ENV'] = 'test'
|
4
|
+
require 'rack/test'
|
5
|
+
|
6
|
+
describe Florida do
|
7
|
+
describe "Application" do
|
8
|
+
include Rack::Test::Methods
|
9
|
+
|
10
|
+
let!(:example_application) do
|
11
|
+
class HomeController < Florida::Controller::Base
|
12
|
+
def index
|
13
|
+
'Hello Florida!!'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class ExampleController < Florida::Controller::Base
|
18
|
+
def index
|
19
|
+
'This is example index page.'
|
20
|
+
end
|
21
|
+
|
22
|
+
def show(id)
|
23
|
+
"This is example of #{id}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class MyApplication < Florida::Application::Base
|
28
|
+
routings do
|
29
|
+
path "/", to: HomeController
|
30
|
+
path "/examples", to: ExampleController
|
31
|
+
end
|
32
|
+
end
|
33
|
+
MyApplication
|
34
|
+
end
|
35
|
+
|
36
|
+
def app
|
37
|
+
Florida::SinatraServer.new(example_application).application
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "access to /" do
|
41
|
+
before do
|
42
|
+
get '/'
|
43
|
+
end
|
44
|
+
it { expect(last_response).to be_ok }
|
45
|
+
it { expect(last_response.body).to eq 'Hello Florida!!' }
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "access to /examples" do
|
49
|
+
before do
|
50
|
+
get '/examples'
|
51
|
+
end
|
52
|
+
it { expect(last_response).to be_ok }
|
53
|
+
it { expect(last_response.body).to eq 'This is example index page.' }
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "access to /examples/1" do
|
57
|
+
before do
|
58
|
+
get '/examples/1'
|
59
|
+
end
|
60
|
+
it { expect(last_response).to be_ok }
|
61
|
+
it { expect(last_response.body).to eq 'This is example of 1' }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/test/application_test.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
$:.unshift File.expand_path('../lib/', File.dirname(__FILE__))
|
2
2
|
require 'florida'
|
3
3
|
|
4
|
-
class
|
5
|
-
|
6
|
-
'Hello
|
4
|
+
class HomeController < Florida::Controller::Base
|
5
|
+
def index
|
6
|
+
'Hello Index!!'
|
7
|
+
end
|
8
|
+
|
9
|
+
def show(id)
|
10
|
+
"This page is #{id}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class MyApplication < Florida::Application::Base
|
15
|
+
routings do
|
16
|
+
path "/home", to: HomeController
|
7
17
|
end
|
8
18
|
end
|
9
19
|
|
10
|
-
|
20
|
+
Florida::SinatraServer.run(MyApplication)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: florida
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- myun2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -61,13 +61,20 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
63
|
- Gemfile
|
64
|
+
- Guardfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
67
68
|
- florida.gemspec
|
68
69
|
- lib/florida.rb
|
69
70
|
- lib/florida/application.rb
|
71
|
+
- lib/florida/application/base.rb
|
72
|
+
- lib/florida/controller/base.rb
|
73
|
+
- lib/florida/router.rb
|
74
|
+
- lib/florida/sinatra_server.rb
|
75
|
+
- lib/florida/sinatra_server/router.rb
|
70
76
|
- lib/florida/version.rb
|
77
|
+
- spec/florida/request_spec.rb
|
71
78
|
- test/application_test.rb
|
72
79
|
homepage: ''
|
73
80
|
licenses:
|
@@ -94,4 +101,5 @@ signing_key:
|
|
94
101
|
specification_version: 4
|
95
102
|
summary: Sinatra Based web Application framework.
|
96
103
|
test_files:
|
104
|
+
- spec/florida/request_spec.rb
|
97
105
|
- test/application_test.rb
|