docwatch-bin 1.1.0 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 203f494fbe91f8a8119b44bf85810e3ceb97f0bf45af3004b0816001f419cf32
4
- data.tar.gz: b753786ed78ec246c192b8de63a2605db13f1e09fc9070eab75d4634a58ad6e1
3
+ metadata.gz: 428e9a8f772a5877ea24b8aa37f63f01f17a6889f0e0d0e72e8502abaf4a5d51
4
+ data.tar.gz: 705d2828ede9e7ab93a91b0e0ce987cfb5b49212c9b7983e8309ce487498a1f6
5
5
  SHA512:
6
- metadata.gz: d3cd164f0062369d5e85f3d10a897f57388656d40d46be34b6a5219cd6f80763536bbc39bb0d741806c4a8a06dfed45246a5a9ff224d4933fbc9c87269e59437
7
- data.tar.gz: 602980ddaf70e96c66bff7e5c39f354ae02e96ab91f14edb9f62902bb436c129e4fb856452c4c4ef975049c9a7b8e5043dfeb69305ece9ae7fdebd0be3350237
6
+ metadata.gz: cbd08501ef11110b8d6cc5d5f6f5e6b0fe5cfb6567aab6655ac9436a33985d8ff29633f66ff53e4531181c7ebb31883ed6c272263d4e7359340deb9f6ad3713f
7
+ data.tar.gz: 3943bd1279191233d3417e8b5e263a324b5645d776e8dd62774865ccc646661c023dcd469c16d71ca1ca5323e440be1ebedc4cc1ba7aed49f82b59004e45cfd4
data/bin/docwatch CHANGED
@@ -15,7 +15,6 @@ class Main
15
15
  @params ||= OpenStruct.new({
16
16
  verbose: @opts['--verbose'],
17
17
  version: @opts['--version'],
18
- help: @opts['--help'],
19
18
  file_path: @opts['<file-path>']
20
19
  })
21
20
  end
@@ -37,11 +36,6 @@ class Main
37
36
  true
38
37
  end
39
38
 
40
- def exit_usage
41
- puts DOCS
42
- exit 0
43
- end
44
-
45
39
  def exit_version
46
40
  puts Docwatch::VERSION
47
41
  exit 0
@@ -63,7 +57,6 @@ class Main
63
57
 
64
58
  def run
65
59
  exit_version if params.version
66
- exit_usage if params.help
67
60
  exit_invalid_file unless File.exist?(params.file_path)
68
61
  exit_invalid_port unless port_valid
69
62
 
@@ -100,30 +93,31 @@ class Main
100
93
  end
101
94
  end
102
95
 
103
- docs = <<~EOF
104
- #{'Usage:'.bold}
96
+ usage = <<~EOF
97
+ Usage:
105
98
  #{File.basename($0)} [options] <file-path>
99
+ #{File.basename($0)} ( --version | --help )
106
100
 
107
- #{'Options:'.bold}
101
+ Options:
108
102
  -p, --port=VALUE Listen port [default: 8888]
109
- -v, --verbose Be verbose
110
- -V, --version Show version
103
+ --verbose Be verbose
104
+ -v, --version Show version
111
105
  -h, --help Show this help
112
106
 
113
- #{'Renderers:'.bold}
114
- markdown (.md)
115
- html (.html)
107
+ Renderers:
108
+ markdown (.md)
109
+ html (.html)
116
110
 
117
- If #{'--port'.bold} is #{'random'.bold} a random port will be chosen, otherwise
118
- the specified one will be used. The default is 8888.
111
+ If #{'--port'.bold} is #{'random'.bold} a random port will be chosen, otherwise the specified
112
+ one will be used. The default is 8888.
119
113
 
120
- In #{'--verbose'.bold} mode, incoming HTTP requests and file change event
121
- notifications will be printed to standard output.
114
+ In #{'--verbose'.bold} mode, incoming HTTP requests and file change event notifications will be
115
+ printed to standard output.
122
116
  EOF
123
117
 
124
118
  begin
125
- Main.run(Docopt::docopt(docs, version: VERSION))
119
+ Main.run(Docopt::docopt(usage))
126
120
  rescue Docopt::Exit => e
127
- puts e.message
128
- exit 1
121
+ puts usage
122
+ exit 2
129
123
  end
@@ -17,6 +17,8 @@ module Docwatch
17
17
  when '/wait'
18
18
  @watcher.wait
19
19
  @session.respond_with_text 'OK'
20
+ else
21
+ @session.respond_with_404
20
22
  end
21
23
  end
22
24
  end
@@ -12,22 +12,28 @@ module Docwatch
12
12
  end
13
13
 
14
14
  def path
15
- return if first_request_line.length == 0
15
+ if first_request_line.nil? || first_request_line.length == 0
16
+ return
17
+ end
18
+
16
19
  first_request_line.split(' ')[1]
17
20
  end
18
21
 
19
22
  def respond_with_text(str)
20
- respond_with(str, 'text/plain')
23
+ respond_with(200, str, 'text/plain')
21
24
  end
22
25
 
23
26
  def respond_with_html(str)
24
- respond_with(str, 'text/html')
27
+ respond_with(200, str, 'text/html')
28
+ end
29
+
30
+ def respond_with_404
31
+ respond_with(404, 'Not Found', 'text/html')
25
32
  end
26
33
 
27
- def respond_with(str, content_type)
28
- println 'HTTP/1.1 200'
34
+ def respond_with(code, str, content_type)
35
+ println 'HTTP/1.1 %d' % code
29
36
  println 'Content-Type: %s; charset=utf8' % content_type
30
- # println 'Connection: close'
31
37
  println
32
38
  println str
33
39
 
@@ -37,7 +43,9 @@ module Docwatch
37
43
  private
38
44
 
39
45
  def input_lines
40
- @input_lines ||= @socket.recvmsg[0].lines rescue []
46
+ @input_lines ||= @socket.recvmsg[0].lines
47
+ rescue
48
+ []
41
49
  end
42
50
 
43
51
  def first_request_line
@@ -1,3 +1,3 @@
1
1
  module Docwatch
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docwatch-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-30 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: redcarpet
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.17.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.17.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,16 +114,16 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '12.3'
117
+ version: '13.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '12.3'
125
- description:
126
- email:
124
+ version: '13.0'
125
+ description:
126
+ email:
127
127
  executables:
128
128
  - docwatch
129
129
  extensions: []
@@ -145,7 +145,7 @@ homepage: https://github.com/crdx/docwatch
145
145
  licenses:
146
146
  - MIT
147
147
  metadata: {}
148
- post_install_message:
148
+ post_install_message:
149
149
  rdoc_options: []
150
150
  require_paths:
151
151
  - lib
@@ -160,8 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  - !ruby/object:Gem::Version
161
161
  version: '0'
162
162
  requirements: []
163
- rubygems_version: 3.0.6
164
- signing_key:
163
+ rubygems_version: 3.2.21
164
+ signing_key:
165
165
  specification_version: 4
166
166
  summary: Preview markdown documents in the browser with reload on change
167
167
  test_files: []