acter 0.1.0 → 0.1.1
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 +4 -4
- data/exe/acter +3 -0
- data/lib/acter.rb +8 -16
- data/lib/acter/response.rb +1 -1
- data/lib/acter/result.rb +7 -4
- data/lib/acter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed02fc9ee223ff3ca43735e8cbe9a56dff404c72009f77648405d41e9a75d007
|
4
|
+
data.tar.gz: 25bedbde8256094d73bbb2ee9c47cbbcab027a3f77b5e1e9077293077ab2694a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2220c0d898887ea03f35c1df01c9c6de8acdadb77f5936db5d47e6e177bf3cb21d4e489132ab10ac5507011c6e2f04d1ff2391c1b447823017909afb2a4997cd
|
7
|
+
data.tar.gz: 653c12f092c4fa39d6db53448559d7959834e7207a90daec44b3a85bff8792610afe9ccb502d349a21a21afec151edcd679cc7cc931239bf1cb700d479497c16
|
data/exe/acter
CHANGED
@@ -15,6 +15,9 @@ opt_parser = OptionParser.new do |opts|
|
|
15
15
|
opts.on("-sPATH", "--schema=PATH", URI, "Path to JSON schema") do |v|
|
16
16
|
schema_path = v.scheme ? v : Pathname.new(v.to_s)
|
17
17
|
end
|
18
|
+
opts.on("-S", "--[no-]show-status", :OPTIONAL, TrueClass, "Output response status code (default: yes)") do |v|
|
19
|
+
render_options[:show_status] = v
|
20
|
+
end
|
18
21
|
opts.on("-H", "--[no-]show-headers", :OPTIONAL, TrueClass, "Output response headers (default: no)") do |v|
|
19
22
|
render_options[:show_headers] = v
|
20
23
|
end
|
data/lib/acter.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "acter/version"
|
2
1
|
require "json_schema-cromulent_links"
|
3
2
|
require "json_schema-example_parsing"
|
4
3
|
require "multi_json"
|
@@ -7,21 +6,6 @@ require "pathname"
|
|
7
6
|
require "yaml"
|
8
7
|
|
9
8
|
module Acter
|
10
|
-
autoload :Action, "acter/action"
|
11
|
-
autoload :Error, "acter/error"
|
12
|
-
autoload :Help, "acter/help"
|
13
|
-
autoload :Request, "acter/request"
|
14
|
-
autoload :Response, "acter/response"
|
15
|
-
autoload :Result, "acter/result"
|
16
|
-
|
17
|
-
autoload :NoSchema, "acter/error"
|
18
|
-
autoload :InvalidSchema, "acter/error"
|
19
|
-
autoload :InvalidCommand, "acter/error"
|
20
|
-
autoload :InvalidSubject, "acter/error"
|
21
|
-
autoload :InvalidAction, "acter/error"
|
22
|
-
autoload :MissingParameters, "acter/error"
|
23
|
-
autoload :HelpWanted, "acter/error"
|
24
|
-
|
25
9
|
class << self
|
26
10
|
def load_schema_data(path = nil)
|
27
11
|
path ||= Pathname.glob("schema.{json,yml}").first or raise NoSchema
|
@@ -75,3 +59,11 @@ module Acter
|
|
75
59
|
alias help_wanted? help_wanted
|
76
60
|
end
|
77
61
|
end
|
62
|
+
|
63
|
+
require_relative "acter/action"
|
64
|
+
require_relative "acter/error"
|
65
|
+
require_relative "acter/help"
|
66
|
+
require_relative "acter/request"
|
67
|
+
require_relative "acter/response"
|
68
|
+
require_relative "acter/result"
|
69
|
+
require_relative "acter/version"
|
data/lib/acter/response.rb
CHANGED
@@ -4,7 +4,7 @@ module Acter
|
|
4
4
|
class Response
|
5
5
|
def initialize(status, headers, body)
|
6
6
|
@status = status
|
7
|
-
@success = (200..299).include?(status[/\d+/])
|
7
|
+
@success = (200..299).include?(status[/\d+/].to_i)
|
8
8
|
@headers = headers.sort.map {|a| a.join(": ") }
|
9
9
|
@body = case body
|
10
10
|
when String
|
data/lib/acter/result.rb
CHANGED
@@ -10,6 +10,7 @@ module Acter
|
|
10
10
|
DEFAULT_RENDER_OPTIONS = {
|
11
11
|
show_body: true,
|
12
12
|
show_headers: false,
|
13
|
+
show_status: true,
|
13
14
|
color: :tty?,
|
14
15
|
theme: "monokai",
|
15
16
|
}
|
@@ -31,10 +32,12 @@ module Acter
|
|
31
32
|
colorize = options[:color] && (options[:color] != :tty? || $>.tty?)
|
32
33
|
|
33
34
|
StringIO.open do |s|
|
34
|
-
if
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
if options[:show_status]
|
36
|
+
if colorize
|
37
|
+
s.puts Term::ANSIColor.bold(response.status)
|
38
|
+
else
|
39
|
+
s.puts response.status
|
40
|
+
end
|
38
41
|
end
|
39
42
|
if options[:show_headers]
|
40
43
|
response.headers.each(&s.method(:puts))
|
data/lib/acter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Slusky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|