simp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +26 -0
- data/README.md +65 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/simp/version.rb +3 -0
- data/lib/simp.rb +28 -0
- data/simp.gemspec +38 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f0aff56c808d6ccf2134d43160ff2fe6f5abcdf6de5df3dc6e85a071ea71d669
|
4
|
+
data.tar.gz: 42f6affa8d992337cfef50cd92beb3326cbd223b1ec68b1a29b82e2004e2a4c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32c679ad07a09d9dbb3ad6a1253342ccbb5d63d12b4b6e3cb3f79590b4b3f6d0d62e990f8648e567a6cef5f503249bbf958a81eca85e6a22a34e4495842037dc
|
7
|
+
data.tar.gz: a926f3e6a08ab3580c5cd68b65fdde491d67474e697cc1ef17e82755c3635786206eba6b644d1ccf71651da98a03d8f9dc06778ed4533ed745a532588fe1df1a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simp (0.1.0)
|
5
|
+
erubi
|
6
|
+
rack
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
erubi (1.7.1)
|
12
|
+
minitest (5.11.3)
|
13
|
+
rack (2.0.4)
|
14
|
+
rake (10.5.0)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.16)
|
21
|
+
minitest (~> 5.0)
|
22
|
+
rake (~> 10.0)
|
23
|
+
simp!
|
24
|
+
|
25
|
+
BUNDLED WITH
|
26
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Simp
|
2
|
+
|
3
|
+
Simp is NOT A WEB FRAMEWORK.
|
4
|
+
|
5
|
+
Simp is something for really tiny app or beginer to learn web development.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'simp'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install simp
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
1. In your app directory, create a file named Gemfile for bundle
|
26
|
+
|
27
|
+
2. create 'config.ru' file and copy the following code:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'simp'
|
31
|
+
run Simp::Application.new
|
32
|
+
|
33
|
+
```
|
34
|
+
3. create your app files ending with 'html.erb'
|
35
|
+
|
36
|
+
```
|
37
|
+
$ touch index.html.erb
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
For example:
|
42
|
+
|
43
|
+
```erb
|
44
|
+
#index.html.erb
|
45
|
+
|
46
|
+
<%
|
47
|
+
@hello = "hello"
|
48
|
+
@world = "world"
|
49
|
+
%>
|
50
|
+
<html>
|
51
|
+
<head>
|
52
|
+
<title>Simp is not a web framework.</title>
|
53
|
+
<head>
|
54
|
+
<body>
|
55
|
+
<%= @hello + ", " + @world %>
|
56
|
+
</body>
|
57
|
+
</html>
|
58
|
+
```
|
59
|
+
4. `rackup`
|
60
|
+
|
61
|
+
5. Browser your web app in `http://localhost:9292`
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/simp.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "simp"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/simp/version.rb
ADDED
data/lib/simp.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "simp/version"
|
2
|
+
require "erubi"
|
3
|
+
|
4
|
+
module Simp
|
5
|
+
class Application
|
6
|
+
def call(env)
|
7
|
+
[200, {"Content-Type" => "html"},
|
8
|
+
[html(env["REQUEST_PATH"][1..0])]
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(file_name)
|
13
|
+
eval Erubi::Engine.new(File.read("#{file_name}.html.erb")).src
|
14
|
+
end
|
15
|
+
|
16
|
+
def render_400
|
17
|
+
"Oops, the page you visited is not exist."
|
18
|
+
end
|
19
|
+
|
20
|
+
def html(file_name)
|
21
|
+
if File.exists?(file_name)
|
22
|
+
render file_name
|
23
|
+
else
|
24
|
+
render_400
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/simp.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "simp/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "simp"
|
8
|
+
spec.version = Simp::VERSION
|
9
|
+
spec.authors = ["rocLv"]
|
10
|
+
spec.email = ["wangqsh999@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{simple web framework}
|
13
|
+
spec.description = %q{simple web framework, for very simple web app}
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
35
|
+
|
36
|
+
spec.add_runtime_dependency "rack"
|
37
|
+
spec.add_runtime_dependency "erubi"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rocLv
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: erubi
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: simple web framework, for very simple web app
|
84
|
+
email:
|
85
|
+
- wangqsh999@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- lib/simp.rb
|
99
|
+
- lib/simp/version.rb
|
100
|
+
- simp.gemspec
|
101
|
+
homepage:
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata:
|
105
|
+
allowed_push_host: https://rubygems.org
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.7.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: simple web framework
|
126
|
+
test_files: []
|