gfm-preview 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -13
- data/lib/gfm-preview/cli.rb +15 -6
- data/lib/gfm-preview/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -2,28 +2,21 @@
|
|
2
2
|
|
3
3
|
GFM (Github Flavored Markdown) preview server.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Installation
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
gem 'gfm-preview'
|
10
|
-
|
11
|
-
and then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
or install it yourself as:
|
7
|
+
Install it yourself as:
|
16
8
|
|
17
9
|
$ gem install gfm-preview
|
18
10
|
|
19
|
-
##
|
11
|
+
## Usage
|
20
12
|
|
21
|
-
|
13
|
+
Start preview server:
|
22
14
|
|
23
15
|
$ gfm-preview [options] [source_dir]
|
24
16
|
Options are:
|
25
17
|
-a, --address [address] Default: 127.0.0.1
|
26
18
|
-p, --port [port] Default: 10080
|
27
|
-
-
|
19
|
+
-n, --no-open Do not open browser
|
20
|
+
-h, --help Show this help message
|
28
21
|
|
29
22
|
```C-c``` to shutdown the preview server.
|
data/lib/gfm-preview/cli.rb
CHANGED
@@ -6,9 +6,10 @@ module GfmPreview
|
|
6
6
|
def self.execute(stdout, arguments=[])
|
7
7
|
|
8
8
|
options = {
|
9
|
-
:source_dir
|
10
|
-
:address
|
11
|
-
:port
|
9
|
+
:source_dir => '.',
|
10
|
+
:address => '127.0.0.1',
|
11
|
+
:port => '10080',
|
12
|
+
:open_browser => true
|
12
13
|
}
|
13
14
|
mandatory_options = %w( )
|
14
15
|
|
@@ -20,8 +21,9 @@ module GfmPreview
|
|
20
21
|
Options are:
|
21
22
|
BANNER
|
22
23
|
opts.on("-a [address]", "--address", "Default: 127.0.0.1") { |v| options[:address] = v }
|
23
|
-
opts.on("-p [port]",
|
24
|
-
opts.on("-
|
24
|
+
opts.on("-p [port]", "--port", "Default: 10080") { |v| options[:port] = v }
|
25
|
+
opts.on("-n", "--no-open", "Do not open browser") { |v| options[:open_browser] = false }
|
26
|
+
opts.on("-h", "--help", "Show this help message") { stdout.puts opts; exit }
|
25
27
|
opts.parse!(ARGV)
|
26
28
|
options[:source_dir] = ARGV[0] if ARGV[0]
|
27
29
|
|
@@ -30,8 +32,15 @@ module GfmPreview
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
|
35
|
+
if options[:open_browser] && system("which open")
|
36
|
+
pid = fork
|
37
|
+
if pid.nil?
|
38
|
+
exec("open http://localhost:#{options[:port]}/")
|
39
|
+
exit!(0)
|
40
|
+
end
|
41
|
+
end
|
34
42
|
|
43
|
+
server = Server.new
|
35
44
|
trap(:INT){server.shutdown}
|
36
45
|
server.start(options[:source_dir], options[:address], options[:port])
|
37
46
|
|
data/lib/gfm-preview/version.rb
CHANGED