docwatch-bin 1.1.4 → 1.1.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
  SHA256:
3
- metadata.gz: 428e9a8f772a5877ea24b8aa37f63f01f17a6889f0e0d0e72e8502abaf4a5d51
4
- data.tar.gz: 705d2828ede9e7ab93a91b0e0ce987cfb5b49212c9b7983e8309ce487498a1f6
3
+ metadata.gz: 365505a045416de99180ea9c1cf68a9471499ac2a6c26c251018a4816ae025c1
4
+ data.tar.gz: 989e62d45cdb2bfd45f6892683c70c5edf18f392d384da347fd346a1b443034a
5
5
  SHA512:
6
- metadata.gz: cbd08501ef11110b8d6cc5d5f6f5e6b0fe5cfb6567aab6655ac9436a33985d8ff29633f66ff53e4531181c7ebb31883ed6c272263d4e7359340deb9f6ad3713f
7
- data.tar.gz: 3943bd1279191233d3417e8b5e263a324b5645d776e8dd62774865ccc646661c023dcd469c16d71ca1ca5323e440be1ebedc4cc1ba7aed49f82b59004e45cfd4
6
+ metadata.gz: 4f066bf2f71eb36305e30f0542581a4df0cc8258bbf112fdfe1653aeeb8644033cc13d07b9be76f054d7fe5eabe134d41617b9978a961168881aef2c8cfe650e
7
+ data.tar.gz: d2899529b2d2120629bbf028f10a8754e8b09f18787bfcfb87aee1704e3d596f642d646d18f45bd18fd756f66898509801b5b73134015511fa7f83c5c84a2ee0
data/bin/docwatch CHANGED
@@ -15,16 +15,16 @@ class Main
15
15
  @params ||= OpenStruct.new({
16
16
  verbose: @opts['--verbose'],
17
17
  version: @opts['--version'],
18
- file_path: @opts['<file-path>']
18
+ file_path: @opts['<file-path>'],
19
19
  })
20
20
  end
21
21
 
22
22
  def port
23
- @port ||= if @opts['--port'] == 'random'
23
+ if @opts['--port'] == 'random'
24
24
  # TODO: check if this port is in use
25
- 10000 + Random.random_number(50000)
25
+ @port ||= 10_000 + Random.random_number(50_000)
26
26
  else
27
- @opts['--port']
27
+ @port ||= @opts['--port']
28
28
  end
29
29
  end
30
30
 
@@ -68,12 +68,12 @@ class Main
68
68
  watcher = Watcher.new(params.file_path)
69
69
 
70
70
  Thread.new do
71
- while socket = server.accept
71
+ while (socket = server.accept)
72
72
  Thread.new do
73
73
  Connection.handle(
74
74
  renderer,
75
75
  watcher,
76
- Session.new(socket, logger)
76
+ Session.new(socket, logger),
77
77
  )
78
78
  end
79
79
  end
@@ -83,10 +83,10 @@ class Main
83
83
  puts 'Press enter to open page in the default handler (xdg-open)'.green
84
84
 
85
85
  begin
86
- while STDIN.gets
86
+ while $stdin.gets
87
87
  system('xdg-open %s' % url)
88
88
  end
89
- rescue Interrupt => e
89
+ rescue Interrupt
90
90
  puts
91
91
  puts 'Bye'
92
92
  end
@@ -116,8 +116,8 @@ usage = <<~EOF
116
116
  EOF
117
117
 
118
118
  begin
119
- Main.run(Docopt::docopt(usage))
120
- rescue Docopt::Exit => e
119
+ Main.run(Docopt.docopt(usage))
120
+ rescue Docopt::Exit
121
121
  puts usage
122
122
  exit 2
123
123
  end
@@ -12,13 +12,13 @@ module Docwatch
12
12
 
13
13
  def handle
14
14
  case @session.path
15
- when '/'
16
- @session.respond_with_html @renderer.to_html
17
- when '/wait'
18
- @watcher.wait
19
- @session.respond_with_text 'OK'
20
- else
21
- @session.respond_with_404
15
+ when '/'
16
+ @session.respond_with_html(@renderer.to_html)
17
+ when '/wait'
18
+ @watcher.wait
19
+ @session.respond_with_text('OK')
20
+ else
21
+ @session.respond_with_404
22
22
  end
23
23
  end
24
24
  end
@@ -16,8 +16,8 @@ module Docwatch
16
16
  Redcarpet::Markdown.new(
17
17
  Redcarpet::Render::HTML,
18
18
  fenced_code_blocks: true,
19
- autolink: true,
20
- tables: true,
19
+ autolink: true,
20
+ tables: true,
21
21
  footnotes: true,
22
22
  ).render(contents)
23
23
  end
@@ -10,6 +10,7 @@ module Docwatch
10
10
  def self.by_filetype(file_path)
11
11
  extname = File.extname(file_path)[1..]
12
12
  return if extname.length == 0
13
+
13
14
  @@extensions[extname.to_sym].first.new(file_path)
14
15
  end
15
16
 
@@ -44,9 +45,7 @@ module Docwatch
44
45
 
45
46
  protected
46
47
 
47
- def file_path
48
- @file_path
49
- end
48
+ attr_reader :file_path
50
49
 
51
50
  def contents
52
51
  File.read(@file_path)
@@ -4,7 +4,7 @@ module Docwatch
4
4
  @socket = socket
5
5
  @logger = logger
6
6
 
7
- logger.log first_request_line
7
+ logger.log(first_request_line)
8
8
  end
9
9
 
10
10
  def close
@@ -16,7 +16,7 @@ module Docwatch
16
16
  return
17
17
  end
18
18
 
19
- first_request_line.split(' ')[1]
19
+ first_request_line.split[1]
20
20
  end
21
21
 
22
22
  def respond_with_text(str)
@@ -1,3 +1,3 @@
1
1
  module Docwatch
2
- VERSION = "1.1.4"
2
+ VERSION = '1.1.5'
3
3
  end
@@ -10,7 +10,7 @@ module Docwatch
10
10
 
11
11
  def wait
12
12
  now = mtime
13
- sleep 0.2 while mtime <= now
13
+ sleep(0.2) while mtime <= now
14
14
  end
15
15
  end
16
16
  end
data/lib/docwatch.rb CHANGED
@@ -9,7 +9,7 @@ require 'socket'
9
9
 
10
10
  module Docwatch
11
11
  def self.root_dir
12
- File.expand_path('../..', __FILE__)
12
+ File.expand_path('..', __dir__)
13
13
  end
14
14
  end
15
15
 
metadata CHANGED
@@ -1,99 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docwatch-bin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - crdx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: require_all
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: 0.8.1
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: '3.0'
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
- name: redcarpet
28
+ name: docopt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.5'
33
+ version: 0.6.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.5'
40
+ version: 0.6.1
41
41
  - !ruby/object:Gem::Dependency
42
- name: colorize
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.1
47
+ version: '1.10'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.1
54
+ version: '1.10'
55
55
  - !ruby/object:Gem::Dependency
56
- name: nokogiri
56
+ name: redcarpet
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.10'
61
+ version: '3.5'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.10'
68
+ version: '3.5'
69
69
  - !ruby/object:Gem::Dependency
70
- name: docopt
70
+ name: require_all
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.1
75
+ version: '3.0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.6.1
82
+ version: '3.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: simplecov
84
+ name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '13.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'
96
+ version: '13.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -109,19 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.8'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rake
112
+ name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '13.0'
117
+ version: '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: '13.0'
124
+ version: '0'
125
125
  description:
126
126
  email:
127
127
  executables:
@@ -153,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="
155
155
  - !ruby/object:Gem::Version
156
- version: '0'
156
+ version: '3.0'
157
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  requirements:
159
159
  - - ">="