komicless 0.1.1 → 0.1.2

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: 11b132bd209123ae5d41bbff277316e691846d93
4
- data.tar.gz: 3ee7acd4cf82820225519c4cec32df29a210f9c0
3
+ metadata.gz: 8ac86593ab60fff6839423930dd834b70c81304c
4
+ data.tar.gz: a6db122a747f1a5dcd49e0b6bf5e1d66abb06b33
5
5
  SHA512:
6
- metadata.gz: 828a9d889b3d0e45eda0faa09bc9291b9b1787f98da6bdf1390741e2993a8635847d39df6ca631df6ebf6c0851311c529225dd23ce70580c2aa2d8c3525d778b
7
- data.tar.gz: 9c6eefbe0b17b469f955a909505ab77c7d070ae3df5604eb815c3a865b017afe64c07dd8393eb3e731c639a88ad5ba403aa7988178a28b47444186118388cf6f
6
+ metadata.gz: efcee235a45d9cb8bb6d227cc85b484dd9de00bcc8b86596d65cacfaff6066a6df633c50bda03c93708b529695fe7226d17f2aec961aef0115c3052b541f96a1
7
+ data.tar.gz: fd62b69957cec3f92d0b1ab0cc1ce37d294cabe3ebf3cb1f1996a69d6abcec363188a30b4470b371f9696504aa5f2bc24f81bbb2691528a9c09550ffc58c8263
data/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  Komicless is an (alternative) server for [ComicGlass](http://comicglass.net/).
4
4
  They already provides a Win server, a Mac server, and a PHP version.
5
5
 
6
- This work should work with recent Ruby, without requiring root privilege and PHP.
6
+ This work should work with recent Ruby, without requiring root privilege and a standalone web server.
7
7
 
8
8
  # Limitations
9
9
 
10
- - Unlike offical servers, Komicless only hosts one directory (not really a problem when we can symlink dirs).
10
+ - Unlike offical servers, Komicless only hosts one directory (not really a problem as it handles symlink of dirs).
11
11
  - uPnP is not supported yet.
12
12
 
13
13
  ## Installation
data/bin/komicless CHANGED
@@ -10,18 +10,24 @@ require 'rack'
10
10
  # --port (optional)
11
11
  # --extension ?
12
12
 
13
- handler_options = {}
14
- root = nil
13
+ handler_options = { :Port => 10080 }
14
+ app_options = { :root => "." }
15
+
15
16
  OptionParser.new do |parser|
16
17
  parser.on "-p", "--port PORT" do |port|
17
18
  handler_options[ :Port ] = port.to_i
18
19
  end
19
20
  parser.on "-r", "--root ROOT_DIR" do |root_dir|
20
- root = root_dir
21
+ app_options[ :root ] = root_dir
21
22
  end
22
23
  end.parse!
23
24
 
24
- app = Komicless::Server.new( root || "." )
25
- handler = Rack::Handler.pick %w/ thin webrick /
25
+ puts "Server port:\t#{handler_options[:Port]}"
26
+ Komicless.each_nic do |count,ipaddr|
27
+ puts "Server IP (#{count}):\t#{ipaddr}"
28
+ end
29
+ puts "Root directory:\t#{File.absolute_path app_options[:root] }"
26
30
 
27
- handler.run app,({ :Port => 10080, }.merge handler_options)
31
+ app = Komicless::Server.create app_options
32
+ handler = Rack::Handler.pick %w/ thin webrick /
33
+ handler.run app, handler_options
@@ -1,13 +1,27 @@
1
1
  require 'rack'
2
2
  require 'erb'
3
+ require 'socket'
3
4
 
4
5
  module Komicless
5
6
 
6
7
  INDEX_ERB = open( File.expand_path "index.html.erb", File.dirname(__FILE__) ).read.freeze
7
8
  INDEX = ::ERB.new INDEX_ERB
8
9
 
10
+ def self.each_nic
11
+ # enumerate IPaddr of NICs
12
+ count = 0
13
+ Socket::getaddrinfo(Socket.gethostname,"http", nil, :STREAM).each do |family, port, hostname, ip, *_|
14
+ count+=1
15
+ yield count, ip[/^[^%]*/]
16
+ end
17
+ end
18
+
9
19
  class Server < ::Rack::Directory
10
20
 
21
+ def self.create app_options
22
+ self.new( app_options[:root] )
23
+ end
24
+
11
25
  # remove first entry
12
26
  def list_directory
13
27
  ret = super
@@ -1,3 +1,3 @@
1
1
  module Komicless
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: komicless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wang Guan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-17 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler