Class: FaaStRuby::Local::StaticFile
- Inherits:
-
Object
- Object
- FaaStRuby::Local::StaticFile
show all
- Includes:
- Logger
- Defined in:
- lib/faastruby/local/static_files/static_file.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logger
#debug, #print, puts, #puts
Constructor Details
#initialize(full_path:, relative_path:, filename:, dirname:) ⇒ StaticFile
Returns a new instance of StaticFile.
19
20
21
22
23
24
25
26
|
# File 'lib/faastruby/local/static_files/static_file.rb', line 19
def initialize(full_path:, relative_path:, filename:, dirname:)
@full_path = full_path
@relative_path = relative_path
@filename = filename
@dirname = dirname
@config = YAML.load(File.read("#{Local.public_dir}/faastruby.yml"))
@before_build = @config['before_build'] || []
end
|
Class Method Details
.full_sync ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/faastruby/local/static_files/static_file.rb', line 6
def self.full_sync
cmd = "faastruby deploy-to #{Local.workspace} -f #{Local.public_dir}"
output, status = Open3.capture2e(cmd)
String.disable_colorization = true
if status.exitstatus == 0
output.split("\n").each {|o| puts "#{Time.now} | #{o}" unless o == '---'}
puts '---'
else
STDERR.puts output
end
String.disable_colorization = false
end
|
Instance Method Details
#deploy ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/faastruby/local/static_files/static_file.rb', line 28
def deploy
path = "public/#{@relative_path}"
cmd = "faastruby cp #{path} #{Local.workspace}:/#{@relative_path}"
puts "Running: #{cmd}"
output, status = Open3.capture2e(cmd)
String.disable_colorization = true
if status.exitstatus == 0
output.split("\n").each {|o| puts o unless o == '---' || o == "" || o.match(/Copying file to/)}
else
puts "* [#{path}] Error uploading static file '#{path}' to cloud workspace '#{Local.workspace}':"
STDERR.puts output
end
String.disable_colorization = false
end
|
#remove_from_workspace ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/faastruby/local/static_files/static_file.rb', line 43
def remove_from_workspace
path = "public/#{@relative_path}"
cmd = "faastruby rm #{Local.workspace}:/#{@relative_path}"
puts "Running: #{cmd}"
output, status = Open3.capture2e(cmd)
String.disable_colorization = true
if status.exitstatus == 0
output.split("\n").each {|o| puts o unless o == '---'}
else
puts "* [#{path}] Error removing static file '#{path}' from cloud workspace '#{Local.workspace}':"
STDERR.puts output
end
String.disable_colorization = false
end
|