nephos-server 0.3.2 → 0.4.0

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: 9c11b4d5d944f6cce30fbcda25510e5f6aba72c0
4
- data.tar.gz: c12a3b132cfdea4075469c53d14e79b851058c78
3
+ metadata.gz: 597ef096f14958c9c1139eb49d340783a4903bba
4
+ data.tar.gz: 91f587c2e6a54091835bfa374f031a4f19a3baef
5
5
  SHA512:
6
- metadata.gz: 2f51af907c046e17a3f1845a95af7eba1c593225dcfe8061f57aa2c9c5a029850642845ebd179c09caf15ed3d0a3ec77a4f7c037aa06cae900c0439569e15e37
7
- data.tar.gz: 3fd178f54482d3ead7a413302e1677a3095fa35f426001e2cc83d766ed7864f48603609235a48dd4ffb2043285b9b63eaa3fa21918198531ac99c5a36973470a
6
+ metadata.gz: 4e0e0860affde008dfdd112563fb7d5eb0e8eb2420c92f891503e3d64345d3d3cffaf96e4065b1e8a742fdea7057b07d57e5d88e4b2c6e3351eca897552bbf0c
7
+ data.tar.gz: 05396e4d53d8c8d0ce6c17c939246db518162344641af4a60da66755317b322be243fa7f7e9606e727486e01b95834ae9eeed472635a38233530b31b41380da9
data/bin/nephos-generator CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'optparse'
4
+ require 'nephos-server/bin-helpers'
5
+
3
6
  GEMFILE = <<EOF
4
7
  source 'https://rubygems.org'
5
8
 
@@ -12,7 +15,22 @@ ROUTE_RB = <<EOF
12
15
  #get url: "/rm", controller: "MainController", method: "rm_url"
13
16
  EOF
14
17
 
18
+ def generate_route(verb, url, dest_c, dest_m=nil)
19
+ raise "You are not in a valid application directory" if not Nephos::Bin.is_a_valid_application?
20
+ raise InvalidVerb, "\"#{verb}\" doesn't match with /\w+/" if not verb.to_s.match(/^\w+$/)
21
+ raise InvalidUrl if not url.match(/^\/?(:?\w+)(\/:?\w+)*\/?$/)
22
+ raise "Option dest_m is not avaiable for now" if not dest_m.nil?
23
+ raise "Option dest_c must match with \"controller#method\"" if not dest_c.match(/^\w+\#\w+$/)
24
+ controller = dest_c.split("#")[0]
25
+ method = dest_c.split("#")[1]
26
+ line = "add_route \"#{verb}\", url: \"#{url}\", controller: \"#{controller}\", method: \"#{method}\""
27
+ File.open("routes.rb", "a") do |f|
28
+ f.puts line
29
+ end
30
+ end
31
+
15
32
  def generate_controller(name, file)
33
+ raise "You are not in a valid application directory" if not Nephos::Bin.is_a_valid_application?
16
34
  if File.exists? file
17
35
  print "The file #{file} already exists. Are you sure to erase it ? (y/N)"
18
36
  r = STDIN.gets.to_s.chomp
@@ -54,8 +72,6 @@ def initialize_application
54
72
  exec("bundle install")
55
73
  end
56
74
 
57
- require 'optparse'
58
-
59
75
  begin
60
76
  OptionParser.new do |opts|
61
77
  opts.banner = "Usage: nephos-generator [controller name] [appli [name]]"
@@ -63,7 +79,7 @@ begin
63
79
 
64
80
  case ARGV[0]
65
81
  when "c", "controller"
66
- if ARGV[1].to_s.match(/[\w_\-\.]+/)
82
+ if ARGV[1].to_s.match(/[\w\-\.]+/)
67
83
  generate_controller("#{ARGV[1].capitalize}Controller", "app/#{ARGV[1].downcase}.rb")
68
84
  else
69
85
  puts "error"
@@ -76,6 +92,8 @@ begin
76
92
  end
77
93
  initialize_application
78
94
  puts "Application initialized"
95
+ when "r", "route"
96
+ generate_route(*(ARGV[1..4]))
79
97
  else
80
98
  puts "\"#{ARGV[0]}\" not recognized has a command"
81
99
  end
data/bin/nephos-status ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'nephos-server/bin-helpers'
5
+
6
+ OptionParser.new do |opts|
7
+ opts.banner = "Usage: nephos-status [appli directory]"
8
+ end.parse!
9
+
10
+ $dir = ARGV[0] || "."
11
+
12
+ begin
13
+ if Dir.exists? $dir
14
+ $gfl = File.expand_path "Gemfile.lock", $dir
15
+ if not File.exists? $gfl or
16
+ not File.read($gfl).split.index("nephos-server")
17
+ raise "\"#{$dir}\" is not a valid nephos-server application"
18
+ else
19
+ i = File.read($gfl).split.index("nephos-server") + 1
20
+ version = File.read($gfl).split[i]
21
+ path = $gfl.gsub(/Gemfile\.lock$/, "")
22
+ puts "Full path: #{path}"
23
+ puts "Installed nephos-version: #{version}"
24
+ end
25
+ else
26
+ raise "\"#{$dir}\" is not a valid directory"
27
+ end
28
+
29
+ rescue => err
30
+ puts err.message
31
+ end
@@ -0,0 +1,13 @@
1
+ module Nephos
2
+ module Bin
3
+
4
+ def self.is_a_valid_application? dir="."
5
+ return false if not Dir.exists? dir
6
+ gfl = File.expand_path "Gemfile.lock", dir
7
+ return false if not File.exists? gfl
8
+ return false if not File.read(gfl).split.index("nephos-server")
9
+ return true
10
+ end
11
+
12
+ end
13
+ end
@@ -13,6 +13,7 @@ lib/nephos-server.rb
13
13
  lib/nephos-server/basic_errors.rb
14
14
  lib/nephos-server/params.rb
15
15
  lib/nephos-server/controller.rb
16
+ lib/nephos-server/bin-helpers.rb
16
17
  lib/nephos-server/server/main.rb
17
18
  lib/nephos-server/server/responder.rb
18
19
  lib/nephos-server/router/main.rb
@@ -36,14 +37,19 @@ app/image.jpg
36
37
  app/main.rb
37
38
  bin/nephos-server
38
39
  bin/nephos-generator
40
+ bin/nephos-status
41
+ )
42
+ s.executables = %w(
43
+ nephos-server
44
+ nephos-generator
45
+ nephos-status
39
46
  )
40
- s.executables = ['nephos-server', 'nephos-generator']
41
47
  s.homepage = 'https://github.com/pouleta/NephosRubyServer'
42
48
  s.license = 'GNU/GPLv3'
43
49
  #s.cert_chain = ['certs/poulet_a.pem']
44
50
  #s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/
45
51
 
46
- s.add_dependency 'nomorebeer', '~> 1.0'
52
+ s.add_dependency 'nomorebeer', '~> 1.1'
47
53
  s.add_dependency 'rack', '~> 1.6'
48
54
  s.add_dependency 'colorize', '~> 0.7'
49
55
 
data/version CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nephos-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - poulet_a
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-30 00:00:00.000000000 Z
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nomorebeer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +60,7 @@ email:
60
60
  - lib/nephos-server/basic_errors.rb
61
61
  - lib/nephos-server/params.rb
62
62
  - lib/nephos-server/controller.rb
63
+ - lib/nephos-server/bin-helpers.rb
63
64
  - lib/nephos-server/server/main.rb
64
65
  - lib/nephos-server/server/responder.rb
65
66
  - lib/nephos-server/router/main.rb
@@ -83,9 +84,11 @@ email:
83
84
  - app/main.rb
84
85
  - bin/nephos-server
85
86
  - bin/nephos-generator
87
+ - bin/nephos-status
86
88
  executables:
87
89
  - nephos-server
88
90
  - nephos-generator
91
+ - nephos-status
89
92
  extensions: []
90
93
  extra_rdoc_files: []
91
94
  files:
@@ -99,8 +102,10 @@ files:
99
102
  - app/main.rb
100
103
  - bin/nephos-generator
101
104
  - bin/nephos-server
105
+ - bin/nephos-status
102
106
  - lib/nephos-server.rb
103
107
  - lib/nephos-server/basic_errors.rb
108
+ - lib/nephos-server/bin-helpers.rb
104
109
  - lib/nephos-server/controller.rb
105
110
  - lib/nephos-server/params.rb
106
111
  - lib/nephos-server/router/helpers.rb