gryphon_nest 1.1.1 → 1.2.0

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: 773f8de17a88d769b28ca4a19a9f7f0f1a916b865d3363262515cee758be13d3
4
- data.tar.gz: e597a97c55f7f34ab8aa2498d608eb1b18e8363bb866549fa5cd514303f8ef1e
3
+ metadata.gz: c6d453e21e5e415707640be17773b49c68e9cc89051e7f4414b1339a6ffc8ced
4
+ data.tar.gz: 62c65f5a605cee0c62b1abba8f638afe6fa7cc8f7e3f118787d2f0dcb6aa379c
5
5
  SHA512:
6
- metadata.gz: 70b4641bc1e84078c37edf1ba0f1c06cda9ec0252133c7a05ac52264a76789c9c8cacfca2e930c631eaa938ce325c3f1a293815685ead2ee70265060e535928c
7
- data.tar.gz: 4989b444b40a22778a4b308637bca2b3630ded3ec4a87deb65ec4a231c0d3dead50f3fe5511a73d723a069907ebb85c221106b024f0b9592446003c7bddcd64a
6
+ metadata.gz: 56bf077e811a4ab6bf7a6836f42a929fea615a1e89078d1e6c3df63d753e08ff3e9f8d82d91b1588ac26648543702aa7543d95b212b0455f55cf78a44e95c4ec
7
+ data.tar.gz: 73ffb7df7f94d890f6c46e82687010722e7989e3cd5e0c8dad7c5c4a878bb288cfe0b03fd4e5d449a006cd32012153675ec665442fd37508dd25e8f681b7bf46
data/bin/nest CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'gryphon_nest'
5
5
  require 'optparse'
6
+ require 'sysexits'
6
7
 
7
8
  DEFAULT_PORT = 8000
8
9
 
@@ -10,6 +11,13 @@ options = {
10
11
  port: DEFAULT_PORT
11
12
  }
12
13
 
14
+ # @param msg [String]
15
+ # @param parser [OptionParser]
16
+ def usage_error(msg, parser)
17
+ warn(msg, parser)
18
+ Sysexits.exit(:usage)
19
+ end
20
+
13
21
  # @param options [Hash]
14
22
  # @return [Array]
15
23
  begin
@@ -33,19 +41,13 @@ begin
33
41
 
34
42
  command = ARGV.fetch(0, 'build')
35
43
 
36
- unless %w[build serve].include?(command)
37
- warn "Unknown command #{command}"
38
- warn parser
39
- exit(1)
40
- end
44
+ usage_error("Unknown command #{command}", parser) unless %w[build serve].include?(command)
41
45
 
42
46
  GryphonNest.build_website
43
47
  GryphonNest.serve_website(options[:port]) if command == 'serve'
44
48
  rescue OptionParser::ParseError => e
49
+ usage_error(e.message, parser)
50
+ rescue GryphonNest::NotFoundError => e
45
51
  warn e.message
46
- warn parser
47
- exit(1)
48
- rescue StandardError => e
49
- warn e.message
50
- exit(1)
52
+ Sysexits.exit(:input_missing)
51
53
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GryphonNest
4
+ class NotFoundError < StandardError; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GryphonNest
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/gryphon_nest.rb CHANGED
@@ -6,6 +6,7 @@ require 'webrick'
6
6
  require 'yaml'
7
7
 
8
8
  module GryphonNest
9
+ autoload :NotFoundError, 'gryphon_nest/not_found_error'
9
10
  autoload :Renderer, 'gryphon_nest/renderer'
10
11
  autoload :VERSION, 'gryphon_nest/version'
11
12
 
@@ -18,7 +19,7 @@ module GryphonNest
18
19
  TEMPLATE_EXT = '.mustache'
19
20
 
20
21
  def build_website
21
- raise "Content directory doesn't exist" unless Dir.exist?(CONTENT_DIR)
22
+ raise NotFoundError, "Content directory doesn't exist" unless Dir.exist?(CONTENT_DIR)
22
23
 
23
24
  existing_files = []
24
25
  if Dir.exist?(BUILD_DIR)
@@ -116,7 +117,7 @@ module GryphonNest
116
117
  layout = context['layout']
117
118
  path = path.join(layout)
118
119
 
119
- raise "#{name} requires layout file #{layout} but it doesn't exist or can't be read" unless File.exist?(path)
120
+ raise NotFoundError, "#{name} requires layout file #{layout} but it doesn't exist or can't be read" unless File.exist?(path)
120
121
 
121
122
  return path.to_s
122
123
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gryphon_nest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Birmingham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-22 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlbeautifier
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sysexits
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: webrick
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +106,7 @@ files:
92
106
  - LICENSE
93
107
  - bin/nest
94
108
  - lib/gryphon_nest.rb
109
+ - lib/gryphon_nest/not_found_error.rb
95
110
  - lib/gryphon_nest/renderer.rb
96
111
  - lib/gryphon_nest/version.rb
97
112
  homepage: https://github.com/chrisBirmingham/gryphon_nest