serve_dir 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3facd4ccca23b4b266de702ea5e3d258d2aea33f
4
+ data.tar.gz: 7d9cbcdbcac118ced348da9717138077de33c1cc
5
+ SHA512:
6
+ metadata.gz: 91723fc191fe83c042ab295cf527890521c317706b639393cf7cd03cd284ab232d21f2bce28d15734284077ffba57b5778270fcb67211b65ce7d7a424a229d08
7
+ data.tar.gz: 2907cc0aec328744e208288284dc89621945b4696b8ddbc98b325441b0af3238977d26aba3ec599528704de1696974347d29076ce76db67b4ec4c1b2b0724998
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serve_dir (0.0.1)
5
- launchy (~> 2.1.0)
4
+ serve_dir (0.2.0)
5
+ launchy (~> 2.3.0)
6
6
  rack (~> 1.4.1)
7
7
  slop (~> 2)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- addressable (2.2.7)
13
- launchy (2.1.0)
14
- addressable (~> 2.2.6)
15
- rack (1.4.1)
12
+ addressable (2.3.5)
13
+ launchy (2.3.0)
14
+ addressable (~> 2.3)
15
+ rack (1.4.5)
16
16
  slop (2.4.4)
17
17
 
18
18
  PLATFORMS
data/README.mkd CHANGED
@@ -1,27 +1,14 @@
1
1
  serve_dir
2
2
  =========
3
3
 
4
- Suppose you are practicing JavaScript and Ajax.
4
+ Start local http server that serves contents of the given directory.
5
5
 
6
- * a.html
7
- * b.js
8
- * c.txt : loaded by b.js with Ajax
9
-
10
- First you open a.html and notice c.txt can't be loaded:
11
-
12
- XMLHttpRequest cannot load file:///somewhere/c.txt. Origin null is not allowed by Access-Control-Allow-Origin.
13
-
14
- Then you can type
15
-
16
- $ gem i serve_dir
17
- $ serve_dir .
18
-
19
- and open http://localhost:8181/a.html .
6
+ Useful for previewing static web sites with Ajax.
20
7
 
21
8
  Requirements
22
9
  ============
23
10
 
24
- Ruby 1.9 (Don't know if it works with 1.8)
11
+ Ruby 2.0 (may work with older ruby)
25
12
 
26
13
  Install
27
14
  =======
@@ -31,11 +18,12 @@ Install
31
18
  Usage
32
19
  =====
33
20
 
34
- serve_dir DIR [OPTIONS]
21
+ $ serve_dir DIR [options]
35
22
 
36
- OPTIONS:
23
+ Options:
37
24
 
38
25
  * -p, --port=PORT : http port (default: 8181)
26
+ * --path=PATH : http path to open with browser (default: '/')
39
27
  * -O, --no-open : don't open browser (default: open browser automatically)
40
28
  * -h, --help : show help
41
29
 
data/bin/serve_dir CHANGED
@@ -5,20 +5,18 @@ require 'slop'
5
5
  require 'launchy'
6
6
 
7
7
  opts = Slop.parse!(ARGV){
8
- banner "usage: serve_dir DIR [OPTIONS]"
9
- on "-p", "--port=", 'http port (default: 8181)', as: :int
8
+ banner "Usage: serve_dir [options] DIR"
9
+ on "-p", "--port=", 'http port (default: 8181)', as: :int, default: 8181
10
+ on "--path=", 'http path to open with browser (default: /)', default: '/'
10
11
  on "-O", "--no-open", "don't open browser"
11
- on "-h", "--help" do
12
- puts self.help
13
- exit
14
- end
12
+ on "-h", "--help"
15
13
  }
16
14
  if ARGV.size == 0
17
15
  puts opts.help
18
16
  exit
19
17
  end
18
+ dir = File.expand_path(ARGV[0])
20
19
 
21
- dir = File.expand_path(ARGV[0] || Dir.pwd)
22
20
  app = Rack::Builder.app{
23
21
  use Rack::CommonLogger
24
22
  use Rack::ShowExceptions
@@ -26,8 +24,10 @@ app = Rack::Builder.app{
26
24
  }
27
25
 
28
26
  port = opts[:port] || 8181
29
- url = "http://localhost:#{port}/"
30
- puts "Open #{url}"
27
+ path = opts[:path]
28
+ path = "/" + path unless path.start_with?("/")
29
+ url = "http://localhost:#{port}#{path}"
30
+ puts url
31
31
  Launchy.open(url) unless opts["no-open"]
32
32
 
33
33
  Rack::Server.start(:app => app, :Port => port)
@@ -1,3 +1,3 @@
1
1
  module ServeDir
2
- VERSION = "0.0.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/serve_dir.gemspec CHANGED
@@ -3,8 +3,8 @@ require File.expand_path('../lib/serve_dir/version', __FILE__)
3
3
  Gem::Specification.new do |gem|
4
4
  gem.authors = ["Yutaka HARA"]
5
5
  gem.email = ["yutaka.hara.gmail.com"]
6
- gem.description = %q{myrurema provides a command 'rurema', which helps searching/browsing/writing the Japanese Ruby documents (a.k.a Rurema http://bugs.ruby-lang.org/projects/rurema/wiki .)}
7
- gem.summary = %q{Serves current directory at http://localhost:8181/}
6
+ gem.summary = %q{Start local webserver on a directory}
7
+ gem.description = %q{Start local webserver on a directory (Useful for previewing static web pages)}
8
8
  gem.homepage = 'http://github.com/yhara/serve_dir'
9
9
 
10
10
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -16,5 +16,5 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.add_dependency("slop", "~> 2")
18
18
  gem.add_dependency("rack", "~> 1.4.1")
19
- gem.add_dependency("launchy", "~> 2.1.0")
19
+ gem.add_dependency("launchy", "~> 2.3.0")
20
20
  end
metadata CHANGED
@@ -1,52 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serve_dir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Yutaka HARA
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-09 00:00:00.000000000 Z
11
+ date: 2013-11-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: slop
16
- requirement: &2152937080 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: '2'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2152937080
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: rack
27
- requirement: &2152936580 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 1.4.1
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *2152936580
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.4.1
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: launchy
38
- requirement: &2152936100 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
- version: 2.1.0
47
+ version: 2.3.0
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *2152936100
47
- description: myrurema provides a command 'rurema', which helps searching/browsing/writing
48
- the Japanese Ruby documents (a.k.a Rurema http://bugs.ruby-lang.org/projects/rurema/wiki
49
- .)
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.0
55
+ description: Start local webserver on a directory (Useful for previewing static web
56
+ pages)
50
57
  email:
51
58
  - yutaka.hara.gmail.com
52
59
  executables:
@@ -64,26 +71,25 @@ files:
64
71
  - serve_dir.gemspec
65
72
  homepage: http://github.com/yhara/serve_dir
66
73
  licenses: []
74
+ metadata: {}
67
75
  post_install_message:
68
76
  rdoc_options: []
69
77
  require_paths:
70
78
  - lib
71
79
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
80
  requirements:
74
- - - ! '>='
81
+ - - '>='
75
82
  - !ruby/object:Gem::Version
76
83
  version: '0'
77
84
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
85
  requirements:
80
- - - ! '>='
86
+ - - '>='
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0'
83
89
  requirements: []
84
90
  rubyforge_project:
85
- rubygems_version: 1.8.11
91
+ rubygems_version: 2.0.3
86
92
  signing_key:
87
- specification_version: 3
88
- summary: Serves current directory at http://localhost:8181/
93
+ specification_version: 4
94
+ summary: Start local webserver on a directory
89
95
  test_files: []