nephos-server 0.1 → 0.1.1
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/README.md +10 -2
- data/bin/nephos-generator +42 -0
- data/lib/nephos-server/routing/execute.rb +1 -1
- data/version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40bd41f32d67b7ff17ee0a94d81962b409bc4a97
|
4
|
+
data.tar.gz: 0c33b56bfdf5b80654d10791197bdbbeb7d55d82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85ce2cfc5c350c0ccf8dea78b2d6a7f64581445bd02f602a3c005269e2049455f3103fceb32ea82875368ac6fa319152205ea8d7bd0d7857a95fd7f41f233dd3
|
7
|
+
data.tar.gz: ecfebc9b2e46f826646f94588525d390302540b53803444236d3e0dc20f635b6a1776aee29271b9a295b2bfc5f020967dc2c38b8f96884f6d41021f47a7537ae
|
data/README.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Nephos Ruby Server
|
2
2
|
|
3
|
+
[](http://badge.fury.io/gh/pouleta%2FNephosRubyServer)
|
4
|
+
|
5
|
+
[](http://badge.fury.io/rb/nephos-server)
|
6
|
+
|
7
|
+
[](https://codeclimate.com/github/pouleta/NephosRubyServer)
|
8
|
+
|
3
9
|
This is a simple web server, based on rack and puma, with a minimal help:
|
4
10
|
|
5
11
|
- Controllers
|
@@ -22,6 +28,8 @@ This is a simple web server, based on rack and puma, with a minimal help:
|
|
22
28
|
|
23
29
|
```sh
|
24
30
|
gem install nephos-server
|
31
|
+
nephos-generator application MyApp
|
32
|
+
cd MyApp
|
25
33
|
nephos-server -p 8080 # port is not required
|
26
34
|
```
|
27
35
|
|
@@ -30,8 +38,8 @@ nephos-server -p 8080 # port is not required
|
|
30
38
|
|
31
39
|
## Controller
|
32
40
|
|
33
|
-
To create a controller, simply add it to ``
|
34
|
-
The basic code of a controller can be generated via ``
|
41
|
+
To create a controller, simply add it to ``controllers/``.
|
42
|
+
The basic code of a controller can be generated via ``nephos-generator controller NAME``.
|
35
43
|
|
36
44
|
```ruby
|
37
45
|
class Example < Nephos::Controller
|
data/bin/nephos-generator
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
GEMFILE = <<EOF
|
4
|
+
source 'https://rubygems.org'
|
5
|
+
|
6
|
+
gem 'nephos-server'
|
7
|
+
EOF
|
8
|
+
|
9
|
+
ROUTE_RB = <<EOF
|
10
|
+
#get url: "/", controller: "MainController", method: "root"
|
11
|
+
#get url: "/add", controller: "MainController", method: "add_url"
|
12
|
+
#get url: "/rm", controller: "MainController", method: "rm_url"
|
13
|
+
EOF
|
14
|
+
|
3
15
|
def generate_controller(name, file)
|
16
|
+
if File.exists? file
|
17
|
+
print "The file #{file} already exists. Are you sure to erase it ? (y/N)"
|
18
|
+
r = STDIN.gets.to_s.chomp
|
19
|
+
raise "File #{file} already exists" unless r.match(/y(es)?/)
|
20
|
+
end
|
4
21
|
f = File.open(file, 'w')
|
5
22
|
f << <<EOF
|
6
23
|
class #{name} < Nephos::Controller
|
@@ -11,11 +28,36 @@ end
|
|
11
28
|
EOF
|
12
29
|
end
|
13
30
|
|
31
|
+
def create_application_dir dir
|
32
|
+
raise "Directory #{dir} already exists" if Dir.exists? dir
|
33
|
+
Dir.mkdir dir
|
34
|
+
end
|
35
|
+
|
36
|
+
def move_to_application_dir dir
|
37
|
+
Dir.chdir dir
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize_application
|
41
|
+
raise "Not an empty dir" unless Dir[File.expand_path "*"].empty?
|
42
|
+
File.write "routes.rb", ROUTE_RB
|
43
|
+
File.write "Gemfile", GEMFILE
|
44
|
+
Dir.mkdir "controllers"
|
45
|
+
exec("bundle install")
|
46
|
+
end
|
47
|
+
|
14
48
|
case ARGV[0]
|
15
49
|
when "c", "controller"
|
16
50
|
if not ARGV[1].to_s.empty?
|
17
51
|
generate_controller("#{ARGV[1]}Controller", "src/#{ARGV[1]}.rb")
|
18
52
|
end
|
53
|
+
when "a", "appli", "application"
|
54
|
+
if not ARGV[1].to_s.empty?
|
55
|
+
create_application_dir(ARGV[1])
|
56
|
+
puts "Application #{ARGV[1]} created"
|
57
|
+
move_to_application_dir(ARGV[1])
|
58
|
+
end
|
59
|
+
initialize_application
|
60
|
+
puts "Application initialized"
|
19
61
|
else
|
20
62
|
puts "help: generate c[ontroller] name"
|
21
63
|
end
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.1.1
|