brick_ftp 0.8.4 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -5
- data/.rubocop.yml +2 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +16 -12
- data/Gemfile +2 -0
- data/README.md +24 -43
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/brick_ftp.gemspec +10 -9
- data/exe/brick_ftp +1 -0
- data/lib/brick_ftp.rb +5 -78
- data/lib/brick_ftp/client.rb +35 -411
- data/lib/brick_ftp/core_ext.rb +8 -0
- data/lib/brick_ftp/core_ext/hash.rb +13 -0
- data/lib/brick_ftp/core_ext/hash/compact.rb +13 -0
- data/lib/brick_ftp/core_ext/struct.rb +13 -0
- data/lib/brick_ftp/core_ext/struct/new.rb +16 -0
- data/lib/brick_ftp/restful_api.rb +82 -0
- data/lib/brick_ftp/restful_api/add_group_member.rb +44 -0
- data/lib/brick_ftp/restful_api/client.rb +179 -0
- data/lib/brick_ftp/restful_api/command.rb +21 -0
- data/lib/brick_ftp/restful_api/complete_upload.rb +46 -0
- data/lib/brick_ftp/restful_api/continue_upload.rb +50 -0
- data/lib/brick_ftp/restful_api/copy_folder.rb +46 -0
- data/lib/brick_ftp/restful_api/count_folder_contents.rb +36 -0
- data/lib/brick_ftp/restful_api/count_users.rb +22 -0
- data/lib/brick_ftp/restful_api/create_api_key.rb +46 -0
- data/lib/brick_ftp/restful_api/create_behavior.rb +42 -0
- data/lib/brick_ftp/restful_api/create_bundle.rb +40 -0
- data/lib/brick_ftp/restful_api/create_folder.rb +25 -0
- data/lib/brick_ftp/restful_api/create_group.rb +42 -0
- data/lib/brick_ftp/restful_api/create_notification.rb +44 -0
- data/lib/brick_ftp/restful_api/create_permission.rb +48 -0
- data/lib/brick_ftp/restful_api/create_public_key.rb +42 -0
- data/lib/brick_ftp/restful_api/create_user.rb +90 -0
- data/lib/brick_ftp/restful_api/create_user_in_group.rb +60 -0
- data/lib/brick_ftp/restful_api/delete_api_key.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_behavior.rb +22 -0
- data/lib/brick_ftp/restful_api/delete_bundle.rb +22 -0
- data/lib/brick_ftp/restful_api/delete_folder.rb +32 -0
- data/lib/brick_ftp/restful_api/delete_group.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_notification.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_permission.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_public_key.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_user.rb +25 -0
- data/lib/brick_ftp/restful_api/download_file.rb +44 -0
- data/lib/brick_ftp/restful_api/get_api_key.rb +25 -0
- data/lib/brick_ftp/restful_api/get_behavior.rb +25 -0
- data/lib/brick_ftp/restful_api/get_bundle.rb +25 -0
- data/lib/brick_ftp/restful_api/get_bundle_zip.rb +48 -0
- data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +49 -0
- data/lib/brick_ftp/restful_api/get_folder_size.rb +25 -0
- data/lib/brick_ftp/restful_api/get_group.rb +26 -0
- data/lib/brick_ftp/restful_api/get_public_key.rb +25 -0
- data/lib/brick_ftp/restful_api/get_site_usage.rb +19 -0
- data/lib/brick_ftp/restful_api/get_user.rb +26 -0
- data/lib/brick_ftp/restful_api/list_api_keys.rb +25 -0
- data/lib/brick_ftp/restful_api/list_behaviors.rb +23 -0
- data/lib/brick_ftp/restful_api/list_bundle_contents.rb +58 -0
- data/lib/brick_ftp/restful_api/list_bundles.rb +23 -0
- data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +39 -0
- data/lib/brick_ftp/restful_api/list_folders.rb +108 -0
- data/lib/brick_ftp/restful_api/list_groups.rb +23 -0
- data/lib/brick_ftp/restful_api/list_notifications.rb +23 -0
- data/lib/brick_ftp/restful_api/list_permissions.rb +41 -0
- data/lib/brick_ftp/restful_api/list_public_keys.rb +25 -0
- data/lib/brick_ftp/restful_api/list_users.rb +60 -0
- data/lib/brick_ftp/restful_api/move_folder.rb +41 -0
- data/lib/brick_ftp/restful_api/remove_group_member.rb +23 -0
- data/lib/brick_ftp/restful_api/retrieve_file_history.rb +41 -0
- data/lib/brick_ftp/restful_api/retrieve_folder_history.rb +41 -0
- data/lib/brick_ftp/restful_api/retrieve_history.rb +54 -0
- data/lib/brick_ftp/restful_api/retrieve_login_history.rb +38 -0
- data/lib/brick_ftp/restful_api/retrieve_site_history.rb +38 -0
- data/lib/brick_ftp/restful_api/retrieve_user_history.rb +40 -0
- data/lib/brick_ftp/restful_api/search_user.rb +28 -0
- data/lib/brick_ftp/restful_api/start_upload.rb +27 -0
- data/lib/brick_ftp/restful_api/unlock_user.rb +25 -0
- data/lib/brick_ftp/restful_api/update_behavior.rb +39 -0
- data/lib/brick_ftp/restful_api/update_group.rb +44 -0
- data/lib/brick_ftp/restful_api/update_group_member.rb +40 -0
- data/lib/brick_ftp/restful_api/update_user.rb +101 -0
- data/lib/brick_ftp/restful_api/upload_file.rb +65 -0
- data/lib/brick_ftp/types.rb +23 -0
- data/lib/brick_ftp/types/behavior.rb +27 -0
- data/lib/brick_ftp/types/bundle.rb +34 -0
- data/lib/brick_ftp/types/bundle_content.rb +25 -0
- data/lib/brick_ftp/types/bundle_zip.rb +19 -0
- data/lib/brick_ftp/types/file.rb +45 -0
- data/lib/brick_ftp/types/file_in_bundle.rb +25 -0
- data/lib/brick_ftp/types/folder_contents_count.rb +24 -0
- data/lib/brick_ftp/types/group.rb +31 -0
- data/lib/brick_ftp/types/group_membership.rb +27 -0
- data/lib/brick_ftp/types/history.rb +43 -0
- data/lib/brick_ftp/types/notification.rb +31 -0
- data/lib/brick_ftp/types/permission.rb +35 -0
- data/lib/brick_ftp/types/site_usage.rb +23 -0
- data/lib/brick_ftp/types/upload.rb +45 -0
- data/lib/brick_ftp/types/user.rb +79 -0
- data/lib/brick_ftp/types/user_api_key.rb +33 -0
- data/lib/brick_ftp/types/user_public_key.rb +28 -0
- data/lib/brick_ftp/utils.rb +2 -0
- data/lib/brick_ftp/utils/chunk_io.rb +5 -4
- data/lib/brick_ftp/version.rb +3 -1
- metadata +123 -86
- data/lib/brick_ftp/api.rb +0 -9
- data/lib/brick_ftp/api/authentication.rb +0 -28
- data/lib/brick_ftp/api/authentication/session.rb +0 -25
- data/lib/brick_ftp/api/base.rb +0 -119
- data/lib/brick_ftp/api/behavior.rb +0 -19
- data/lib/brick_ftp/api/bundle.rb +0 -17
- data/lib/brick_ftp/api/bundle_content.rb +0 -18
- data/lib/brick_ftp/api/bundle_download.rb +0 -18
- data/lib/brick_ftp/api/file.rb +0 -20
- data/lib/brick_ftp/api/file_operation.rb +0 -6
- data/lib/brick_ftp/api/file_operation/copy.rb +0 -10
- data/lib/brick_ftp/api/file_operation/move.rb +0 -10
- data/lib/brick_ftp/api/file_operation/upload.rb +0 -66
- data/lib/brick_ftp/api/file_operation/uploading_result.rb +0 -22
- data/lib/brick_ftp/api/file_operation/uploading_session.rb +0 -95
- data/lib/brick_ftp/api/folder.rb +0 -22
- data/lib/brick_ftp/api/folder_behavior.rb +0 -12
- data/lib/brick_ftp/api/group.rb +0 -16
- data/lib/brick_ftp/api/history.rb +0 -6
- data/lib/brick_ftp/api/history/file.rb +0 -23
- data/lib/brick_ftp/api/history/folder.rb +0 -23
- data/lib/brick_ftp/api/history/login.rb +0 -23
- data/lib/brick_ftp/api/history/site.rb +0 -23
- data/lib/brick_ftp/api/history/user.rb +0 -23
- data/lib/brick_ftp/api/notification.rb +0 -14
- data/lib/brick_ftp/api/permission.rb +0 -17
- data/lib/brick_ftp/api/public_key.rb +0 -15
- data/lib/brick_ftp/api/site_usage.rb +0 -21
- data/lib/brick_ftp/api/user.rb +0 -36
- data/lib/brick_ftp/api_component.rb +0 -81
- data/lib/brick_ftp/api_definition.rb +0 -65
- data/lib/brick_ftp/cli.rb +0 -7
- data/lib/brick_ftp/cli/config.rb +0 -20
- data/lib/brick_ftp/cli/main.rb +0 -26
- data/lib/brick_ftp/cli/site.rb +0 -10
- data/lib/brick_ftp/configuration.rb +0 -121
- data/lib/brick_ftp/http_client.rb +0 -130
- data/lib/brick_ftp/log_formatter.rb +0 -15
- data/lib/brick_ftp/webhook.rb +0 -4
- data/lib/brick_ftp/webhook/request.rb +0 -28
data/lib/brick_ftp/cli.rb
DELETED
data/lib/brick_ftp/cli/config.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
module BrickFTP
|
2
|
-
module CLI
|
3
|
-
class Config < Thor
|
4
|
-
desc 'get NAME', 'Show specified configuration.'
|
5
|
-
def get(name)
|
6
|
-
abort 'No such configuration.' unless BrickFTP.config.respond_to?(name)
|
7
|
-
|
8
|
-
puts BrickFTP.config.send(name)
|
9
|
-
end
|
10
|
-
|
11
|
-
desc 'set NAME VALUE', 'Set configuration value.'
|
12
|
-
def set(name, value)
|
13
|
-
abort 'No such configuration.' unless BrickFTP.config.respond_to?("#{name}=")
|
14
|
-
|
15
|
-
BrickFTP.config.send("#{name}=", value)
|
16
|
-
BrickFTP.config.save!
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/brick_ftp/cli/main.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module BrickFTP
|
2
|
-
module CLI
|
3
|
-
class Main < Thor
|
4
|
-
class_option :profile,
|
5
|
-
desc: 'Configuration profile.',
|
6
|
-
default: 'global',
|
7
|
-
type: :string
|
8
|
-
|
9
|
-
class_option :config,
|
10
|
-
desc: 'Path for configuration file.',
|
11
|
-
default: BrickFTP::Configuration::CONFIG_FILE_PATH,
|
12
|
-
type: :string
|
13
|
-
|
14
|
-
def initialize(*args)
|
15
|
-
super
|
16
|
-
BrickFTP.config = BrickFTP::Configuration.new(profile: options[:profile], config_file_path: options[:config])
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'config COMMAND', 'Manage configuration.'
|
20
|
-
subcommand 'config', BrickFTP::CLI::Config
|
21
|
-
|
22
|
-
desc 'site COMMAND', 'Manage site.'
|
23
|
-
subcommand 'site', BrickFTP::CLI::Site
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/brick_ftp/cli/site.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'logger'
|
2
|
-
require 'inifile'
|
3
|
-
|
4
|
-
module BrickFTP
|
5
|
-
class Configuration
|
6
|
-
# Name of configuration profile.
|
7
|
-
# @return [String] profile
|
8
|
-
attr_reader :profile
|
9
|
-
# Path for configuration file.
|
10
|
-
# @return [String] path
|
11
|
-
attr_reader :config_file_path
|
12
|
-
# Subdomain of API endpoint. If not specified, get value from enviroment variable `BRICK_FTP_SUBDOMAIN`.
|
13
|
-
# @return [String] subdomain
|
14
|
-
attr_accessor :subdomain
|
15
|
-
# Access key of API. If not specified, get value from enviroment variable `BRICK_FTP_API_KEY`.
|
16
|
-
# @return [String] API access key
|
17
|
-
attr_accessor :api_key
|
18
|
-
# Authentication session for cookie auth.
|
19
|
-
# @return [BrickFTP::API::Authentication::Session] authentication session object.
|
20
|
-
attr_accessor :session
|
21
|
-
# Logger.
|
22
|
-
# @return [Logger] logger
|
23
|
-
attr_accessor :logger
|
24
|
-
# Log level
|
25
|
-
# @return [Integer]
|
26
|
-
attr_reader :log_level
|
27
|
-
# Log formatter
|
28
|
-
# @return [Logger::Formatter]
|
29
|
-
attr_reader :log_formatter
|
30
|
-
# Open timeout
|
31
|
-
# @return [Integer]
|
32
|
-
attr_accessor :open_timeout
|
33
|
-
# Read timeout
|
34
|
-
# @return [Integer]
|
35
|
-
attr_accessor :read_timeout
|
36
|
-
|
37
|
-
DEFAULT_OPEN_TIMEOUT = 10
|
38
|
-
DEFAULT_READ_TIMEOUT = 30
|
39
|
-
|
40
|
-
DEFAULT_PROFILE = 'global'.freeze
|
41
|
-
# Name of storable configurations. (TODO: log_path, log_level, log_formatter)
|
42
|
-
STORABLE_CONFIGURATION_KEYS = %w[subdomain api_key open_timeout read_timeout].freeze
|
43
|
-
|
44
|
-
STORABLE_CONFIGURATION_KEYS.each do |name|
|
45
|
-
define_method("#{name}=") do |value|
|
46
|
-
dirty_attributes.add(name)
|
47
|
-
instance_variable_set(:"@#{name}", value)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.default_config_file_path
|
52
|
-
File.expand_path('~/.brick_ftp/config')
|
53
|
-
rescue ArgumentError
|
54
|
-
# couldn't find login name -- expanding `~'
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
CONFIG_FILE_PATH = default_config_file_path
|
58
|
-
|
59
|
-
def initialize(profile: DEFAULT_PROFILE, config_file_path: CONFIG_FILE_PATH)
|
60
|
-
@profile = profile
|
61
|
-
@config_file_path = config_file_path
|
62
|
-
load_config_file(config_file_path)
|
63
|
-
|
64
|
-
self.subdomain = ENV.fetch('BRICK_FTP_SUBDOMAIN', inifile[profile]['subdomain'])
|
65
|
-
self.api_key = ENV.fetch('BRICK_FTP_API_KEY', inifile[profile]['api_key'])
|
66
|
-
self.session = nil
|
67
|
-
self.open_timeout = (inifile[profile]['open_timeout'] || DEFAULT_OPEN_TIMEOUT).to_i
|
68
|
-
self.read_timeout = (inifile[profile]['read_timeout'] || DEFAULT_READ_TIMEOUT).to_i
|
69
|
-
self.logger = Logger.new(STDOUT)
|
70
|
-
self.log_level = Logger::WARN
|
71
|
-
self.log_formatter = Logger::Formatter.new
|
72
|
-
logger.level = log_level
|
73
|
-
|
74
|
-
dirty_attributes.clear
|
75
|
-
end
|
76
|
-
|
77
|
-
# Host name of API endpoint.
|
78
|
-
# @return [String] API host
|
79
|
-
def api_host
|
80
|
-
"#{subdomain}.brickftp.com"
|
81
|
-
end
|
82
|
-
|
83
|
-
# Set log level to logger object.
|
84
|
-
# @param level [Integer] log level.
|
85
|
-
def log_level=(level)
|
86
|
-
@log_level = level
|
87
|
-
logger.level = @log_level
|
88
|
-
end
|
89
|
-
|
90
|
-
# Set log formatter to logger object.
|
91
|
-
# @param formatter [Logger::Formatter]
|
92
|
-
def log_formatter=(formatter)
|
93
|
-
@log_formatter = formatter
|
94
|
-
logger.formatter = @log_formatter
|
95
|
-
end
|
96
|
-
|
97
|
-
def save!
|
98
|
-
dirty_attributes.each do |key|
|
99
|
-
inifile[profile][key] = send(key)
|
100
|
-
end
|
101
|
-
FileUtils.mkdir_p(File.dirname(inifile.filename)) unless File.exist?(File.dirname(inifile.filename))
|
102
|
-
inifile.save
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
|
107
|
-
attr_reader :inifile
|
108
|
-
|
109
|
-
def load_config_file(config_file_path)
|
110
|
-
@inifile = if config_file_path && File.exist?(config_file_path)
|
111
|
-
IniFile.load(config_file_path, encoding: 'UTF-8')
|
112
|
-
else
|
113
|
-
IniFile.new(filename: config_file_path, encoding: 'UTF-8')
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def dirty_attributes
|
118
|
-
@dirty_attributes ||= Set.new
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'net/https'
|
2
|
-
require 'json'
|
3
|
-
require 'cgi'
|
4
|
-
|
5
|
-
module BrickFTP
|
6
|
-
class HTTPClient
|
7
|
-
class Error < StandardError
|
8
|
-
def initialize(response)
|
9
|
-
begin
|
10
|
-
error = JSON.parse(response.body)
|
11
|
-
rescue StandardError
|
12
|
-
error = { 'http-code' => response.code, 'error' => "#{response.message}, #{response.body}" }
|
13
|
-
end
|
14
|
-
|
15
|
-
case
|
16
|
-
when !error.is_a?(Hash)
|
17
|
-
super "#{response.code} #{response.message}"
|
18
|
-
when error.key?('http-code')
|
19
|
-
super "#{error['http-code']}: #{error['error']}"
|
20
|
-
when error.key?('errors')
|
21
|
-
super error['errors'].join('. ')
|
22
|
-
else
|
23
|
-
super 'unknown error.'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
USER_AGENT = 'BrickFTP Client/0.1 (https://github.com/koshigoe/brick_ftp)'.freeze
|
29
|
-
|
30
|
-
def initialize(host = nil)
|
31
|
-
@host = host || BrickFTP.config.api_host
|
32
|
-
@conn = Net::HTTP.new(@host, 443)
|
33
|
-
@conn.use_ssl = true
|
34
|
-
@conn.open_timeout = BrickFTP.config.open_timeout
|
35
|
-
@conn.read_timeout = BrickFTP.config.read_timeout
|
36
|
-
end
|
37
|
-
|
38
|
-
def get(path, params: {}, headers: {})
|
39
|
-
query = params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
|
40
|
-
path = "#{path}?#{query}" unless query.empty?
|
41
|
-
|
42
|
-
case res = request(:get, path, headers: headers)
|
43
|
-
when Net::HTTPSuccess
|
44
|
-
res.body.nil? || res.body.empty? ? {} : JSON.parse(res.body)
|
45
|
-
else
|
46
|
-
# TODO: redirect
|
47
|
-
raise Error, res
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def post(path, params: {}, headers: {})
|
52
|
-
case res = request(:post, path, params: params, headers: headers)
|
53
|
-
when Net::HTTPSuccess, Net::HTTPCreated
|
54
|
-
res.body.nil? || res.body.empty? ? {} : JSON.parse(res.body)
|
55
|
-
else
|
56
|
-
# TODO: redirect
|
57
|
-
raise Error, res
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def put(path, params: {}, headers: {})
|
62
|
-
case res = request(:put, path, params: params, headers: headers)
|
63
|
-
when Net::HTTPSuccess
|
64
|
-
res.body.nil? || res.body.empty? ? {} : JSON.parse(res.body)
|
65
|
-
else
|
66
|
-
# TODO: redirect
|
67
|
-
raise Error, res
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def delete(path, params: {}, headers: {})
|
72
|
-
case res = request(:delete, path, params: params, headers: headers)
|
73
|
-
when Net::HTTPSuccess
|
74
|
-
true
|
75
|
-
else
|
76
|
-
# TODO: redirect
|
77
|
-
raise Error, res
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
84
|
-
def request(method, path, params: {}, headers: {})
|
85
|
-
req = Net::HTTP.const_get(method.to_s.capitalize).new(path, headers)
|
86
|
-
req['User-Agent'] = USER_AGENT
|
87
|
-
|
88
|
-
if @host == BrickFTP.config.api_host
|
89
|
-
req['Content-Type'] = 'application/json'
|
90
|
-
case
|
91
|
-
when BrickFTP.config.session
|
92
|
-
req['Cookie'] = BrickFTP::API::Authentication.cookie(BrickFTP.config.session).to_s
|
93
|
-
when BrickFTP.config.api_key
|
94
|
-
req.basic_auth(BrickFTP.config.api_key, 'x')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
case
|
99
|
-
when params.is_a?(Hash)
|
100
|
-
req.body = params.to_json unless params.empty?
|
101
|
-
when params.is_a?(IO) || params.is_a?(StringIO)
|
102
|
-
req.body_stream = params
|
103
|
-
req['Content-Length'] = params.size
|
104
|
-
end
|
105
|
-
|
106
|
-
start = Time.now
|
107
|
-
begin
|
108
|
-
logger.debug format('Request headers: %{headers}', headers: req.each_capitalized.map { |k, v| "#{k}: #{v}" })
|
109
|
-
logger.debug format('Request body: %{body}', body: req.body)
|
110
|
-
@conn.request(req).tap do |res|
|
111
|
-
logger.debug format('Response headers: %{headers}', headers: res.each_capitalized.map { |k, v| "#{k}: #{v}" })
|
112
|
-
logger.debug format('Response body: %{body}', body: res.body)
|
113
|
-
end
|
114
|
-
ensure
|
115
|
-
message = format(
|
116
|
-
'Complete %{method} %{path} (%{time} ms)',
|
117
|
-
method: method.upcase,
|
118
|
-
path: path,
|
119
|
-
time: (Time.now - start) * 1000
|
120
|
-
)
|
121
|
-
logger.info message
|
122
|
-
end
|
123
|
-
end
|
124
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
125
|
-
|
126
|
-
def logger
|
127
|
-
BrickFTP.logger
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module BrickFTP
|
2
|
-
class LogFormatter < Logger::Formatter
|
3
|
-
FORMAT = "severity:%{severity}\tpid:%{pid}\ttime:%{time}\tmessage:%{message}\n".freeze
|
4
|
-
|
5
|
-
def call(severity, time, _program_name, message)
|
6
|
-
params = {
|
7
|
-
severity: severity,
|
8
|
-
pid: Process.pid,
|
9
|
-
time: format_datetime(time),
|
10
|
-
message: msg2str(message),
|
11
|
-
}
|
12
|
-
FORMAT % params
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/brick_ftp/webhook.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
|
-
module BrickFTP
|
4
|
-
module Webhook
|
5
|
-
class Request
|
6
|
-
attr_reader :action, :interface, :path, :destination, :at, :username, :type
|
7
|
-
|
8
|
-
def self.from_query_string(query_string)
|
9
|
-
params = query_string.split('&').each_with_object({}) do |pair, res|
|
10
|
-
key, value = pair.split('=').map { |x| CGI.unescape(x) }
|
11
|
-
res[key.to_sym] = value
|
12
|
-
end
|
13
|
-
|
14
|
-
new(params)
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(action: nil, interface: nil, path: nil, destination: nil, at: nil, username: nil, type: nil)
|
18
|
-
@action = action
|
19
|
-
@interface = interface
|
20
|
-
@path = path
|
21
|
-
@destination = destination
|
22
|
-
@at = at
|
23
|
-
@username = username
|
24
|
-
@type = type
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|