rest-ftp-daemon 0.242.1 → 0.242.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -8
- data/Gemfile.lock +4 -1
- data/Rakefile +4 -4
- data/bin/rest-ftp-daemon +19 -20
- data/config.ru +5 -2
- data/lib/rest-ftp-daemon/api/dashboard.rb +10 -6
- data/lib/rest-ftp-daemon/api/jobs.rb +11 -11
- data/lib/rest-ftp-daemon/api/root.rb +13 -14
- data/lib/rest-ftp-daemon/constants.rb +4 -5
- data/lib/rest-ftp-daemon/helpers.rb +4 -4
- data/lib/rest-ftp-daemon/job.rb +11 -15
- data/lib/rest-ftp-daemon/job_queue.rb +3 -1
- data/lib/rest-ftp-daemon/logger.rb +13 -13
- data/lib/rest-ftp-daemon/logger_helper.rb +1 -1
- data/lib/rest-ftp-daemon/logger_pool.rb +3 -1
- data/lib/rest-ftp-daemon/notification.rb +2 -0
- data/lib/rest-ftp-daemon/patch_haml.rb +10 -0
- data/lib/rest-ftp-daemon/path.rb +5 -2
- data/lib/rest-ftp-daemon/remote.rb +2 -4
- data/lib/rest-ftp-daemon/remote_ftp.rb +4 -6
- data/lib/rest-ftp-daemon/remote_sftp.rb +3 -4
- data/lib/rest-ftp-daemon/worker.rb +2 -2
- data/lib/rest-ftp-daemon/worker_conchita.rb +2 -0
- data/lib/rest-ftp-daemon/worker_job.rb +2 -0
- data/lib/rest-ftp-daemon/worker_pool.rb +6 -4
- data/lib/rest-ftp-daemon.rb +5 -1
- data/rest-ftp-daemon.gemspec +6 -8
- data/spec/rest-ftp-daemon/features/dashboard_spec.rb +3 -3
- data/spec/rest-ftp-daemon/features/jobs_spec.rb +7 -7
- data/spec/rest-ftp-daemon/features/routes_spec.rb +1 -1
- data/spec/rest-ftp-daemon/features/status_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- data/spec/support/request_helpers.rb +6 -6
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fed5f04a6d1a2f75378437123d1ee8d7d650c3d3
|
4
|
+
data.tar.gz: c0232b87d7c6497059ec52e539f63955ec6d78b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ab309003321a4e37d43ac8a02146d7640c92a745298565c5e8e751c8017c3eeb0f9c9db05a29b5d6cab8c2969535b56baee68a43498fa8f58970da7f6c2ca3
|
7
|
+
data.tar.gz: 4ea60d8be7aa292c831303fa75fedb855b039a2a0cf7cf2e47addf7df0828508cac781c286496dea53636e4201c680126f0af562667e697fcb48356ec66bd4fc
|
data/.rubocop.yml
CHANGED
@@ -27,6 +27,7 @@ AllCops:
|
|
27
27
|
Exclude:
|
28
28
|
- 'vendor/**/*'
|
29
29
|
- 'DOC/**/*'
|
30
|
+
- '**/actors/*'
|
30
31
|
# By default, the rails cops are not run. Override in project or home
|
31
32
|
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
32
33
|
RunRailsCops: false
|
@@ -380,6 +381,7 @@ Style/FileName:
|
|
380
381
|
# File names listed in AllCops:Include are excluded by default. Add extra
|
381
382
|
# excludes here.
|
382
383
|
Exclude: []
|
384
|
+
Enabled: false
|
383
385
|
|
384
386
|
Style/FirstParameterIndentation:
|
385
387
|
EnforcedStyle: special_for_inner_method_call_in_parentheses
|
@@ -413,7 +415,7 @@ Style/FormatString:
|
|
413
415
|
|
414
416
|
# Built-in global variables are allowed by default.
|
415
417
|
Style/GlobalVars:
|
416
|
-
AllowedVariables: []
|
418
|
+
AllowedVariables: ["$queue", "$pool"]
|
417
419
|
|
418
420
|
# `MinBodyLength` defines the number of lines of the a body of an if / unless
|
419
421
|
# needs to have to trigger this cop
|
@@ -490,7 +492,7 @@ Style/NonNilCheck:
|
|
490
492
|
IncludeSemanticChanges: false
|
491
493
|
|
492
494
|
Style/MethodDefParentheses:
|
493
|
-
EnforcedStyle:
|
495
|
+
EnforcedStyle: require_no_parentheses
|
494
496
|
SupportedStyles:
|
495
497
|
- require_parentheses
|
496
498
|
- require_no_parentheses
|
@@ -660,7 +662,7 @@ Style/TrailingComma:
|
|
660
662
|
# last item of a list, but only for lists where each item is on its own line.
|
661
663
|
# If EnforcedStyleForMultiline is consistent_comma, the cop requires a comma
|
662
664
|
# after the last item of a list, for all lists.
|
663
|
-
EnforcedStyleForMultiline:
|
665
|
+
EnforcedStyleForMultiline: comma
|
664
666
|
SupportedStyles:
|
665
667
|
- comma
|
666
668
|
- consistent_comma
|
@@ -715,7 +717,7 @@ Style/VariableName:
|
|
715
717
|
- camelCase
|
716
718
|
|
717
719
|
Style/WhileUntilModifier:
|
718
|
-
MaxLineLength:
|
720
|
+
MaxLineLength: 120
|
719
721
|
|
720
722
|
Style/WordArray:
|
721
723
|
MinSize: 0
|
@@ -742,10 +744,10 @@ Metrics/ModuleLength:
|
|
742
744
|
|
743
745
|
# Avoid complex methods.
|
744
746
|
Metrics/CyclomaticComplexity:
|
745
|
-
Max:
|
747
|
+
Max: 10
|
746
748
|
|
747
749
|
Metrics/LineLength:
|
748
|
-
Max:
|
750
|
+
Max: 120
|
749
751
|
# To make it possible to copy or click on URIs in the code, we allow lines
|
750
752
|
# contaning a URI to be longer than Max.
|
751
753
|
AllowURI: true
|
@@ -755,14 +757,14 @@ Metrics/LineLength:
|
|
755
757
|
|
756
758
|
Metrics/MethodLength:
|
757
759
|
CountComments: false # count full line comments?
|
758
|
-
Max:
|
760
|
+
Max: 20
|
759
761
|
|
760
762
|
Metrics/ParameterLists:
|
761
763
|
Max: 5
|
762
764
|
CountKeywordArgs: true
|
763
765
|
|
764
766
|
Metrics/PerceivedComplexity:
|
765
|
-
Max:
|
767
|
+
Max: 10
|
766
768
|
|
767
769
|
##################### Lint ##################################
|
768
770
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rest-ftp-daemon (0.242.
|
4
|
+
rest-ftp-daemon (0.242.2)
|
5
5
|
double-bag-ftps
|
6
6
|
facter
|
7
7
|
get_process_mem
|
@@ -152,3 +152,6 @@ DEPENDENCIES
|
|
152
152
|
rest-ftp-daemon!
|
153
153
|
rspec (~> 3.1)
|
154
154
|
rubocop (~> 0.32.0)
|
155
|
+
|
156
|
+
BUNDLED WITH
|
157
|
+
1.10.6
|
data/Rakefile
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
require "bundler/gem_tasks"
|
3
3
|
require "rubygems"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "rspec/core/rake_task"
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
8
|
# Run specs by default
|
9
|
-
desc
|
9
|
+
desc "Run all tests"
|
10
10
|
|
11
|
-
require
|
11
|
+
require "rubocop/rake_task"
|
12
12
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
13
13
|
task.fail_on_error = false
|
14
14
|
end
|
15
15
|
|
16
|
-
task :
|
16
|
+
task default: [:spec, :rubocop]
|
data/bin/rest-ftp-daemon
CHANGED
@@ -23,17 +23,17 @@ puts
|
|
23
23
|
# Detect options from ARGV
|
24
24
|
options = {}
|
25
25
|
parser = OptionParser.new do |opts|
|
26
|
-
opts.banner = "Usage: #{File.basename $
|
27
|
-
opts.on("-c", "--config CONFIGFILE")
|
28
|
-
opts.on("-e", "--environment ENV")
|
29
|
-
opts.on("", "--dev")
|
30
|
-
opts.on("-p", "--port PORT", "use PORT")
|
31
|
-
opts.on("-w", "--workers COUNT", "Use COUNT worker threads")
|
32
|
-
opts.on("-d", "--daemonize", "Run daemonized in the background")
|
33
|
-
opts.on("-f", "--foreground", "Run in the foreground")
|
34
|
-
opts.on("-P", "--pid FILE", "File to store PID")
|
35
|
-
opts.on("-u", "--user NAME", "User to run daemon as (use with -g)")
|
36
|
-
opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)"){ |group| options["group"] = group }
|
26
|
+
opts.banner = "Usage: #{File.basename $PROGRAM_NAME} [options] start|stop"
|
27
|
+
opts.on("-c", "--config CONFIGFILE") { |config| APP_CONF = config }
|
28
|
+
opts.on("-e", "--environment ENV") { |env| APP_ENV = env }
|
29
|
+
opts.on("", "--dev") { APP_ENV = "development" }
|
30
|
+
opts.on("-p", "--port PORT", "use PORT") { |port| options["port"] = port.to_i }
|
31
|
+
opts.on("-w", "--workers COUNT", "Use COUNT worker threads") { |count| options["workers"] = count.to_i }
|
32
|
+
opts.on("-d", "--daemonize", "Run daemonized in the background") { options["daemonize"] = true }
|
33
|
+
opts.on("-f", "--foreground", "Run in the foreground") { options["daemonize"] = false }
|
34
|
+
opts.on("-P", "--pid FILE", "File to store PID") { |file| options["pidfile"] = file }
|
35
|
+
opts.on("-u", "--user NAME", "User to run daemon as (use with -g)") { |user| options["user"] = user }
|
36
|
+
opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)") { |group| options["group"] = group }
|
37
37
|
|
38
38
|
opts.separator ""
|
39
39
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -41,10 +41,9 @@ parser = OptionParser.new do |opts|
|
|
41
41
|
puts TAIL_MESSAGE unless File.exist?(DEFAULT_CONFIG_PATH)
|
42
42
|
exit
|
43
43
|
end
|
44
|
-
opts.on_tail("-v", "--version", "Show version (#{APP_VER})") { puts
|
44
|
+
opts.on_tail("-v", "--version", "Show version (#{APP_VER})") { puts(APP_VER) && exit }
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
47
|
# Parse options and check compliance
|
49
48
|
begin
|
50
49
|
parser.order!(ARGV)
|
@@ -119,9 +118,9 @@ puts "Daemonize \t #{Settings.daemonize ? "YES" : "no (PID: #{Process.pid})"}
|
|
119
118
|
puts "Host \t #{Settings.host}"
|
120
119
|
puts "Namespace \t #{Settings.namespace}"
|
121
120
|
puts "Network port \t #{Settings.port}"
|
122
|
-
puts "User:group \t #{Settings.user}:#{Settings.group}" if
|
121
|
+
puts "User:group \t #{Settings.user}:#{Settings.group}" if Settings.user || Settings.group
|
123
122
|
puts "Newrelic \t #{Settings.newrelic_enabled? ? Settings.at(:newrelic, :licence) : "no"}"
|
124
|
-
puts "Started at \t #{APP_STARTED
|
123
|
+
puts "Started at \t #{APP_STARTED}"
|
125
124
|
# puts Settings.dump
|
126
125
|
puts
|
127
126
|
puts "--- Thin ARGV"
|
@@ -132,7 +131,7 @@ puts
|
|
132
131
|
# Start Thin with this rackup configuration, changing to app_root first
|
133
132
|
begin
|
134
133
|
Dir.chdir app_root
|
135
|
-
|
134
|
+
Thin::Runner.new(argv.flatten).run!
|
136
135
|
rescue RuntimeError => e
|
137
136
|
puts "FAILED: RuntimeError: #{e.message}"
|
138
137
|
rescue Thin::PidFileExist
|
@@ -144,8 +143,8 @@ rescue Errno::ENOENT => e
|
|
144
143
|
rescue SystemExit
|
145
144
|
# Leave some time for the daemon to launch
|
146
145
|
pidfile = Settings.pidfile
|
147
|
-
|
148
|
-
|
146
|
+
print "Waiting for pidfile"
|
147
|
+
until File.file?(pidfile) do
|
149
148
|
print "."
|
150
149
|
sleep 0.25
|
151
150
|
end
|
@@ -157,9 +156,9 @@ rescue SystemExit
|
|
157
156
|
Process.kill(0, pid)
|
158
157
|
puts "Process ##{pid} is running"
|
159
158
|
rescue Errno::EPERM # changed uid
|
160
|
-
puts "No permission to query process ##{pid}!"
|
159
|
+
puts "No permission to query process ##{pid}!"
|
161
160
|
rescue Errno::ESRCH
|
162
|
-
puts "Process ##{pid} is NOT running."
|
161
|
+
puts "Process ##{pid} is NOT running." # or zombied
|
163
162
|
rescue
|
164
163
|
puts "Unable to determine status for ##{pid}: #{$!}"
|
165
164
|
end
|
data/config.ru
CHANGED
@@ -20,7 +20,7 @@ end
|
|
20
20
|
GC::Profiler.enable if Settings.newrelic_enabled?
|
21
21
|
|
22
22
|
# Serve static assets
|
23
|
-
use Rack::Static, :
|
23
|
+
use Rack::Static, urls: ["/css", "/js", "/images"], root: "#{APP_LIBS}/static/"
|
24
24
|
|
25
25
|
# Rack reloader and mini-profiler
|
26
26
|
unless Settings.namespace == "production"
|
@@ -28,6 +28,9 @@ unless Settings.namespace == "production"
|
|
28
28
|
# use Rack::MiniProfiler
|
29
29
|
end
|
30
30
|
|
31
|
+
# Set up encodings
|
32
|
+
Encoding.default_internal = "utf-8"
|
33
|
+
Encoding.default_external = "utf-8"
|
34
|
+
|
31
35
|
# Launch the main daemon
|
32
36
|
run RestFtpDaemon::API::Root
|
33
|
-
#run Rack::Cascade.new [RestFtpDaemon::API::Root]
|
@@ -5,14 +5,17 @@ require "facter"
|
|
5
5
|
|
6
6
|
module RestFtpDaemon
|
7
7
|
module API
|
8
|
+
|
9
|
+
# Offers an HTML dashboard through the Grape API (hum...)
|
8
10
|
class Dashbaord < Grape::API
|
9
11
|
|
10
|
-
|
12
|
+
### HELPERS
|
11
13
|
|
12
14
|
helpers do
|
13
15
|
def logger
|
14
16
|
Root.logger
|
15
17
|
end
|
18
|
+
|
16
19
|
def render name, values={}
|
17
20
|
template = File.read("#{APP_LIBS}/views/#{name}.haml")
|
18
21
|
haml_engine = Haml::Engine.new(template)
|
@@ -21,13 +24,14 @@ module RestFtpDaemon
|
|
21
24
|
end
|
22
25
|
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
27
|
+
### Common request logging
|
28
|
+
|
29
|
+
before do
|
30
|
+
log_info "HTTP #{request.request_method} #{request.fullpath}", params
|
31
|
+
end
|
28
32
|
|
29
33
|
|
30
|
-
|
34
|
+
### DASHBOARD
|
31
35
|
|
32
36
|
get "/" do
|
33
37
|
# Initialize Facter
|
@@ -4,7 +4,7 @@ module RestFtpDaemon
|
|
4
4
|
module API
|
5
5
|
class Jobs < Grape::API
|
6
6
|
|
7
|
-
|
7
|
+
### HELPERS
|
8
8
|
|
9
9
|
helpers do
|
10
10
|
def logger
|
@@ -13,13 +13,13 @@ module RestFtpDaemon
|
|
13
13
|
end
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
### Common request logging
|
17
|
+
before do
|
18
|
+
log_info "HTTP #{request.request_method} #{request.fullpath}", params
|
19
|
+
end
|
20
20
|
|
21
21
|
|
22
|
-
|
22
|
+
### READ ONE JOB
|
23
23
|
|
24
24
|
desc "Read job with ID"
|
25
25
|
params do
|
@@ -34,11 +34,11 @@ module RestFtpDaemon
|
|
34
34
|
|
35
35
|
rescue RestFtpDaemon::JobNotFound => exception
|
36
36
|
log_error "JobNotFound: #{exception.message}"
|
37
|
-
error!({error: :api_job_not_found, message: exception.message}, 404)
|
37
|
+
error!({ error: :api_job_not_found, message: exception.message }, 404)
|
38
38
|
|
39
39
|
rescue StandardError => exception
|
40
40
|
log_error "Exception: #{exception.message}"
|
41
|
-
error!({error: :api_exception, message: exception.message}, 500)
|
41
|
+
error!({ error: :api_exception, message: exception.message }, 500)
|
42
42
|
|
43
43
|
else
|
44
44
|
status 200
|
@@ -48,7 +48,7 @@ module RestFtpDaemon
|
|
48
48
|
end
|
49
49
|
|
50
50
|
|
51
|
-
|
51
|
+
### READ ALL JOBS
|
52
52
|
|
53
53
|
desc "List all Jobs"
|
54
54
|
get "/" do
|
@@ -58,7 +58,7 @@ module RestFtpDaemon
|
|
58
58
|
|
59
59
|
rescue StandardError => exception
|
60
60
|
log_error "Exception: #{exception.message}"
|
61
|
-
error!({error: :api_exception, message: exception.message}, 500)
|
61
|
+
error!({ error: :api_exception, message: exception.message }, 500)
|
62
62
|
|
63
63
|
else
|
64
64
|
status 200
|
@@ -68,7 +68,7 @@ module RestFtpDaemon
|
|
68
68
|
end
|
69
69
|
|
70
70
|
|
71
|
-
|
71
|
+
### CREATE A JOB
|
72
72
|
|
73
73
|
desc "Create a new job"
|
74
74
|
params do
|
@@ -5,11 +5,9 @@ module RestFtpDaemon
|
|
5
5
|
module API
|
6
6
|
class Root < Grape::API
|
7
7
|
|
8
|
-
|
9
|
-
####### CLASS CONFIG
|
8
|
+
### CLASS CONFIG
|
10
9
|
|
11
10
|
helpers RestFtpDaemon::LoggerHelper
|
12
|
-
|
13
11
|
logger RestFtpDaemon::LoggerPool.instance.get :api
|
14
12
|
|
15
13
|
do_not_route_head!
|
@@ -21,7 +19,7 @@ module RestFtpDaemon
|
|
21
19
|
mount RestFtpDaemon::API::Dashbaord => "/"
|
22
20
|
|
23
21
|
|
24
|
-
|
22
|
+
### INITIALIZATION
|
25
23
|
|
26
24
|
def initialize
|
27
25
|
# Call daddy
|
@@ -33,7 +31,7 @@ module RestFtpDaemon
|
|
33
31
|
end
|
34
32
|
|
35
33
|
|
36
|
-
|
34
|
+
### HELPERS
|
37
35
|
|
38
36
|
helpers do
|
39
37
|
def logger
|
@@ -42,13 +40,14 @@ module RestFtpDaemon
|
|
42
40
|
end
|
43
41
|
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
### Common request logging
|
44
|
+
|
45
|
+
before do
|
46
|
+
log_info "HTTP #{request.request_method} #{request.fullpath}", params
|
47
|
+
end
|
49
48
|
|
50
49
|
|
51
|
-
|
50
|
+
### SHOW ROUTES
|
52
51
|
|
53
52
|
desc "Show application routes"
|
54
53
|
get "/routes" do
|
@@ -57,7 +56,7 @@ module RestFtpDaemon
|
|
57
56
|
end
|
58
57
|
|
59
58
|
|
60
|
-
|
59
|
+
### SHOW STATUS
|
61
60
|
|
62
61
|
desc "Show daemon status"
|
63
62
|
get "/status" do
|
@@ -74,12 +73,12 @@ module RestFtpDaemon
|
|
74
73
|
status: $queue.counts_by_status,
|
75
74
|
workers: $pool.worker_variables,
|
76
75
|
jobs_count: $queue.jobs_count,
|
77
|
-
jobs_queued: $queue.queued_ids
|
76
|
+
jobs_queued: $queue.queued_ids,
|
78
77
|
}
|
79
78
|
end
|
80
79
|
|
81
80
|
|
82
|
-
|
81
|
+
### SHOW CONFIG
|
83
82
|
|
84
83
|
desc "Show daemon config"
|
85
84
|
get "/config" do
|
@@ -88,7 +87,7 @@ module RestFtpDaemon
|
|
88
87
|
end
|
89
88
|
|
90
89
|
|
91
|
-
|
90
|
+
### RELOAD CONFIG
|
92
91
|
|
93
92
|
desc "Reload daemon config"
|
94
93
|
post "/config/reload" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Terrific constants
|
2
2
|
APP_NAME = "rest-ftp-daemon"
|
3
3
|
APP_NICK = "rftpd"
|
4
|
-
APP_VER = "0.242.
|
4
|
+
APP_VER = "0.242.2"
|
5
5
|
|
6
6
|
# Provide default config file information
|
7
7
|
APP_LIB = File.expand_path File.dirname(__FILE__)
|
@@ -10,7 +10,6 @@ APP_ROOT = File.expand_path(File.dirname(__FILE__) + "/../../")
|
|
10
10
|
DEFAULT_CONFIG_PATH = File.expand_path "/etc/#{APP_NAME}.yml"
|
11
11
|
SAMPLE_CONFIG_FILE = File.expand_path(File.join File.dirname(__FILE__), "/../../rest-ftp-daemon.yml.sample")
|
12
12
|
|
13
|
-
#SAMPLE_CONFIG_FILE = File.expand_path("#{app_root}/#{APP_NAME}.yml.sample")
|
14
13
|
TAIL_MESSAGE = <<EOD
|
15
14
|
|
16
15
|
A default configuration is available here: #{SAMPLE_CONFIG_FILE}.
|
@@ -56,7 +55,7 @@ WORKER_STATUS_CLEANING = :cleaning
|
|
56
55
|
# Logging and startup
|
57
56
|
LOG_PIPE_LEN = 10
|
58
57
|
LOG_COL_WID = 8
|
59
|
-
LOG_COL_JID = JOB_IDENT_LEN+3+2
|
58
|
+
LOG_COL_JID = JOB_IDENT_LEN + 3 + 2
|
60
59
|
LOG_COL_ID = 6
|
61
60
|
LOG_TRIM_LINE = 80
|
62
61
|
LOG_DUMPS = File.dirname(__FILE__) + "/../../log/"
|
@@ -67,7 +66,7 @@ LOG_FORMAT_MESSAGE = "%#{-LOG_COL_WID.to_i}s\t%#{-LOG_COL_JID.to_i}s\t%#{-L
|
|
67
66
|
LOG_NEWLINE = "\n"
|
68
67
|
LOG_INDENT = "\t"
|
69
68
|
BIND_PORT_TIMEOUT = 3
|
70
|
-
BIND_PORT_LOCALHOST =
|
69
|
+
BIND_PORT_LOCALHOST = "127.0.0.1"
|
71
70
|
|
72
71
|
|
73
72
|
# Notifications
|
@@ -89,7 +88,7 @@ DASHBOARD_WORKER_STYLES = {
|
|
89
88
|
working: :info,
|
90
89
|
crashed: :danger,
|
91
90
|
done: :success,
|
92
|
-
dead: :danger
|
91
|
+
dead: :danger,
|
93
92
|
}
|
94
93
|
|
95
94
|
|
@@ -110,7 +110,7 @@ module RestFtpDaemon
|
|
110
110
|
|
111
111
|
def self.hide_credentials_from_url path
|
112
112
|
return unless path.is_a? String
|
113
|
-
path.sub(/([a-z]+:\/\/[^\/]+):[^\/]+\@/, '\1@'
|
113
|
+
path.sub(/([a-z]+:\/\/[^\/]+):[^\/]+\@/, '\1@')
|
114
114
|
end
|
115
115
|
|
116
116
|
def self.formatted_duration duration
|
@@ -120,11 +120,11 @@ module RestFtpDaemon
|
|
120
120
|
minutes = (duration / 60) % 60
|
121
121
|
seconds = duration % 60
|
122
122
|
|
123
|
-
out << "#{hours}h" if hours>0
|
124
|
-
out << "#{minutes}mn" if (minutes>0) || (hours>0)
|
123
|
+
out << "#{hours}h" if hours > 0
|
124
|
+
out << "#{minutes}mn" if (minutes > 0) || (hours > 0)
|
125
125
|
out << "#{seconds}s"
|
126
126
|
|
127
|
-
out.join(
|
127
|
+
out.join(" ")
|
128
128
|
end
|
129
129
|
|
130
130
|
def self.dashboard_job_link job
|
data/lib/rest-ftp-daemon/job.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "securerandom"
|
2
2
|
|
3
3
|
module RestFtpDaemon
|
4
|
+
|
5
|
+
# Reprensents work to be done along with parameters to process it
|
4
6
|
class Job
|
5
7
|
include LoggerHelper
|
6
8
|
attr_reader :logger
|
@@ -29,7 +31,7 @@ module RestFtpDaemon
|
|
29
31
|
attr_reader name
|
30
32
|
end
|
31
33
|
|
32
|
-
def initialize job_id, params={}
|
34
|
+
def initialize job_id, params = {}
|
33
35
|
# Call super
|
34
36
|
# super()
|
35
37
|
|
@@ -68,7 +70,7 @@ module RestFtpDaemon
|
|
68
70
|
@updated_at = Time.now
|
69
71
|
|
70
72
|
# Send first notification
|
71
|
-
log_info "Job.initialize notify[queued] notify_after_sec[#{@notify_after_sec}]
|
73
|
+
log_info "Job.initialize notify[queued] notify_after_sec[#{@notify_after_sec}] interval[#{JOB_UPDATE_INTERVAL}]"
|
72
74
|
client_notify :queued
|
73
75
|
end
|
74
76
|
|
@@ -197,12 +199,12 @@ module RestFtpDaemon
|
|
197
199
|
@weight = [
|
198
200
|
- @runs.to_i,
|
199
201
|
+ @priority.to_i,
|
200
|
-
- @queued_at.to_i
|
202
|
+
- @queued_at.to_i,
|
201
203
|
]
|
202
204
|
end
|
203
205
|
|
204
206
|
def exectime
|
205
|
-
return nil if
|
207
|
+
return nil if @started_at.nil? || @finished_at.nil?
|
206
208
|
(@finished_at - @started_at).round(2)
|
207
209
|
end
|
208
210
|
|
@@ -242,7 +244,7 @@ module RestFtpDaemon
|
|
242
244
|
URI.parse replace_tokens(path)
|
243
245
|
end
|
244
246
|
|
245
|
-
def contains_brackets
|
247
|
+
def contains_brackets item
|
246
248
|
/\[.*\]/.match(item)
|
247
249
|
end
|
248
250
|
|
@@ -320,7 +322,6 @@ module RestFtpDaemon
|
|
320
322
|
|
321
323
|
def transfer
|
322
324
|
# Update job status
|
323
|
-
#log_info "Job.transfer starting"
|
324
325
|
@started_at = Time.now
|
325
326
|
|
326
327
|
# Method assertions and init
|
@@ -335,7 +336,6 @@ module RestFtpDaemon
|
|
335
336
|
set :source_count, sources.count
|
336
337
|
set :source_files, sources.collect(&:full)
|
337
338
|
log_info "Job.transfer sources #{sources.collect(&:name)}"
|
338
|
-
#log_info "Job.transfer target #{target.full}"
|
339
339
|
raise RestFtpDaemon::JobSourceNotFound if sources.empty?
|
340
340
|
|
341
341
|
# Guess target file name, and fail if present while we matched multiple sources
|
@@ -343,11 +343,9 @@ module RestFtpDaemon
|
|
343
343
|
|
344
344
|
# Connect to remote server and login
|
345
345
|
newstatus :remote_connect
|
346
|
-
#log_info "Job.remote_connect" # [#{host}] [#{login}]"
|
347
346
|
@remote.connect
|
348
347
|
|
349
348
|
# Prepare target path or build it if asked
|
350
|
-
#log_info "Job.remote_chdir"
|
351
349
|
newstatus :remote_chdir
|
352
350
|
@remote.chdir_or_create @target_path.dir, @mkdir
|
353
351
|
|
@@ -371,7 +369,6 @@ module RestFtpDaemon
|
|
371
369
|
end
|
372
370
|
|
373
371
|
# Do the transfer, for each file
|
374
|
-
#log_info "Job.remote_push"
|
375
372
|
remote_push source, full_target
|
376
373
|
|
377
374
|
# Update counters
|
@@ -387,8 +384,8 @@ module RestFtpDaemon
|
|
387
384
|
|
388
385
|
def log_context
|
389
386
|
{
|
390
|
-
|
391
|
-
|
387
|
+
wid: @wid,
|
388
|
+
jid: @id,
|
392
389
|
}
|
393
390
|
end
|
394
391
|
|
@@ -484,7 +481,6 @@ module RestFtpDaemon
|
|
484
481
|
|
485
482
|
# Done
|
486
483
|
set :source_current, nil
|
487
|
-
#log_info "Job.remote_push finished"
|
488
484
|
end
|
489
485
|
|
490
486
|
def progress transferred, name = ""
|
@@ -511,7 +507,7 @@ module RestFtpDaemon
|
|
511
507
|
stack << (Helpers.format_bytes @transfer_sent, "B")
|
512
508
|
stack << (Helpers.format_bytes @transfer_total, "B")
|
513
509
|
stack << (Helpers.format_bytes @current_bitrate.round(0), "bps")
|
514
|
-
stack2 = stack.map{ |txt| ("%#{LOG_PIPE_LEN.to_i}s" % txt)}.join("\t")
|
510
|
+
stack2 = stack.map { |txt| ("%#{LOG_PIPE_LEN.to_i}s" % txt) }.join("\t")
|
515
511
|
log_info "#{LOG_INDENT}progress #{stack2} \t#{name}"
|
516
512
|
|
517
513
|
# Remember when we last did it
|
@@ -526,7 +522,7 @@ module RestFtpDaemon
|
|
526
522
|
progress: percent0,
|
527
523
|
transfer_sent: @transfer_sent,
|
528
524
|
transfer_total: @transfer_total,
|
529
|
-
transfer_bitrate: @current_bitrate
|
525
|
+
transfer_bitrate: @current_bitrate,
|
530
526
|
}
|
531
527
|
client_notify :progress, status: notif_status
|
532
528
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module RestFtpDaemon
|
2
|
+
|
3
|
+
# Queue that stores all the Jobs waiting to be processed or fully processed
|
2
4
|
class JobQueue
|
3
5
|
include LoggerHelper
|
4
6
|
attr_reader :logger
|
@@ -134,7 +136,7 @@ module RestFtpDaemon
|
|
134
136
|
alias enq push
|
135
137
|
alias requeue push
|
136
138
|
|
137
|
-
def pop non_block=false
|
139
|
+
def pop non_block = false
|
138
140
|
@mutex.synchronize do
|
139
141
|
loop do
|
140
142
|
if @queue.empty?
|
@@ -9,7 +9,7 @@ class Logger
|
|
9
9
|
|
10
10
|
# Build prefixes depending on this context
|
11
11
|
prefix1 = build_prefix(context)
|
12
|
-
prefix2 = build_prefix
|
12
|
+
prefix2 = build_prefix + " | "
|
13
13
|
|
14
14
|
lines = context[:lines]
|
15
15
|
|
@@ -36,25 +36,25 @@ class Logger
|
|
36
36
|
context[:wid].to_s,
|
37
37
|
context[:jid].to_s,
|
38
38
|
context[:id].to_s,
|
39
|
-
context[:level].to_i+1
|
39
|
+
context[:level].to_i + 1,
|
40
40
|
]
|
41
41
|
end
|
42
42
|
|
43
43
|
protected
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
45
|
+
def build_from_array prefix, lines
|
46
|
+
lines.map do |value|
|
47
|
+
#text = value.to_s.strip[0..LOG_TRIM_LINE]
|
48
|
+
text = value.to_s[0..LOG_TRIM_LINE]
|
49
|
+
"#{prefix}#{text}"
|
51
50
|
end
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
53
|
+
def build_from_hash prefix, lines
|
54
|
+
lines.map do |name, value|
|
55
|
+
text = value.to_s.strip[0..LOG_TRIM_LINE]
|
56
|
+
"#{prefix}#{name}: #{text}"
|
58
57
|
end
|
58
|
+
end
|
59
59
|
|
60
60
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "logger"
|
2
2
|
|
3
3
|
module RestFtpDaemon
|
4
|
+
|
5
|
+
# Logger interface class to access logger though symbolic names
|
4
6
|
class LoggerPool
|
5
7
|
include Singleton
|
6
8
|
|
@@ -27,7 +29,7 @@ module RestFtpDaemon
|
|
27
29
|
prefix = LOG_FORMAT_PREFIX % [
|
28
30
|
datetime.strftime(LOG_FORMAT_TIME),
|
29
31
|
severity,
|
30
|
-
progname
|
32
|
+
progname,
|
31
33
|
]
|
32
34
|
|
33
35
|
# If we have a bunch of lines, prefix them and send them together
|
data/lib/rest-ftp-daemon/path.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module RestFtpDaemon
|
2
|
+
|
3
|
+
# Handles transfers for Job class
|
2
4
|
class Remote
|
3
5
|
include LoggerHelper
|
4
6
|
attr_reader :logger
|
@@ -41,11 +43,7 @@ module RestFtpDaemon
|
|
41
43
|
# Output header to STDOUT
|
42
44
|
puts
|
43
45
|
puts "-------------------- SESSION STARTING -------------------------"
|
44
|
-
#puts "job id\t #{@id}"
|
45
|
-
#puts "source\t #{@source}"
|
46
|
-
#puts "target\t #{@target}"
|
47
46
|
puts "class\t #{myname}"
|
48
|
-
#puts "class\t #{myname}"
|
49
47
|
puts "host\t #{@url.host}"
|
50
48
|
puts "user\t #{@url.user}"
|
51
49
|
puts "port\t #{@url.port}"
|
@@ -2,6 +2,7 @@ require "net/ftp"
|
|
2
2
|
require "double_bag_ftps"
|
3
3
|
|
4
4
|
module RestFtpDaemon
|
5
|
+
# Handles FTP and FTPeS transfers for Remote class
|
5
6
|
class RemoteFTP < Remote
|
6
7
|
attr_reader :ftp
|
7
8
|
|
@@ -77,12 +78,9 @@ module RestFtpDaemon
|
|
77
78
|
rescue Net::FTPPermError => _e
|
78
79
|
# If not allowed to create path, that's over, we're stuck
|
79
80
|
return false unless mkdir
|
80
|
-
|
81
|
-
#log_info "#{LOG_INDENT}upward [#{parent}]"
|
82
81
|
chdir_or_create parent, mkdir
|
83
82
|
|
84
83
|
# Now I was able to chdir into my parent, create the current directory
|
85
|
-
#log_info "#{LOG_INDENT}mkdir [#{directory}]"
|
86
84
|
mkdir "/#{directory}"
|
87
85
|
|
88
86
|
# Finally retry the chdir
|
@@ -105,7 +103,7 @@ module RestFtpDaemon
|
|
105
103
|
|
106
104
|
@ftp.putbinaryfile source.full, target.name, @chunk_size do |data|
|
107
105
|
# Update the worker activity marker
|
108
|
-
#FIXME worker_is_still_active
|
106
|
+
# FIXME: worker_is_still_active
|
109
107
|
|
110
108
|
# Update job status after this block transfer
|
111
109
|
yield data.bytesize, destination.name
|
@@ -130,11 +128,11 @@ module RestFtpDaemon
|
|
130
128
|
@ftp = Net::FTP.new
|
131
129
|
end
|
132
130
|
|
133
|
-
|
131
|
+
def prepare_ftpes
|
134
132
|
@ftp = DoubleBagFTPS.new
|
135
133
|
@ftp.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
136
134
|
@ftp.ftps_mode = DoubleBagFTPS::EXPLICIT
|
137
|
-
|
135
|
+
end
|
138
136
|
|
139
137
|
|
140
138
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "net/sftp"
|
2
2
|
|
3
3
|
module RestFtpDaemon
|
4
|
+
# Handles sFTP transfers for Remote class
|
4
5
|
class RemoteSFTP < Remote
|
5
6
|
attr_reader :sftp
|
6
7
|
|
@@ -81,11 +82,9 @@ module RestFtpDaemon
|
|
81
82
|
return false unless mkdir
|
82
83
|
|
83
84
|
# Recurse upward
|
84
|
-
#log_info "#{LOG_INDENT}upward [#{parent}]"
|
85
85
|
chdir_or_create parent, mkdir
|
86
86
|
|
87
87
|
# Now I was able to chdir into my parent, create the current directory
|
88
|
-
#log_info "#{LOG_INDENT}mkdir [#{directory}]"
|
89
88
|
mkdir directory
|
90
89
|
|
91
90
|
# Finally retry the chdir
|
@@ -114,7 +113,7 @@ module RestFtpDaemon
|
|
114
113
|
|
115
114
|
# Do the transfer
|
116
115
|
log_info "RemoteSFTP.push [#{destination.full}]"
|
117
|
-
@sftp.upload! source.full, destination.full do |event,
|
116
|
+
@sftp.upload! source.full, destination.full do |event, _uploader, *args|
|
118
117
|
case event
|
119
118
|
when :open then
|
120
119
|
# args[0] : file metadata
|
@@ -125,7 +124,7 @@ module RestFtpDaemon
|
|
125
124
|
# puts "writing #{args[2].length} bytes to #{args[0].remote} starting at #{args[1]}"
|
126
125
|
|
127
126
|
# Update the worker activity marker
|
128
|
-
#FIXME worker_is_still_active
|
127
|
+
# FIXME: worker_is_still_active
|
129
128
|
|
130
129
|
# Update job status after this block transfer
|
131
130
|
yield args[2].length, destination.name
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module RestFtpDaemon
|
2
|
+
|
3
|
+
# Handles a pool of Worker objects
|
2
4
|
class WorkerPool
|
3
5
|
include LoggerHelper
|
4
6
|
attr_reader :logger
|
@@ -96,10 +98,10 @@ module RestFtpDaemon
|
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
if Settings.newrelic_enabled?
|
102
|
+
add_transaction_tracer :create_conchita_thread, category: :task
|
103
|
+
add_transaction_tracer :create_worker_thread, category: :task
|
104
|
+
end
|
103
105
|
|
104
106
|
end
|
105
107
|
end
|
data/lib/rest-ftp-daemon.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
|
1
2
|
# Global libs
|
2
3
|
require "rubygems"
|
3
4
|
require "json"
|
5
|
+
require "haml"
|
4
6
|
require "uri"
|
5
7
|
require "timeout"
|
6
8
|
require "syslog"
|
@@ -17,7 +19,6 @@ require "newrelic_rpm"
|
|
17
19
|
# require 'flamegraph'
|
18
20
|
# end
|
19
21
|
|
20
|
-
|
21
22
|
# Project's libs
|
22
23
|
require_relative "rest-ftp-daemon/constants"
|
23
24
|
require_relative "rest-ftp-daemon/settings"
|
@@ -45,3 +46,6 @@ require_relative "rest-ftp-daemon/api/job_presenter"
|
|
45
46
|
require_relative "rest-ftp-daemon/api/jobs"
|
46
47
|
require_relative "rest-ftp-daemon/api/dashboard"
|
47
48
|
require_relative "rest-ftp-daemon/api/root"
|
49
|
+
|
50
|
+
# Haml monkey-patching
|
51
|
+
require_relative "rest-ftp-daemon/patch_haml"
|
data/rest-ftp-daemon.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
# Libs
|
4
|
-
#require "settingslogic"
|
5
4
|
app_root = File.dirname(__FILE__)
|
6
5
|
require File.expand_path("#{app_root}/lib/rest-ftp-daemon/constants")
|
7
6
|
|
@@ -17,32 +16,31 @@ Gem::Specification.new do |spec|
|
|
17
16
|
spec.licenses = ["MIT"]
|
18
17
|
|
19
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
-
f ==
|
19
|
+
f == "dashboard.png"
|
21
20
|
end
|
22
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
22
|
spec.require_paths = ["lib"]
|
24
23
|
spec.version = APP_VER
|
25
24
|
|
26
|
-
|
27
|
-
spec.required_ruby_version = ">= 2.1"
|
25
|
+
spec.required_ruby_version = ">= 2.1.7"
|
28
26
|
|
27
|
+
# spec.add_development_dependency "rack-mini-profiler"
|
28
|
+
# spec.add_development_dependency "stackprof"
|
29
|
+
# spec.add_development_dependency "flamegraph"
|
29
30
|
spec.add_development_dependency "bundler", "~> 1.6"
|
30
31
|
spec.add_development_dependency "rake"
|
31
32
|
spec.add_development_dependency "rspec", "~> 3.1"
|
32
33
|
spec.add_development_dependency "http", "~> 0.8"
|
33
34
|
spec.add_development_dependency "rubocop", "~> 0.32.0"
|
34
35
|
spec.add_development_dependency "pry"
|
35
|
-
# spec.add_development_dependency "rack-mini-profiler"
|
36
|
-
# spec.add_development_dependency "stackprof"
|
37
|
-
# spec.add_development_dependency "flamegraph"
|
38
36
|
|
37
|
+
# spec.add_runtime_dependency "net-ssh", "~> 2.10.1.rc1"
|
39
38
|
spec.add_runtime_dependency "thin", "~> 1.6"
|
40
39
|
spec.add_runtime_dependency "grape"
|
41
40
|
spec.add_runtime_dependency "grape-entity"
|
42
41
|
spec.add_runtime_dependency "settingslogic"
|
43
42
|
spec.add_runtime_dependency "haml"
|
44
43
|
spec.add_runtime_dependency "json"
|
45
|
-
#spec.add_runtime_dependency "net-ssh", "~> 2.10.1.rc1"
|
46
44
|
spec.add_runtime_dependency "net-sftp"
|
47
45
|
spec.add_runtime_dependency "double-bag-ftps"
|
48
46
|
spec.add_runtime_dependency "facter"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe "Dashboard", feature: true do
|
4
4
|
|
5
5
|
describe "GET /" do
|
6
6
|
context 'without a password' do
|
@@ -9,8 +9,8 @@ describe 'Dashboard', feature: true do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
context
|
13
|
-
it
|
12
|
+
context "with a password" do
|
13
|
+
it "can be accessed" do
|
14
14
|
expect(
|
15
15
|
get("/").status
|
16
16
|
).to eq 200
|
@@ -23,24 +23,24 @@ describe "Jobs", feature: true do
|
|
23
23
|
let(:params) do
|
24
24
|
{
|
25
25
|
source: "/tmp/foo",
|
26
|
-
target: "/tmp/bar"
|
26
|
+
target: "/tmp/bar",
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
30
|
it "issues a 201 response" do
|
31
31
|
expect(
|
32
|
-
post("/jobs", json: params).status
|
32
|
+
post("/jobs", json: params).status,
|
33
33
|
).to eq 201
|
34
34
|
end
|
35
35
|
|
36
36
|
it "exposes the new job id" do
|
37
37
|
response = JSON.parse post("/jobs", json: params)
|
38
|
-
expect(response[
|
38
|
+
expect(response["id"]).not_to be_nil
|
39
39
|
end
|
40
40
|
|
41
41
|
it "assigns a status" do
|
42
42
|
response = JSON.parse post("/jobs", json: params)
|
43
|
-
expect(response[
|
43
|
+
expect(response["status"]).to match(/^(queued|failed)$/)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "creates a new job" do
|
@@ -53,14 +53,14 @@ describe "Jobs", feature: true do
|
|
53
53
|
|
54
54
|
describe "GET /jobs/:id" do
|
55
55
|
let(:creation_response) do
|
56
|
-
JSON.parse post("/jobs", json: {source: "/tmp/foo", target: "/tmp/bar"}).body
|
56
|
+
JSON.parse post("/jobs", json: { source: "/tmp/foo", target: "/tmp/bar" }).body
|
57
57
|
end
|
58
58
|
|
59
|
-
let(:job_id) { creation_response.fetch(
|
59
|
+
let(:job_id) { creation_response.fetch("id") }
|
60
60
|
|
61
61
|
it "is properly exposed" do
|
62
62
|
expect(
|
63
|
-
get("/jobs/#{job_id}").status
|
63
|
+
get("/jobs/#{job_id}").status,
|
64
64
|
).to eq 200
|
65
65
|
end
|
66
66
|
end # GET /jobs/:id
|
data/spec/spec_helper.rb
CHANGED
@@ -38,7 +38,7 @@ RSpec.configure do |config|
|
|
38
38
|
# Use the documentation formatter for detailed output,
|
39
39
|
# unless a formatter has already been configured
|
40
40
|
# (e.g. via a command-line flag).
|
41
|
-
config.default_formatter =
|
41
|
+
config.default_formatter = "doc"
|
42
42
|
end
|
43
43
|
|
44
44
|
# Print the 10 slowest examples and example groups at the
|
@@ -51,8 +51,8 @@ RSpec.configure do |config|
|
|
51
51
|
|
52
52
|
include RequestHelpers
|
53
53
|
|
54
|
-
def call_server
|
55
|
-
system(Pathname(__dir__).join("../bin/rest-ftp-daemon -e test -c #{config} #{command} -p #{port}").to_s, chdir: __dir__)
|
54
|
+
def call_server command, config = Pathname(__dir__).join("support/config.yml"), port = RequestHelpers::PORT
|
55
|
+
system(Pathname(__dir__).join("../bin/rest-ftp-daemon -e test -c #{config} #{command} -p #{port}").to_s, chdir: __dir__) || fail("Could not #{command} server")
|
56
56
|
end
|
57
57
|
|
58
58
|
config.before :suite do
|
@@ -5,18 +5,18 @@ require "uri"
|
|
5
5
|
module RequestHelpers
|
6
6
|
PORT = 5678
|
7
7
|
|
8
|
-
def get
|
8
|
+
def get path, options = {}
|
9
9
|
accept = options.delete(:accept) { :json }
|
10
10
|
url = URI("http://localhost:#{PORT}").merge(path)
|
11
|
-
HTTP.accept(accept).basic_auth(user:
|
12
|
-
get(url, options)
|
11
|
+
HTTP.accept(accept).basic_auth(user: "admin", pass: "admin")
|
12
|
+
.get(url, options)
|
13
13
|
end
|
14
14
|
|
15
|
-
def post
|
15
|
+
def post path, options = {}
|
16
16
|
accept = options.delete(:accept) { :json }
|
17
17
|
url = URI("http://localhost:#{PORT}").merge(path)
|
18
|
-
HTTP.accept(accept).basic_auth(user:
|
19
|
-
post(url, options)
|
18
|
+
HTTP.accept(accept).basic_auth(user: "admin", pass: "admin")
|
19
|
+
.post(url, options)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-ftp-daemon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.242.
|
4
|
+
version: 0.242.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno MEDICI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/rest-ftp-daemon/logger_pool.rb
|
297
297
|
- lib/rest-ftp-daemon/notification.rb
|
298
298
|
- lib/rest-ftp-daemon/paginate.rb
|
299
|
+
- lib/rest-ftp-daemon/patch_haml.rb
|
299
300
|
- lib/rest-ftp-daemon/path.rb
|
300
301
|
- lib/rest-ftp-daemon/remote.rb
|
301
302
|
- lib/rest-ftp-daemon/remote_ftp.rb
|
@@ -337,7 +338,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
337
338
|
requirements:
|
338
339
|
- - ">="
|
339
340
|
- !ruby/object:Gem::Version
|
340
|
-
version:
|
341
|
+
version: 2.1.7
|
341
342
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
342
343
|
requirements:
|
343
344
|
- - ">="
|
@@ -345,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
346
|
version: '0'
|
346
347
|
requirements: []
|
347
348
|
rubyforge_project:
|
348
|
-
rubygems_version: 2.
|
349
|
+
rubygems_version: 2.2.5
|
349
350
|
signing_key:
|
350
351
|
specification_version: 4
|
351
352
|
summary: RESTful FTP client daemon
|