gothonweb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/gothonweb.gemspec +24 -0
- data/index.erb +14 -0
- data/lib/gothonweb.rb +21 -0
- data/lib/gothonweb/version.rb +3 -0
- data/lib/views/hello_form.erb +10 -0
- data/lib/views/index.erb +5 -0
- data/lib/views/layout.erb +12 -0
- data/tests/gothonweb_tests.rb +1 -0
- data/tests/tools.rb +24 -0
- metadata +57 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/gothonweb.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gothonweb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gothonweb"
|
7
|
+
s.version = Gothonweb::VERSION
|
8
|
+
s.authors = ["pengquankun"]
|
9
|
+
s.email = ["283857115@qq.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{originates from "learn ruby the hard way"}
|
12
|
+
s.description = %q{originates from "learn ruby the hard way"}
|
13
|
+
|
14
|
+
s.rubyforge_project = "gothonweb"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
data/index.erb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
</html>
|
2
|
+
<head>
|
3
|
+
<title>Gothons Of Planet Percal #25</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
|
7
|
+
<% if greeting %>
|
8
|
+
<p>I just wanted to say <em style="color: green; font-size: 2em;"><%= greeting %></em>.
|
9
|
+
<% else %>
|
10
|
+
<em>Hello</em>, world!
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/lib/gothonweb.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "gothonweb/version"
|
2
|
+
require "sinatra"
|
3
|
+
require "erb"
|
4
|
+
|
5
|
+
module Gothonweb
|
6
|
+
|
7
|
+
get '/' do
|
8
|
+
greeting = "Hello, World!"
|
9
|
+
erb :index, :locals => {:greeting => greeting}
|
10
|
+
end
|
11
|
+
|
12
|
+
get '/hello' do
|
13
|
+
erb :hello_form
|
14
|
+
end
|
15
|
+
|
16
|
+
post '/hello' do
|
17
|
+
greeting = "#{params[:greet] || "Hello"}, #{params[:name] || "Nobody"}"
|
18
|
+
erb :index, :locals => {:greeting => greeting}
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/views/index.erb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../lib/gothonweb'
|
data/tests/tools.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
def assert_response(resp, contains=nil, matches=nil, headers=nil, status=200)
|
4
|
+
|
5
|
+
assert_equal(resp.status, status, "Expected response #{status} not in #{resp}")
|
6
|
+
|
7
|
+
if status == 200
|
8
|
+
assert(resp.body, "Response data is empty.")
|
9
|
+
end
|
10
|
+
|
11
|
+
if contains
|
12
|
+
assert((resp.body.include? contains), "Response does not contain #{contains}")
|
13
|
+
end
|
14
|
+
|
15
|
+
if matches
|
16
|
+
reg = Regexp.new(matches)
|
17
|
+
assert reg.match(contains), "Response does not match #{matches}"
|
18
|
+
end
|
19
|
+
|
20
|
+
if headers
|
21
|
+
assert_equal(resp.headers, headers)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gothonweb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- pengquankun
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: originates from "learn ruby the hard way"
|
15
|
+
email:
|
16
|
+
- 283857115@qq.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- Rakefile
|
24
|
+
- gothonweb.gemspec
|
25
|
+
- index.erb
|
26
|
+
- lib/gothonweb.rb
|
27
|
+
- lib/gothonweb/version.rb
|
28
|
+
- lib/views/hello_form.erb
|
29
|
+
- lib/views/index.erb
|
30
|
+
- lib/views/layout.erb
|
31
|
+
- tests/gothonweb_tests.rb
|
32
|
+
- tests/tools.rb
|
33
|
+
homepage: ''
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project: gothonweb
|
53
|
+
rubygems_version: 1.8.11
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: originates from "learn ruby the hard way"
|
57
|
+
test_files: []
|