ftpmock 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +60 -2
- data/.travis.yml +19 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +30 -11
- data/README.md +136 -12
- data/ftpmock.gemspec +6 -1
- data/images/ftpmock.png +0 -0
- data/images/ruby.png +0 -0
- data/lib/ftpmock.rb +19 -1
- data/lib/ftpmock/core/cache.rb +186 -0
- data/lib/ftpmock/core/configuration.rb +33 -0
- data/lib/ftpmock/helpers/get_helper.rb +46 -0
- data/lib/ftpmock/helpers/list_helper.rb +53 -0
- data/lib/ftpmock/helpers/path_helper.rb +24 -0
- data/lib/ftpmock/helpers/put_helper.rb +39 -0
- data/lib/ftpmock/proxies/method_missing_mixin.rb +9 -0
- data/lib/ftpmock/proxies/net_ftp_proxy.rb +287 -0
- data/lib/ftpmock/proxies/net_sftp_proxy.rb +50 -0
- data/lib/ftpmock/utils/color_utils.rb +27 -0
- data/lib/ftpmock/utils/string_utils.rb +29 -0
- data/lib/ftpmock/utils/verbose_utils.rb +19 -0
- data/lib/ftpmock/version.rb +1 -1
- metadata +74 -3
@@ -0,0 +1,50 @@
|
|
1
|
+
# https://github.com/net-ssh/net-sftp
|
2
|
+
|
3
|
+
module Ftpmock
|
4
|
+
class NetSftpProxy
|
5
|
+
# Stubbers
|
6
|
+
|
7
|
+
Real = begin
|
8
|
+
Net::SFTP
|
9
|
+
rescue NameError
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# inspired by https://github.com/bblimke/webmock/blob/master/lib/webmock/http_lib_caches/net_http.rb
|
14
|
+
def self.on!
|
15
|
+
unless Real
|
16
|
+
yield
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
Net.send(:remove_const, :SFTP)
|
21
|
+
Net.const_set(:SFTP, self)
|
22
|
+
if block_given?
|
23
|
+
yield
|
24
|
+
off!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.off!
|
29
|
+
return unless Real
|
30
|
+
|
31
|
+
Net.send(:remove_const, :SFTP)
|
32
|
+
Net.const_set(:SFTP, Real)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Instance Methods
|
36
|
+
|
37
|
+
def initialize(configuration: Ftpmock.configuration)
|
38
|
+
@configuration = configuration
|
39
|
+
end
|
40
|
+
|
41
|
+
# def self.start(*)
|
42
|
+
# i = new
|
43
|
+
# yield i
|
44
|
+
# end
|
45
|
+
|
46
|
+
def real
|
47
|
+
@real ||= Real.new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ftpmock
|
2
|
+
module ColorUtils
|
3
|
+
module_function
|
4
|
+
|
5
|
+
# gem colorize, 'string'.bold.black.on_light_yellow
|
6
|
+
def highlight(string)
|
7
|
+
"\e[1;30;103m#{string}\e[0m"
|
8
|
+
end
|
9
|
+
|
10
|
+
def colorize(string, color)
|
11
|
+
case color
|
12
|
+
when :red
|
13
|
+
"\e[0;91;49m#{string}\e[0m"
|
14
|
+
when :yellow
|
15
|
+
"\e[0;93;49m#{string}\e[0m"
|
16
|
+
when :green
|
17
|
+
"\e[0;92;49m#{string}\e[0m"
|
18
|
+
else
|
19
|
+
string
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def bold(string)
|
24
|
+
"\e[1;39;49m#{string}\e[0m"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'diffy'
|
2
|
+
|
3
|
+
module Ftpmock
|
4
|
+
module StringUtils
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def all_present?(*strings)
|
8
|
+
strings.all? { |string| present?(string) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def present?(string)
|
12
|
+
return string.present? if string.respond_to?(:present?)
|
13
|
+
|
14
|
+
!string.to_s.strip.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
# Inspired by from gems/activesupport-5.2.3
|
18
|
+
# /lib/active_support/inflector/transliterate.rb
|
19
|
+
def parameterize(string, separator: '-')
|
20
|
+
string.to_s
|
21
|
+
.gsub(/[^a-z0-9\-_]+/i, separator)
|
22
|
+
.downcase
|
23
|
+
end
|
24
|
+
|
25
|
+
def diff(localfile, path)
|
26
|
+
Diffy::Diff.new(localfile.to_s, path.to_s, source: 'files').to_s(:color)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Ftpmock
|
2
|
+
module VerboseUtils
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def warn(string)
|
6
|
+
Kernel.warn string
|
7
|
+
end
|
8
|
+
|
9
|
+
def puts(string = '')
|
10
|
+
Kernel.puts string
|
11
|
+
end
|
12
|
+
|
13
|
+
def alert(tag, content, color)
|
14
|
+
content = ColorUtils.colorize(content, color)
|
15
|
+
output = ColorUtils.bold "#{tag} -> #{content}"
|
16
|
+
puts output
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ftpmock/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ftpmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Pinto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: codeclimate-test-reporter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: net-sftp
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rake
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +80,34 @@ dependencies:
|
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: diffy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
55
111
|
description: Just like VCR and WebMock, but for FTP.
|
56
112
|
email:
|
57
113
|
- thejamespinto@gmail.com
|
@@ -72,8 +128,23 @@ files:
|
|
72
128
|
- bin/console
|
73
129
|
- bin/setup
|
74
130
|
- ftpmock.gemspec
|
131
|
+
- images/ftpmock.png
|
132
|
+
- images/ruby.png
|
75
133
|
- lib/ftpmock.rb
|
134
|
+
- lib/ftpmock/core/cache.rb
|
135
|
+
- lib/ftpmock/core/configuration.rb
|
136
|
+
- lib/ftpmock/helpers/get_helper.rb
|
137
|
+
- lib/ftpmock/helpers/list_helper.rb
|
138
|
+
- lib/ftpmock/helpers/path_helper.rb
|
139
|
+
- lib/ftpmock/helpers/put_helper.rb
|
140
|
+
- lib/ftpmock/proxies/method_missing_mixin.rb
|
141
|
+
- lib/ftpmock/proxies/net_ftp_proxy.rb
|
142
|
+
- lib/ftpmock/proxies/net_sftp_proxy.rb
|
143
|
+
- lib/ftpmock/utils/color_utils.rb
|
144
|
+
- lib/ftpmock/utils/string_utils.rb
|
145
|
+
- lib/ftpmock/utils/verbose_utils.rb
|
76
146
|
- lib/ftpmock/version.rb
|
147
|
+
- tmp/.gitkeep
|
77
148
|
homepage: https://github.com/thejamespinto/ftpmock
|
78
149
|
licenses:
|
79
150
|
- MIT
|
@@ -96,5 +167,5 @@ requirements: []
|
|
96
167
|
rubygems_version: 3.0.4
|
97
168
|
signing_key:
|
98
169
|
specification_version: 4
|
99
|
-
summary:
|
170
|
+
summary: Test your FTP calls offline.
|
100
171
|
test_files: []
|