nephos-server 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0839af6ab21e208af170dba120d5bac00a34d287
4
- data.tar.gz: 92b2d4b2760723ade7d820289c5c1c36c5a80c25
3
+ metadata.gz: 40bd41f32d67b7ff17ee0a94d81962b409bc4a97
4
+ data.tar.gz: 0c33b56bfdf5b80654d10791197bdbbeb7d55d82
5
5
  SHA512:
6
- metadata.gz: 753a000e9e45bab9c728cc3345b9d81a692b564b84cfaeff4c371d951f19010d4c872de4c21e9522119a2c7d8e3cd42f20371273c7551235e1b9b2dad7898f76
7
- data.tar.gz: b86e626ee836f1117c580ea4c26ec02ccbb1e5da83167212feed4dd99fb20e6aaa88c454072db1d5c171f63af29324377f3bc93650d2ee69b6cf9337deae9237
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
+ [![GitHub version](https://badge.fury.io/gh/pouleta%2FNephosRubyServer.svg)](http://badge.fury.io/gh/pouleta%2FNephosRubyServer)
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/nephos-server.svg)](http://badge.fury.io/rb/nephos-server)
6
+
7
+ [![Code Climate](https://codeclimate.com/github/pouleta/NephosRubyServer/badges/gpa.svg)](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 ``src/``.
34
- The basic code of a controller can be generated via ``bin/generate controller NAME``.
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
@@ -1,6 +1,6 @@
1
1
  require_relative 'controller'
2
2
 
3
- Dir[File.expand_path "src/*.rb"].each do |f|
3
+ Dir[File.expand_path "controllers/*.rb"].each do |f|
4
4
  load(f) and puts "#{f} loaded"
5
5
  end
6
6
  puts
data/version CHANGED
@@ -1 +1 @@
1
- 0.1
1
+ 0.1.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nephos-server
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - poulet_a