fluid_cli 0.1.8 → 0.2.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/README.md +200 -1
- data/exe/fluid +12 -17
- data/lib/fluid_cli/version.rb +1 -1
- data/lib/fluid_cli.rb +4 -57
- metadata +14 -274
- data/Rakefile +0 -26
- data/dev.yml +0 -5
- data/lib/fluid_cli/api.rb +0 -141
- data/lib/fluid_cli/assets/post_auth_page/index.html.erb +0 -34
- data/lib/fluid_cli/assets/post_auth_page/style.css +0 -58
- data/lib/fluid_cli/command.rb +0 -55
- data/lib/fluid_cli/commands/help.rb +0 -21
- data/lib/fluid_cli/commands/login.rb +0 -30
- data/lib/fluid_cli/commands/logout.rb +0 -38
- data/lib/fluid_cli/commands/switch.rb +0 -23
- data/lib/fluid_cli/commands/theme/common/company_helper.rb +0 -15
- data/lib/fluid_cli/commands/theme/common/root_helper.rb +0 -95
- data/lib/fluid_cli/commands/theme/dev.rb +0 -61
- data/lib/fluid_cli/commands/theme/help.rb +0 -21
- data/lib/fluid_cli/commands/theme/init.rb +0 -46
- data/lib/fluid_cli/commands/theme/pull.rb +0 -68
- data/lib/fluid_cli/commands/theme/push.rb +0 -132
- data/lib/fluid_cli/commands/theme.rb +0 -23
- data/lib/fluid_cli/commands/whoami.rb +0 -23
- data/lib/fluid_cli/commands.rb +0 -19
- data/lib/fluid_cli/company_switcher.rb +0 -69
- data/lib/fluid_cli/context.rb +0 -691
- data/lib/fluid_cli/db.rb +0 -114
- data/lib/fluid_cli/entry_point.rb +0 -10
- data/lib/fluid_cli/environment.rb +0 -32
- data/lib/fluid_cli/file_system_listener.rb +0 -29
- data/lib/fluid_cli/form.rb +0 -42
- data/lib/fluid_cli/git.rb +0 -319
- data/lib/fluid_cli/http_request.rb +0 -60
- data/lib/fluid_cli/identity_auth/servlet.rb +0 -39
- data/lib/fluid_cli/identity_auth.rb +0 -126
- data/lib/fluid_cli/options.rb +0 -38
- data/lib/fluid_cli/packager.rb +0 -36
- data/lib/fluid_cli/theme/dev_server/certificate_manager.rb +0 -79
- data/lib/fluid_cli/theme/dev_server/errors.rb +0 -9
- data/lib/fluid_cli/theme/dev_server/header_hash.rb +0 -98
- data/lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb +0 -39
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot-reload-no-script.html +0 -27
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/hot_reload.js +0 -28
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/sse_client.js +0 -43
- data/lib/fluid_cli/theme/dev_server/hot_reload/resources/theme.js +0 -16
- data/lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb +0 -54
- data/lib/fluid_cli/theme/dev_server/hot_reload.rb +0 -75
- data/lib/fluid_cli/theme/dev_server/local_assets.rb +0 -92
- data/lib/fluid_cli/theme/dev_server/proxy.rb +0 -235
- data/lib/fluid_cli/theme/dev_server/proxy_param_builder.rb +0 -82
- data/lib/fluid_cli/theme/dev_server/reload_mode.rb +0 -34
- data/lib/fluid_cli/theme/dev_server/sse.rb +0 -75
- data/lib/fluid_cli/theme/dev_server/watcher.rb +0 -57
- data/lib/fluid_cli/theme/dev_server/web_server.rb +0 -140
- data/lib/fluid_cli/theme/dev_server.rb +0 -293
- data/lib/fluid_cli/theme/development_theme.rb +0 -101
- data/lib/fluid_cli/theme/file.rb +0 -105
- data/lib/fluid_cli/theme/forms/select.rb +0 -33
- data/lib/fluid_cli/theme/mime_type.rb +0 -34
- data/lib/fluid_cli/theme/presenters/theme_presenter.rb +0 -49
- data/lib/fluid_cli/theme/presenters/themes_presenter.rb +0 -31
- data/lib/fluid_cli/theme/root.rb +0 -62
- data/lib/fluid_cli/theme/syncer/checksums.rb +0 -66
- data/lib/fluid_cli/theme/syncer/downloader.rb +0 -54
- data/lib/fluid_cli/theme/syncer/error_reporter.rb +0 -45
- data/lib/fluid_cli/theme/syncer/merger.rb +0 -53
- data/lib/fluid_cli/theme/syncer/operation.rb +0 -58
- data/lib/fluid_cli/theme/syncer/standard_reporter.rb +0 -32
- data/lib/fluid_cli/theme/syncer/unsupported_script_warning.rb +0 -90
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all.rb +0 -41
- data/lib/fluid_cli/theme/syncer/uploader/forms/apply_to_all_form.rb +0 -37
- data/lib/fluid_cli/theme/syncer/uploader/forms/base_strategy_form.rb +0 -64
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_delete_strategy.rb +0 -29
- data/lib/fluid_cli/theme/syncer/uploader/forms/select_update_strategy.rb +0 -30
- data/lib/fluid_cli/theme/syncer/uploader/json_delete_handler.rb +0 -49
- data/lib/fluid_cli/theme/syncer/uploader/json_update_handler.rb +0 -71
- data/lib/fluid_cli/theme/syncer/uploader.rb +0 -105
- data/lib/fluid_cli/theme/syncer.rb +0 -492
- data/lib/fluid_cli/theme/theme.rb +0 -186
- data/lib/fluid_cli/theme/ui/sync_progress_bar.rb +0 -22
- data/lib/fluid_cli/thread_pool/job.rb +0 -35
- data/lib/fluid_cli/thread_pool.rb +0 -49
- data/packaging/homebrew/fluid_cli.base.rb +0 -103
- data/vendor/deps/base64/.document +0 -5
- data/vendor/deps/base64/.gitignore +0 -9
- data/vendor/deps/base64/BSDL +0 -22
- data/vendor/deps/base64/COPYING +0 -56
- data/vendor/deps/base64/Gemfile +0 -9
- data/vendor/deps/base64/LEGAL +0 -60
- data/vendor/deps/base64/README.md +0 -48
- data/vendor/deps/base64/Rakefile +0 -31
- data/vendor/deps/base64/base64.gemspec +0 -28
- data/vendor/deps/base64/bin/console +0 -14
- data/vendor/deps/base64/bin/setup +0 -8
- data/vendor/deps/base64/lib/base64.rb +0 -382
- data/vendor/deps/base64/sig/base64.rbs +0 -358
- data/vendor/deps/base64/test/base64/test_base64.rb +0 -115
- data/vendor/deps/base64/test_sig/test_base64.rb +0 -44
- data/vendor/deps/cli-kit/REVISION +0 -1
- data/vendor/deps/cli-kit/lib/cli/kit/args/definition.rb +0 -286
- data/vendor/deps/cli-kit/lib/cli/kit/args/evaluation.rb +0 -215
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser/node.rb +0 -128
- data/vendor/deps/cli-kit/lib/cli/kit/args/parser.rb +0 -125
- data/vendor/deps/cli-kit/lib/cli/kit/args/tokenizer.rb +0 -130
- data/vendor/deps/cli-kit/lib/cli/kit/args.rb +0 -16
- data/vendor/deps/cli-kit/lib/cli/kit/base_command.rb +0 -30
- data/vendor/deps/cli-kit/lib/cli/kit/command_help.rb +0 -268
- data/vendor/deps/cli-kit/lib/cli/kit/command_registry.rb +0 -150
- data/vendor/deps/cli-kit/lib/cli/kit/config.rb +0 -137
- data/vendor/deps/cli-kit/lib/cli/kit/core_ext.rb +0 -28
- data/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb +0 -166
- data/vendor/deps/cli-kit/lib/cli/kit/executor.rb +0 -92
- data/vendor/deps/cli-kit/lib/cli/kit/ini.rb +0 -91
- data/vendor/deps/cli-kit/lib/cli/kit/levenshtein.rb +0 -92
- data/vendor/deps/cli-kit/lib/cli/kit/logger.rb +0 -94
- data/vendor/deps/cli-kit/lib/cli/kit/opts.rb +0 -248
- data/vendor/deps/cli-kit/lib/cli/kit/parse_args.rb +0 -55
- data/vendor/deps/cli-kit/lib/cli/kit/resolver.rb +0 -66
- data/vendor/deps/cli-kit/lib/cli/kit/support/test_helper.rb +0 -260
- data/vendor/deps/cli-kit/lib/cli/kit/support.rb +0 -11
- data/vendor/deps/cli-kit/lib/cli/kit/system.rb +0 -290
- data/vendor/deps/cli-kit/lib/cli/kit/util.rb +0 -118
- data/vendor/deps/cli-kit/lib/cli/kit/version.rb +0 -7
- data/vendor/deps/cli-kit/lib/cli/kit.rb +0 -139
- data/vendor/deps/cli-ui/REVISION +0 -1
- data/vendor/deps/cli-ui/lib/cli/ui/ansi.rb +0 -218
- data/vendor/deps/cli-ui/lib/cli/ui/color.rb +0 -101
- data/vendor/deps/cli-ui/lib/cli/ui/formatter.rb +0 -219
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_stack.rb +0 -67
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/box.rb +0 -179
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style/bracket.rb +0 -152
- data/vendor/deps/cli-ui/lib/cli/ui/frame/frame_style.rb +0 -127
- data/vendor/deps/cli-ui/lib/cli/ui/frame.rb +0 -286
- data/vendor/deps/cli-ui/lib/cli/ui/glyph.rb +0 -92
- data/vendor/deps/cli-ui/lib/cli/ui/os.rb +0 -63
- data/vendor/deps/cli-ui/lib/cli/ui/printer.rb +0 -64
- data/vendor/deps/cli-ui/lib/cli/ui/progress.rb +0 -132
- data/vendor/deps/cli-ui/lib/cli/ui/progress_reporter.rb +0 -209
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/interactive_options.rb +0 -583
- data/vendor/deps/cli-ui/lib/cli/ui/prompt/options_handler.rb +0 -36
- data/vendor/deps/cli-ui/lib/cli/ui/prompt.rb +0 -381
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/async.rb +0 -48
- data/vendor/deps/cli-ui/lib/cli/ui/spinner/spin_group.rb +0 -602
- data/vendor/deps/cli-ui/lib/cli/ui/spinner.rb +0 -79
- data/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb +0 -399
- data/vendor/deps/cli-ui/lib/cli/ui/table.rb +0 -83
- data/vendor/deps/cli-ui/lib/cli/ui/terminal.rb +0 -55
- data/vendor/deps/cli-ui/lib/cli/ui/truncater.rb +0 -106
- data/vendor/deps/cli-ui/lib/cli/ui/version.rb +0 -8
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/base.rb +0 -46
- data/vendor/deps/cli-ui/lib/cli/ui/widgets/status.rb +0 -79
- data/vendor/deps/cli-ui/lib/cli/ui/widgets.rb +0 -89
- data/vendor/deps/cli-ui/lib/cli/ui/work_queue.rb +0 -142
- data/vendor/deps/cli-ui/lib/cli/ui/wrap.rb +0 -61
- data/vendor/deps/cli-ui/lib/cli/ui.rb +0 -359
- data/vendor/deps/cli-ui/vendor/reentrant_mutex.rb +0 -78
- data/vendor/deps/webrick/.gitignore +0 -9
- data/vendor/deps/webrick/Gemfile +0 -3
- data/vendor/deps/webrick/LICENSE.txt +0 -22
- data/vendor/deps/webrick/README.md +0 -61
- data/vendor/deps/webrick/Rakefile +0 -10
- data/vendor/deps/webrick/lib/webrick/accesslog.rb +0 -157
- data/vendor/deps/webrick/lib/webrick/cgi.rb +0 -313
- data/vendor/deps/webrick/lib/webrick/compat.rb +0 -36
- data/vendor/deps/webrick/lib/webrick/config.rb +0 -158
- data/vendor/deps/webrick/lib/webrick/cookie.rb +0 -172
- data/vendor/deps/webrick/lib/webrick/htmlutils.rb +0 -30
- data/vendor/deps/webrick/lib/webrick/httpauth/authenticator.rb +0 -117
- data/vendor/deps/webrick/lib/webrick/httpauth/basicauth.rb +0 -116
- data/vendor/deps/webrick/lib/webrick/httpauth/digestauth.rb +0 -395
- data/vendor/deps/webrick/lib/webrick/httpauth/htdigest.rb +0 -132
- data/vendor/deps/webrick/lib/webrick/httpauth/htgroup.rb +0 -97
- data/vendor/deps/webrick/lib/webrick/httpauth/htpasswd.rb +0 -158
- data/vendor/deps/webrick/lib/webrick/httpauth/userdb.rb +0 -53
- data/vendor/deps/webrick/lib/webrick/httpauth.rb +0 -96
- data/vendor/deps/webrick/lib/webrick/httpproxy.rb +0 -354
- data/vendor/deps/webrick/lib/webrick/httprequest.rb +0 -636
- data/vendor/deps/webrick/lib/webrick/httpresponse.rb +0 -564
- data/vendor/deps/webrick/lib/webrick/https.rb +0 -152
- data/vendor/deps/webrick/lib/webrick/httpserver.rb +0 -294
- data/vendor/deps/webrick/lib/webrick/httpservlet/abstract.rb +0 -152
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgi_runner.rb +0 -47
- data/vendor/deps/webrick/lib/webrick/httpservlet/cgihandler.rb +0 -126
- data/vendor/deps/webrick/lib/webrick/httpservlet/erbhandler.rb +0 -88
- data/vendor/deps/webrick/lib/webrick/httpservlet/filehandler.rb +0 -552
- data/vendor/deps/webrick/lib/webrick/httpservlet/prochandler.rb +0 -47
- data/vendor/deps/webrick/lib/webrick/httpservlet.rb +0 -23
- data/vendor/deps/webrick/lib/webrick/httpstatus.rb +0 -194
- data/vendor/deps/webrick/lib/webrick/httputils.rb +0 -512
- data/vendor/deps/webrick/lib/webrick/httpversion.rb +0 -76
- data/vendor/deps/webrick/lib/webrick/log.rb +0 -156
- data/vendor/deps/webrick/lib/webrick/server.rb +0 -381
- data/vendor/deps/webrick/lib/webrick/ssl.rb +0 -215
- data/vendor/deps/webrick/lib/webrick/utils.rb +0 -265
- data/vendor/deps/webrick/lib/webrick/version.rb +0 -18
- data/vendor/deps/webrick/lib/webrick.rb +0 -232
- data/vendor/deps/webrick/webrick.gemspec +0 -74
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
# typed: true
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
module CLI
|
|
5
|
-
module UI
|
|
6
|
-
autoload :ANSI, 'cli/ui/ansi'
|
|
7
|
-
autoload :Glyph, 'cli/ui/glyph'
|
|
8
|
-
autoload :Color, 'cli/ui/color'
|
|
9
|
-
autoload :Frame, 'cli/ui/frame'
|
|
10
|
-
autoload :OS, 'cli/ui/os'
|
|
11
|
-
autoload :Printer, 'cli/ui/printer'
|
|
12
|
-
autoload :Progress, 'cli/ui/progress'
|
|
13
|
-
autoload :ProgressReporter, 'cli/ui/progress_reporter'
|
|
14
|
-
autoload :Prompt, 'cli/ui/prompt'
|
|
15
|
-
autoload :Table, 'cli/ui/table'
|
|
16
|
-
autoload :Terminal, 'cli/ui/terminal'
|
|
17
|
-
autoload :Truncater, 'cli/ui/truncater'
|
|
18
|
-
autoload :Formatter, 'cli/ui/formatter'
|
|
19
|
-
autoload :Spinner, 'cli/ui/spinner'
|
|
20
|
-
autoload :Widgets, 'cli/ui/widgets'
|
|
21
|
-
autoload :Wrap, 'cli/ui/wrap'
|
|
22
|
-
|
|
23
|
-
# Convenience accessor to +CLI::UI::Spinner::SpinGroup+
|
|
24
|
-
SpinGroup = Spinner::SpinGroup
|
|
25
|
-
|
|
26
|
-
#: type colorable = Symbol | String | CLI::UI::Color
|
|
27
|
-
#: type frame_stylable = Symbol | String | CLI::UI::Frame::FrameStyle
|
|
28
|
-
#: type io_like = IO | StringIO
|
|
29
|
-
|
|
30
|
-
class << self
|
|
31
|
-
# Glyph resolution using +CLI::UI::Glyph.lookup+
|
|
32
|
-
# Look at the method signature for +Glyph.lookup+ for more details
|
|
33
|
-
#
|
|
34
|
-
# ==== Attributes
|
|
35
|
-
#
|
|
36
|
-
# * +handle+ - handle of the glyph to resolve
|
|
37
|
-
#
|
|
38
|
-
#: (String handle) -> Glyph
|
|
39
|
-
def glyph(handle)
|
|
40
|
-
CLI::UI::Glyph.lookup(handle)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Color resolution using +CLI::UI::Color.lookup+
|
|
44
|
-
# Will lookup using +Color.lookup+ unless it's already a CLI::UI::Color (or nil)
|
|
45
|
-
#
|
|
46
|
-
# ==== Attributes
|
|
47
|
-
#
|
|
48
|
-
# * +input+ - color to resolve
|
|
49
|
-
#
|
|
50
|
-
#: (colorable input) -> CLI::UI::Color
|
|
51
|
-
def resolve_color(input)
|
|
52
|
-
case input
|
|
53
|
-
when CLI::UI::Color
|
|
54
|
-
input
|
|
55
|
-
else
|
|
56
|
-
CLI::UI::Color.lookup(input)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# Frame style resolution using +CLI::UI::Frame::FrameStyle.lookup+.
|
|
61
|
-
# Will lookup using +FrameStyle.lookup+ unless it's already a CLI::UI::Frame::FrameStyle(or nil)
|
|
62
|
-
#
|
|
63
|
-
# ==== Attributes
|
|
64
|
-
#
|
|
65
|
-
# * +input+ - frame style to resolve
|
|
66
|
-
#: (frame_stylable input) -> CLI::UI::Frame::FrameStyle
|
|
67
|
-
def resolve_style(input)
|
|
68
|
-
case input
|
|
69
|
-
when CLI::UI::Frame::FrameStyle
|
|
70
|
-
input
|
|
71
|
-
else
|
|
72
|
-
CLI::UI::Frame::FrameStyle.lookup(input.to_s)
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Convenience Method for +CLI::UI::Prompt.confirm+
|
|
77
|
-
#
|
|
78
|
-
# ==== Attributes
|
|
79
|
-
#
|
|
80
|
-
# * +question+ - question to confirm
|
|
81
|
-
#
|
|
82
|
-
#: (String question, ?default: bool) -> bool
|
|
83
|
-
def confirm(question, default: true)
|
|
84
|
-
CLI::UI::Prompt.confirm(question, default: default)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Convenience Method for +CLI::UI::Prompt.any_key+
|
|
88
|
-
#
|
|
89
|
-
# ==== Attributes
|
|
90
|
-
#
|
|
91
|
-
# * +prompt+ - prompt to present
|
|
92
|
-
#
|
|
93
|
-
#: (?String prompt) -> String?
|
|
94
|
-
def any_key(prompt = 'Press any key to continue')
|
|
95
|
-
CLI::UI::Prompt.any_key(prompt)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# Convenience Method for +CLI::UI::Prompt.ask+
|
|
99
|
-
#: (String question, ?options: Array[String]?, ?default: (String | Array[String])?, ?is_file: bool, ?allow_empty: bool, ?multiple: bool, ?filter_ui: bool, ?select_ui: bool) ?{ (Prompt::OptionsHandler handler) -> void } -> (String | Array[String])
|
|
100
|
-
def ask(
|
|
101
|
-
question,
|
|
102
|
-
options: nil,
|
|
103
|
-
default: nil,
|
|
104
|
-
is_file: false,
|
|
105
|
-
allow_empty: true,
|
|
106
|
-
multiple: false,
|
|
107
|
-
filter_ui: true,
|
|
108
|
-
select_ui: true,
|
|
109
|
-
&options_proc
|
|
110
|
-
)
|
|
111
|
-
CLI::UI::Prompt.ask(
|
|
112
|
-
question,
|
|
113
|
-
options: options,
|
|
114
|
-
default: default,
|
|
115
|
-
is_file: is_file,
|
|
116
|
-
allow_empty: allow_empty,
|
|
117
|
-
multiple: multiple,
|
|
118
|
-
filter_ui: filter_ui,
|
|
119
|
-
select_ui: select_ui,
|
|
120
|
-
&options_proc
|
|
121
|
-
)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Convenience Method to resolve text using +CLI::UI::Formatter.format+
|
|
125
|
-
# Check +CLI::UI::Formatter::SGR_MAP+ for available formatting options
|
|
126
|
-
#
|
|
127
|
-
# ==== Attributes
|
|
128
|
-
#
|
|
129
|
-
# * +input+ - input to format
|
|
130
|
-
# * +truncate_to+ - number of characters to truncate the string to (or nil)
|
|
131
|
-
# * +enable_color+ - should color be used? default to true unless output is redirected.
|
|
132
|
-
#
|
|
133
|
-
#: (String input, ?truncate_to: Integer?, ?enable_color: bool) -> String
|
|
134
|
-
def resolve_text(input, truncate_to: nil, enable_color: enable_color?)
|
|
135
|
-
formatted = CLI::UI::Formatter.new(input).format(enable_color: enable_color)
|
|
136
|
-
return formatted unless truncate_to
|
|
137
|
-
|
|
138
|
-
CLI::UI::Truncater.call(formatted, truncate_to)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Convenience Method to format text using +CLI::UI::Formatter.format+
|
|
142
|
-
# Check +CLI::UI::Formatter::SGR_MAP+ for available formatting options
|
|
143
|
-
#
|
|
144
|
-
# https://user-images.githubusercontent.com/3074765/33799827-6d0721a2-dd01-11e7-9ab5-c3d455264afe.png
|
|
145
|
-
# https://user-images.githubusercontent.com/3074765/33799847-9ec03fd0-dd01-11e7-93f7-5f5cc540e61e.png
|
|
146
|
-
#
|
|
147
|
-
# ==== Attributes
|
|
148
|
-
#
|
|
149
|
-
# * +input+ - input to format
|
|
150
|
-
#
|
|
151
|
-
# ==== Options
|
|
152
|
-
#
|
|
153
|
-
# * +enable_color+ - should color be used? default to true unless output is redirected.
|
|
154
|
-
#
|
|
155
|
-
#: (String input, ?enable_color: bool) -> String
|
|
156
|
-
def fmt(input, enable_color: enable_color?)
|
|
157
|
-
CLI::UI::Formatter.new(input).format(enable_color: enable_color)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
#: (String input) -> String
|
|
161
|
-
def wrap(input)
|
|
162
|
-
CLI::UI::Wrap.new(input).wrap
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
# Convenience Method for +CLI::UI::Printer.puts+
|
|
166
|
-
#
|
|
167
|
-
# ==== Attributes
|
|
168
|
-
#
|
|
169
|
-
# * +msg+ - Message to print
|
|
170
|
-
# * +kwargs+ - keyword arguments for +Printer.puts+
|
|
171
|
-
#
|
|
172
|
-
#: (String msg, ?frame_color: colorable?, ?to: io_like, ?encoding: Encoding, ?format: bool, ?graceful: bool, ?wrap: bool) -> void
|
|
173
|
-
def puts(
|
|
174
|
-
msg,
|
|
175
|
-
frame_color: nil,
|
|
176
|
-
to: $stdout,
|
|
177
|
-
encoding: Encoding::UTF_8,
|
|
178
|
-
format: true,
|
|
179
|
-
graceful: true,
|
|
180
|
-
wrap: true
|
|
181
|
-
)
|
|
182
|
-
CLI::UI::Printer.puts(
|
|
183
|
-
msg,
|
|
184
|
-
frame_color: frame_color,
|
|
185
|
-
to: to,
|
|
186
|
-
encoding: encoding,
|
|
187
|
-
format: format,
|
|
188
|
-
graceful: graceful,
|
|
189
|
-
wrap: wrap,
|
|
190
|
-
)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# Convenience Method for +CLI::UI::Frame.open+
|
|
194
|
-
#
|
|
195
|
-
# ==== Attributes
|
|
196
|
-
#
|
|
197
|
-
# * +args+ - arguments for +Frame.open+
|
|
198
|
-
# * +block+ - block for +Frame.open+
|
|
199
|
-
#
|
|
200
|
-
#: [T] (String text, ?color: colorable?, ?failure_text: String?, ?success_text: String?, ?timing: (Numeric | bool), ?frame_style: frame_stylable, ?to: io_like) ?{ -> T } -> T?
|
|
201
|
-
def frame(
|
|
202
|
-
text,
|
|
203
|
-
color: Frame::DEFAULT_FRAME_COLOR,
|
|
204
|
-
failure_text: nil,
|
|
205
|
-
success_text: nil,
|
|
206
|
-
timing: block_given?,
|
|
207
|
-
frame_style: Frame.frame_style,
|
|
208
|
-
to: $stdout,
|
|
209
|
-
&block
|
|
210
|
-
)
|
|
211
|
-
CLI::UI::Frame.open(
|
|
212
|
-
text,
|
|
213
|
-
color: color,
|
|
214
|
-
failure_text: failure_text,
|
|
215
|
-
success_text: success_text,
|
|
216
|
-
timing: timing,
|
|
217
|
-
frame_style: frame_style,
|
|
218
|
-
to: to,
|
|
219
|
-
&block
|
|
220
|
-
)
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# Convenience Method for +CLI::UI::Spinner.spin+
|
|
224
|
-
#
|
|
225
|
-
# ==== Attributes
|
|
226
|
-
#
|
|
227
|
-
# * +args+ - arguments for +Spinner.open+
|
|
228
|
-
# * +block+ - block for +Spinner.open+
|
|
229
|
-
#
|
|
230
|
-
#: (String title, ?auto_debrief: bool, ?to: io_like) { (Spinner::SpinGroup::Task task) -> void } -> bool
|
|
231
|
-
def spinner(title, auto_debrief: true, to: $stdout, &block)
|
|
232
|
-
CLI::UI::Spinner.spin(title, auto_debrief: auto_debrief, to: to, &block)
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
# Convenience Method to override frame color using +CLI::UI::Frame.with_frame_color+
|
|
236
|
-
#
|
|
237
|
-
# ==== Attributes
|
|
238
|
-
#
|
|
239
|
-
# * +color+ - color to override to
|
|
240
|
-
# * +block+ - block for +Frame.with_frame_color_override+
|
|
241
|
-
#
|
|
242
|
-
#: [T] (colorable color) { -> T } -> T
|
|
243
|
-
def with_frame_color(color, &block)
|
|
244
|
-
CLI::UI::Frame.with_frame_color_override(color, &block)
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
# Duplicate output to a file path
|
|
248
|
-
#
|
|
249
|
-
# ==== Attributes
|
|
250
|
-
#
|
|
251
|
-
# * +path+ - path to duplicate output to
|
|
252
|
-
#
|
|
253
|
-
#: [T] (String path) { -> T } -> T
|
|
254
|
-
def log_output_to(path, &block)
|
|
255
|
-
if CLI::UI::StdoutRouter.duplicate_output_to
|
|
256
|
-
raise 'multiple logs not allowed'
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
CLI::UI::StdoutRouter.duplicate_output_to = File.open(path, 'w')
|
|
260
|
-
yield
|
|
261
|
-
ensure
|
|
262
|
-
if (file_descriptor = CLI::UI::StdoutRouter.duplicate_output_to)
|
|
263
|
-
begin
|
|
264
|
-
file_descriptor.close
|
|
265
|
-
rescue IOError
|
|
266
|
-
nil
|
|
267
|
-
end
|
|
268
|
-
CLI::UI::StdoutRouter.duplicate_output_to = nil
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
# Disable all framing within a block
|
|
273
|
-
#
|
|
274
|
-
# ==== Attributes
|
|
275
|
-
#
|
|
276
|
-
# * +block+ - block in which to disable frames
|
|
277
|
-
#
|
|
278
|
-
#: [T] { -> T } -> T
|
|
279
|
-
def raw(&block)
|
|
280
|
-
prev = Thread.current[:no_cliui_frame_inset]
|
|
281
|
-
Thread.current[:no_cliui_frame_inset] = true
|
|
282
|
-
yield
|
|
283
|
-
ensure
|
|
284
|
-
Thread.current[:no_cliui_frame_inset] = prev
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
# Check whether colour is enabled in Formatter, Frame, and Spinner output.
|
|
288
|
-
# By default, colour is enabled when STDOUT is a TTY; that is, when output
|
|
289
|
-
# has not been directed to another program or to a file.
|
|
290
|
-
#
|
|
291
|
-
#: -> bool
|
|
292
|
-
def enable_color?
|
|
293
|
-
@enable_color
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
# Turn colour in Formatter, Frame, and Spinner output on or off.
|
|
297
|
-
#
|
|
298
|
-
# ==== Attributes
|
|
299
|
-
#
|
|
300
|
-
# * +bool+ - true or false; enable or disable colour.
|
|
301
|
-
#
|
|
302
|
-
#: (bool bool) -> void
|
|
303
|
-
def enable_color=(bool)
|
|
304
|
-
@enable_color = !!bool
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
# Check whether cursor control is enabled in Formatter, Frame, and Spinner output.
|
|
308
|
-
# By default, cursor control is enabled when STDOUT is a TTY; that is, when output
|
|
309
|
-
# has not been directed to another program or to a file.
|
|
310
|
-
#
|
|
311
|
-
#: -> bool
|
|
312
|
-
def enable_cursor?
|
|
313
|
-
@enable_cursor
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
# Turn cursor control in Formatter, Frame, and Spinner output on or off.
|
|
317
|
-
#
|
|
318
|
-
# ==== Attributes
|
|
319
|
-
#
|
|
320
|
-
# * +bool+ - true or false; enable or disable cursor control.
|
|
321
|
-
#
|
|
322
|
-
#: (bool bool) -> void
|
|
323
|
-
def enable_cursor=(bool)
|
|
324
|
-
@enable_cursor = !!bool
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
# Set the default frame style.
|
|
328
|
-
# Convenience method for setting the default frame style with +CLI::UI::Frame.frame_style=+
|
|
329
|
-
#
|
|
330
|
-
# Raises ArgumentError if +frame_style+ is not valid
|
|
331
|
-
#
|
|
332
|
-
# ==== Attributes
|
|
333
|
-
#
|
|
334
|
-
# * +symbol+ - the default frame style to use for frames
|
|
335
|
-
#
|
|
336
|
-
#: (frame_stylable frame_style) -> void
|
|
337
|
-
def frame_style=(frame_style)
|
|
338
|
-
Frame.frame_style = frame_style
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
# Create a terminal link
|
|
342
|
-
#: (String url, String text, ?format: bool, ?blue_underline: bool) -> String
|
|
343
|
-
def link(url, text, format: true, blue_underline: format)
|
|
344
|
-
raise 'cannot use blue_underline without format' if blue_underline && !format
|
|
345
|
-
|
|
346
|
-
text = "{{blue:{{underline:#{text}}}}}" if blue_underline
|
|
347
|
-
text = CLI::UI.fmt(text) if format
|
|
348
|
-
"\x1b]8;;#{url}\x1b\\#{text}\x1b]8;;\x1b\\"
|
|
349
|
-
end
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
self.enable_color = $stdout.tty? && ENV['TERM'] != 'dumb' #: as !nil
|
|
353
|
-
|
|
354
|
-
# Shopify's CI system supports color, but not cursor control
|
|
355
|
-
self.enable_cursor = $stdout.tty? && ENV['TERM'] != 'dumb' && ENV['CI'].nil? && ENV['JOURNAL_STREAM'].nil? #: as !nil
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
|
-
|
|
359
|
-
require 'cli/ui/stdout_router'
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Copyright (c) 2014 Boris Bera
|
|
2
|
-
#
|
|
3
|
-
# MIT License
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
# a copy of this software and associated documentation files (the
|
|
7
|
-
# "Software"), to deal in the Software without restriction, including
|
|
8
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
# the following conditions:
|
|
12
|
-
#
|
|
13
|
-
# The above copyright notice and this permission notice shall be
|
|
14
|
-
# included in all copies or substantial portions of the Software.
|
|
15
|
-
#
|
|
16
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
# Sourced from https://github.com/dotboris/reentrant_mutex
|
|
25
|
-
module CLI
|
|
26
|
-
module UI
|
|
27
|
-
class ReentrantMutex < Mutex
|
|
28
|
-
def initialize
|
|
29
|
-
@count_mutex = Mutex.new
|
|
30
|
-
@counts = Hash.new(0)
|
|
31
|
-
|
|
32
|
-
super
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def synchronize
|
|
36
|
-
raise ThreadError, 'Must be called with a block' unless block_given?
|
|
37
|
-
|
|
38
|
-
begin
|
|
39
|
-
lock
|
|
40
|
-
yield
|
|
41
|
-
ensure
|
|
42
|
-
unlock
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def lock
|
|
47
|
-
c = increase_count Thread.current
|
|
48
|
-
super if c <= 1
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def unlock
|
|
52
|
-
c = decrease_count Thread.current
|
|
53
|
-
if c <= 0
|
|
54
|
-
super
|
|
55
|
-
delete_count Thread.current
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def count
|
|
60
|
-
@count_mutex.synchronize { @counts[Thread.current] }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
def increase_count(thread)
|
|
66
|
-
@count_mutex.synchronize { @counts[thread] += 1 }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def decrease_count(thread)
|
|
70
|
-
@count_mutex.synchronize { @counts[thread] -= 1 }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def delete_count(thread)
|
|
74
|
-
@count_mutex.synchronize { @counts.delete(thread) }
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
data/vendor/deps/webrick/Gemfile
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without
|
|
4
|
-
modification, are permitted provided that the following conditions
|
|
5
|
-
are met:
|
|
6
|
-
1. Redistributions of source code must retain the above copyright
|
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
|
8
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
|
10
|
-
documentation and/or other materials provided with the distribution.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
13
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
14
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
15
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
16
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
17
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
18
|
-
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
19
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
20
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
21
|
-
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
22
|
-
SUCH DAMAGE.
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# Webrick
|
|
2
|
-
|
|
3
|
-
WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.
|
|
4
|
-
|
|
5
|
-
WEBrick features complete logging of both server operations and HTTP access.
|
|
6
|
-
|
|
7
|
-
WEBrick supports both basic and digest authentication in addition to algorithms not in RFC 2617.
|
|
8
|
-
|
|
9
|
-
A WEBrick server can be composed of multiple WEBrick servers or servlets to provide differing behavior on a per-host or per-path basis. WEBrick includes servlets for handling CGI scripts, ERB pages, Ruby blocks and directory listings.
|
|
10
|
-
|
|
11
|
-
WEBrick also includes tools for daemonizing a process and starting a process at a higher privilege level and dropping permissions.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Add this line to your application's Gemfile:
|
|
16
|
-
|
|
17
|
-
```ruby
|
|
18
|
-
gem 'webrick'
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
And then execute:
|
|
22
|
-
|
|
23
|
-
$ bundle
|
|
24
|
-
|
|
25
|
-
Or install it yourself as:
|
|
26
|
-
|
|
27
|
-
$ gem install webrick
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
To create a new WEBrick::HTTPServer that will listen to connections on port 8000 and serve documents from the current user's public_html folder:
|
|
32
|
-
|
|
33
|
-
```ruby
|
|
34
|
-
require 'webrick'
|
|
35
|
-
|
|
36
|
-
root = File.expand_path '~/public_html'
|
|
37
|
-
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
To run the server you will need to provide a suitable shutdown hook as
|
|
41
|
-
starting the server blocks the current thread:
|
|
42
|
-
|
|
43
|
-
```ruby
|
|
44
|
-
trap 'INT' do server.shutdown end
|
|
45
|
-
|
|
46
|
-
server.start
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Development
|
|
50
|
-
|
|
51
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
52
|
-
|
|
53
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
54
|
-
|
|
55
|
-
## Contributing
|
|
56
|
-
|
|
57
|
-
Bug reports and Patch are welcome on https://bugs.ruby-lang.org/.
|
|
58
|
-
|
|
59
|
-
## License
|
|
60
|
-
|
|
61
|
-
The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
#--
|
|
3
|
-
# accesslog.rb -- Access log handling utilities
|
|
4
|
-
#
|
|
5
|
-
# Author: IPR -- Internet Programming with Ruby -- writers
|
|
6
|
-
# Copyright (c) 2002 keita yamaguchi
|
|
7
|
-
# Copyright (c) 2002 Internet Programming with Ruby writers
|
|
8
|
-
#
|
|
9
|
-
# $IPR: accesslog.rb,v 1.1 2002/10/01 17:16:32 gotoyuzo Exp $
|
|
10
|
-
|
|
11
|
-
module WEBrick
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
# AccessLog provides logging to various files in various formats.
|
|
15
|
-
#
|
|
16
|
-
# Multiple logs may be written to at the same time:
|
|
17
|
-
#
|
|
18
|
-
# access_log = [
|
|
19
|
-
# [$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT],
|
|
20
|
-
# [$stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT],
|
|
21
|
-
# ]
|
|
22
|
-
#
|
|
23
|
-
# server = WEBrick::HTTPServer.new :AccessLog => access_log
|
|
24
|
-
#
|
|
25
|
-
# Custom log formats may be defined. WEBrick::AccessLog provides a subset
|
|
26
|
-
# of the formatting from Apache's mod_log_config
|
|
27
|
-
# http://httpd.apache.org/docs/mod/mod_log_config.html#formats. See
|
|
28
|
-
# AccessLog::setup_params for a list of supported options
|
|
29
|
-
|
|
30
|
-
module AccessLog
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
# Raised if a parameter such as %e, %i, %o or %n is used without fetching
|
|
34
|
-
# a specific field.
|
|
35
|
-
|
|
36
|
-
class AccessLogError < StandardError; end
|
|
37
|
-
|
|
38
|
-
##
|
|
39
|
-
# The Common Log Format's time format
|
|
40
|
-
|
|
41
|
-
CLF_TIME_FORMAT = "[%d/%b/%Y:%H:%M:%S %Z]"
|
|
42
|
-
|
|
43
|
-
##
|
|
44
|
-
# Common Log Format
|
|
45
|
-
|
|
46
|
-
COMMON_LOG_FORMAT = "%h %l %u %t \"%r\" %s %b"
|
|
47
|
-
|
|
48
|
-
##
|
|
49
|
-
# Short alias for Common Log Format
|
|
50
|
-
|
|
51
|
-
CLF = COMMON_LOG_FORMAT
|
|
52
|
-
|
|
53
|
-
##
|
|
54
|
-
# Referer Log Format
|
|
55
|
-
|
|
56
|
-
REFERER_LOG_FORMAT = "%{Referer}i -> %U"
|
|
57
|
-
|
|
58
|
-
##
|
|
59
|
-
# User-Agent Log Format
|
|
60
|
-
|
|
61
|
-
AGENT_LOG_FORMAT = "%{User-Agent}i"
|
|
62
|
-
|
|
63
|
-
##
|
|
64
|
-
# Combined Log Format
|
|
65
|
-
|
|
66
|
-
COMBINED_LOG_FORMAT = "#{CLF} \"%{Referer}i\" \"%{User-agent}i\""
|
|
67
|
-
|
|
68
|
-
module_function
|
|
69
|
-
|
|
70
|
-
# This format specification is a subset of mod_log_config of Apache:
|
|
71
|
-
#
|
|
72
|
-
# %a:: Remote IP address
|
|
73
|
-
# %b:: Total response size
|
|
74
|
-
# %e{variable}:: Given variable in ENV
|
|
75
|
-
# %f:: Response filename
|
|
76
|
-
# %h:: Remote host name
|
|
77
|
-
# %{header}i:: Given request header
|
|
78
|
-
# %l:: Remote logname, always "-"
|
|
79
|
-
# %m:: Request method
|
|
80
|
-
# %{attr}n:: Given request attribute from <tt>req.attributes</tt>
|
|
81
|
-
# %{header}o:: Given response header
|
|
82
|
-
# %p:: Server's request port
|
|
83
|
-
# %{format}p:: The canonical port of the server serving the request or the
|
|
84
|
-
# actual port or the client's actual port. Valid formats are
|
|
85
|
-
# canonical, local or remote.
|
|
86
|
-
# %q:: Request query string
|
|
87
|
-
# %r:: First line of the request
|
|
88
|
-
# %s:: Request status
|
|
89
|
-
# %t:: Time the request was received
|
|
90
|
-
# %T:: Time taken to process the request
|
|
91
|
-
# %u:: Remote user from auth
|
|
92
|
-
# %U:: Unparsed URI
|
|
93
|
-
# %%:: Literal %
|
|
94
|
-
|
|
95
|
-
def setup_params(config, req, res)
|
|
96
|
-
params = Hash.new("")
|
|
97
|
-
params["a"] = req.peeraddr[3]
|
|
98
|
-
params["b"] = res.sent_size
|
|
99
|
-
params["e"] = ENV
|
|
100
|
-
params["f"] = res.filename || ""
|
|
101
|
-
params["h"] = req.peeraddr[2]
|
|
102
|
-
params["i"] = req
|
|
103
|
-
params["l"] = "-"
|
|
104
|
-
params["m"] = req.request_method
|
|
105
|
-
params["n"] = req.attributes
|
|
106
|
-
params["o"] = res
|
|
107
|
-
params["p"] = req.port
|
|
108
|
-
params["q"] = req.query_string
|
|
109
|
-
params["r"] = req.request_line.sub(/\x0d?\x0a\z/o, '')
|
|
110
|
-
params["s"] = res.status # won't support "%>s"
|
|
111
|
-
params["t"] = req.request_time
|
|
112
|
-
params["T"] = Time.now - req.request_time
|
|
113
|
-
params["u"] = req.user || "-"
|
|
114
|
-
params["U"] = req.unparsed_uri
|
|
115
|
-
params["v"] = config[:ServerName]
|
|
116
|
-
params
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
##
|
|
120
|
-
# Formats +params+ according to +format_string+ which is described in
|
|
121
|
-
# setup_params.
|
|
122
|
-
|
|
123
|
-
def format(format_string, params)
|
|
124
|
-
format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){
|
|
125
|
-
param, spec = $1, $2
|
|
126
|
-
case spec[0]
|
|
127
|
-
when ?e, ?i, ?n, ?o
|
|
128
|
-
raise AccessLogError,
|
|
129
|
-
"parameter is required for \"#{spec}\"" unless param
|
|
130
|
-
(param = params[spec][param]) ? escape(param) : "-"
|
|
131
|
-
when ?t
|
|
132
|
-
params[spec].strftime(param || CLF_TIME_FORMAT)
|
|
133
|
-
when ?p
|
|
134
|
-
case param
|
|
135
|
-
when 'remote'
|
|
136
|
-
escape(params["i"].peeraddr[1].to_s)
|
|
137
|
-
else
|
|
138
|
-
escape(params["p"].to_s)
|
|
139
|
-
end
|
|
140
|
-
when ?%
|
|
141
|
-
"%"
|
|
142
|
-
else
|
|
143
|
-
escape(params[spec].to_s)
|
|
144
|
-
end
|
|
145
|
-
}
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
##
|
|
149
|
-
# Escapes control characters in +data+
|
|
150
|
-
|
|
151
|
-
def escape(data)
|
|
152
|
-
data = data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}
|
|
153
|
-
data.untaint if RUBY_VERSION < '2.7'
|
|
154
|
-
data
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|