jobim 0.4.4 → 0.4.5

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: 7162c0bfec182bf62950c3534456b546c34684a4
4
- data.tar.gz: bff45345003a4279c2b285ae23cfeee76760f979
3
+ metadata.gz: 583fc59d720021c552913ef4bff99fced316b51c
4
+ data.tar.gz: c42dbaa32411b22f6a09534b0988f59aed73e4be
5
5
  SHA512:
6
- metadata.gz: 87416def141658f5627798cdfa1d9061b990e3488d86874e5b93bfc1a399eb8cc30e5750b2410f12a7f8cd409d2dac41c3b061055456367479c64d92b8330a60
7
- data.tar.gz: 3ca87964fca7859b13cf31b844e0d467c9d77fdf02387ac1024f1257d42d892a2668b5de6760a5139ee662adf7f60e7fa543a6fd9cc2072dc0e5e7523286b187
6
+ metadata.gz: 8b5681660771b22617e3965186893c62686004d1832e189579a00b3c74868096ad59356450f290d7c53a7a987336f2abf07c943dd6a3ba51254cc4e6db94047a
7
+ data.tar.gz: a01e3ece983d2757ec7ba58259a2f924e7656839b62901e8053f7b4e3716a4d465e202c93f4d0a0379a7083ff7f593b1f360489d6910dab14573fd64e1c2b733
data/README.md CHANGED
@@ -1,12 +1,15 @@
1
+
1
2
  # Jobim
2
3
 
3
- `jobim` is a small ruby utility to pop-up an HTTP server on top of any given
4
- directory. `jobim` leverages [Thin](//github.com/macournoyer/thin/) and offers a
5
- limited subset of the `thin` utilities for your convenience.
4
+ `jobim` is a light utility for generating a static HTTP server. This allows
5
+ for rapid website design and development without the hassle and security risk
6
+ of a full web-server installation. `jobim` leverages
7
+ [Thin](//github.com/macournoyer/thin/) and exposes a limited subset of the
8
+ `thin` executable command flags for your convenience.
6
9
 
7
10
  ## Installation
8
11
 
9
- `jobim` is registered on [rubygems](//rubygems.org/gems/jobim) and is therefore
12
+ `jobim` is registered on [rubygems](//rubygems.org/gems/jobim) and is
10
13
  available anywhere good gems are sold.
11
14
 
12
15
  ``` shell
@@ -15,12 +18,33 @@ gem install jobim
15
18
 
16
19
  ## Usage
17
20
 
18
- `jobim` is run like `thin` with no configure script.
21
+ ```
22
+ Usage: jobim [OPTION]... [DIRECTORY]
23
+
24
+ Specific options:
25
+ -a, --address HOST bind to HOST address (default: 0.0.0.0)
26
+ -d, --daemonize Run as a daemon process
27
+ -p, --port PORT use PORT (default: 5634)
28
+ -P, --prefix PATH Mount the app under PATH
29
+ -q, --quiet Silence all logging
30
+
31
+ General options:
32
+ -h, --help Display this help message.
33
+ --version Display the version number
34
+
35
+ Jobim home page: <https://github.com/zellio/jobim/>
36
+ Report bugs to: <https://github.com/zellio/jobim/issues>
37
+ ```
38
+
39
+ `jobim` is run like `thin` but does not require a configuration script. By
40
+ default `jobim` will bind to `0.0.0.0:5634` and serve the current working
41
+ directory.
19
42
 
20
43
  ``` shell
21
44
  jobim path/to/webroot
22
45
  ```
23
- The site can then be view at `http://localhost:5634`
46
+
47
+ The site can be viewed at `http://localhost:5634` via a normal web browser.
24
48
 
25
49
  ## Contributing
26
50
 
data/bin/jobim CHANGED
@@ -7,46 +7,4 @@ $:.unshift File.expand_path("../../lib", file)
7
7
 
8
8
  require 'jobim'
9
9
 
10
- opts = Jobim::CLI.run!(*ARGV)
11
-
12
- exit if opts.nil?
13
-
14
- require 'rack'
15
- require 'rack/rewrite'
16
-
17
- app = Rack::Builder.new do
18
- use Rack::Rewrite do
19
- rewrite %r{(.*)}, -> (match, env) do
20
- request_path = env["REQUEST_PATH"]
21
-
22
- return match[1] if opts[:Prefix].length > request_path.length
23
-
24
- local_path = File.join(opts[:Dir], request_path[opts[:Prefix].length..-1])
25
-
26
- if File.directory?(local_path) and
27
- File.exists?(File.join(local_path, "index.html"))
28
- File.join(request_path, "index.html")
29
- else
30
- match[1]
31
- end
32
- end
33
- end
34
-
35
- use Rack::CommonLogger, STDOUT
36
-
37
- map opts[:Prefix] do
38
- run Rack::Directory.new(opts[:Dir])
39
- end
40
- end
41
-
42
- puts ">>> Serving #{opts[:Dir]}"
43
-
44
- Rack::Handler::Thin.run(app, opts) do |server|
45
- if opts[:Daemonize]
46
- server.pid_file = 'jobim.pid'
47
- server.log_file = 'jobim.log'
48
- server.daemonize
49
- end
50
-
51
- Thin::Logging.silent = opts[:Quiet]
52
- end
10
+ Jobim::CLI.run!(*ARGV)
data/lib/jobim/cli.rb CHANGED
@@ -9,7 +9,9 @@ class Jobim::CLI
9
9
  cli = Jobim::CLI.new
10
10
  begin
11
11
  cli.parse(args)
12
- cli.options
12
+ options = cli.options
13
+ exit if options.nil?
14
+ Jobim::Server.start options
13
15
  rescue
14
16
  puts cli.help
15
17
  exit
@@ -0,0 +1,45 @@
1
+ require 'rack'
2
+ require 'rack/rewrite'
3
+
4
+ module Jobim::Server
5
+
6
+ def self.start(opts)
7
+ app = Rack::Builder.new do
8
+ use Rack::Rewrite do
9
+ rewrite %r{(.*)}, -> (match, env) do
10
+ request_path = env["REQUEST_PATH"]
11
+
12
+ return match[1] if opts[:Prefix].length > request_path.length
13
+
14
+ local_path = File.join(opts[:Dir], request_path[opts[:Prefix].length..-1])
15
+
16
+ if File.directory?(local_path) and
17
+ File.exists?(File.join(local_path, "index.html"))
18
+ File.join(request_path, "index.html")
19
+ else
20
+ match[1]
21
+ end
22
+ end
23
+ end
24
+
25
+ use Rack::CommonLogger, STDOUT
26
+
27
+ map opts[:Prefix] do
28
+ run Rack::Directory.new(opts[:Dir])
29
+ end
30
+ end
31
+
32
+ puts ">>> Serving #{opts[:Dir]}"
33
+
34
+ Rack::Handler::Thin.run(app, opts) do |server|
35
+ if opts[:Daemonize]
36
+ server.pid_file = 'jobim.pid'
37
+ server.log_file = 'jobim.log'
38
+ server.daemonize
39
+ end
40
+
41
+ Thin::Logging.silent = opts[:Quiet]
42
+ end
43
+ end
44
+
45
+ end
data/lib/jobim/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jobim
2
- VERSION = "0.4.4"
2
+ VERSION = "0.4.5"
3
3
  end
data/lib/jobim.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  module Jobim
3
3
 
4
4
  require "jobim/version"
5
+ require "jobim/server"
5
6
  require "jobim/cli"
6
7
 
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2013-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,6 +125,7 @@ files:
125
125
  - jobim.gemspec
126
126
  - lib/jobim.rb
127
127
  - lib/jobim/cli.rb
128
+ - lib/jobim/server.rb
128
129
  - lib/jobim/version.rb
129
130
  homepage: https://github.com/zellio/jobim
130
131
  licenses:
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  version: '0'
147
148
  requirements: []
148
149
  rubyforge_project:
149
- rubygems_version: 2.1.4
150
+ rubygems_version: 2.1.5
150
151
  signing_key:
151
152
  specification_version: 4
152
153
  summary: Popup HTTP Server