riddl 0.99.196 → 0.99.197

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: 71e91dab768e617feaeefd4578f8f6ed7a5b0794
4
- data.tar.gz: 22ea00a94c657f994e37c5450f3dcf6466c2079c
3
+ metadata.gz: f63ab5e073d3f4ad52ca2a8da2610744e41c5bd3
4
+ data.tar.gz: 6d2230ea52f58d53079cea749da984748705edbe
5
5
  SHA512:
6
- metadata.gz: 41c7e768e4b3fb83274672d08e15cc832822d488904e943d700e316b1e11dc6879231a675e9347a9688f17efb7cd98ed1292204df7ecc1a33a04c37afca894f7
7
- data.tar.gz: 62fd64e0c2d91059bce0b209572c95f34aa54a7178897ec2600e084464bcc3e0553398c20206a08e1f9b6419e4e7ca7e96576faa9a72c2ae05bcd6372ea2f547
6
+ metadata.gz: d81f4ada7e6f5439766326bea935a36d4e111b58fe32a069b9f5710c9963f4de8e29bdeb4492b1cf58b3912174d8e88af0af3e9efead16e0d22939c7064b3103
7
+ data.tar.gz: c76110264a2abffa77c0e6136eda9f4a571b08d3b7c056604157da273582b5c86566e38faeda7be72c564b07ade64a97976a221a051c2ab75d8e85d32e9ef488
@@ -43,13 +43,14 @@ module Riddl
43
43
  end #}}}
44
44
 
45
45
  OPTS = {
46
- :host => 'localhost',
47
- :port => 9292,
48
- :secure => false,
49
- :mode => :debug,
50
- :basepath => File.expand_path(File.dirname($0)),
51
- :pidfile => File.basename($0,'.rb') + '.pid',
52
- :conffile => File.basename($0,'.rb') + '.conf'
46
+ :host => 'localhost',
47
+ :port => 9292,
48
+ :secure => false,
49
+ :mode => :debug,
50
+ :basepath => File.expand_path(File.dirname($0)),
51
+ :pidfile => File.basename($0,'.rb') + '.pid',
52
+ :conffile => File.basename($0,'.rb') + '.conf',
53
+ :runtime_options => []
53
54
  }
54
55
 
55
56
  def loop! #{{{
@@ -61,16 +62,18 @@ module Riddl
61
62
  operation = "start"
62
63
  ARGV.options { |opt|
63
64
  opt.summary_indent = ' ' * 4
64
- opt.banner = "Usage:\n#{opt.summary_indent}ruby server.rb [options] start|startclean|stop|restart|info\n"
65
+ opt.banner = "Usage:\n#{opt.summary_indent}ruby server.rb [options] start|stop|restart|info|...\n"
65
66
  opt.on("Options:")
66
67
  opt.on("--http-only", "-s", "Only http, no other protocols.") { http_only = true }
67
68
  opt.on("--verbose", "-v", "Do not daemonize. Write ouput to console.") { verbose = true }
68
69
  opt.on("--help", "-h", "This text.") { puts opt; exit }
69
70
  opt.separator(opt.summary_indent + "start|stop|restart|info".ljust(opt.summary_width+1) + "Do operation start, stop, restart or get information.")
70
- opt.separator(opt.summary_indent + "startclean".ljust(opt.summary_width+1) + "Delete all instances before starting.")
71
+ @riddl_opts[:runtime_options].each do |ro|
72
+ opt.separator(opt.summary_indent + ro[0].ljust(opt.summary_width+1) + ro[1])
73
+ end
71
74
  opt.parse!
72
75
  }
73
- unless %w{start startclean stop restart info}.include?(ARGV[0])
76
+ unless (%w{start stop restart info} + @riddl_opts[:runtime_options].map{|ro| ro[0] }).include?(ARGV[0])
74
77
  puts ARGV.options
75
78
  exit
76
79
  end
@@ -104,10 +107,12 @@ module Riddl
104
107
  end
105
108
  exit
106
109
  end
107
- if %w{start startclean}.include?(operation) && status.call == true
110
+ if %w{start}.include?(operation) && status.call == true
108
111
  puts "Server (#{@riddl_opts[:url]}) already started"
109
112
  exit
110
113
  end
114
+
115
+
111
116
 
112
117
  ########################################################################################################################
113
118
  # stop/restart server
@@ -127,12 +132,10 @@ module Riddl
127
132
  end
128
133
 
129
134
  ########################################################################################################################
130
- # start server
135
+ # go through user defined startup thingis
131
136
  ########################################################################################################################
132
- if operation == 'startclean'
133
- Dir.glob(File.expand_path(@riddl_opts[:basepath] + '/instances/*')).each do |d|
134
- FileUtils.rm_r(d) if File.basename(d) =~ /^\d+$/
135
- end
137
+ @riddl_opts[:runtime_options].each do |ro|
138
+ ro[2].call(status.call) if operation == ro[0]
136
139
  end
137
140
 
138
141
  app = Rack::Builder.new self
@@ -21,18 +21,25 @@ module Riddl
21
21
  @headers << Riddl::Header.new("Connection","close")
22
22
  @status = 304 # Not modified
23
23
  return []
24
- else
25
- mt = MIME::Types.type_for(path).first
26
- apx = ''
27
- if mt.ascii?
28
- tstr = File.read(path,CharlockHolmes::EncodingDetector::DEFAULT_BINARY_SCAN_LEN)
29
- apx = ';charset=' + CharlockHolmes::EncodingDetector.detect(tstr)[:encoding]
24
+ else
25
+ fmt = @a[1] || begin
26
+ mt = MIME::Types.type_for(path).first
27
+ if mt.nil?
28
+ 'text/plain;charset=utf-8'
29
+ else
30
+ apx = ''
31
+ if mt.ascii?
32
+ tstr = File.read(path,CharlockHolmes::EncodingDetector::DEFAULT_BINARY_SCAN_LEN)
33
+ apx = ';charset=' + CharlockHolmes::EncodingDetector.detect(tstr)[:encoding]
34
+ end
35
+ mt.to_s + apx
36
+ end
30
37
  end
31
- return Riddl::Parameter::Complex.new('file',mt.to_s + apx,File.open(path,'r'))
32
- end
38
+ return Riddl::Parameter::Complex.new('file',fmt,File.open(path,'r'))
39
+ end
33
40
  end
34
41
  @status = 404
35
- end
42
+ end
36
43
  end
37
- end
38
- end
44
+ end
45
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.196"
3
+ s.version = "0.99.197"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.196
4
+ version: 0.99.197
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  autorequire:
9
9
  bindir: tools
10
10
  cert_chain: []
11
- date: 2015-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-smart