Class: Relish::Command::Push
- Inherits:
-
Base
- Object
- Base
- Relish::Command::Push
show all
- Defined in:
- lib/relish/commands/push.rb
Instance Attribute Summary
Attributes inherited from Base
#args, #cli_options
Instance Method Summary
collapse
Methods inherited from Base
#get_param, #initialize, #url
Methods included from Dsl
#option, #option_names, #option_names_to_display
Instance Method Details
#default ⇒ Object
16
|
# File 'lib/relish/commands/push.rb', line 16
def default; run end
|
#files ⇒ Object
53
54
55
|
# File 'lib/relish/commands/push.rb', line 53
def files
Dir['features/**/*.{feature,md,markdown}']
end
|
#files_as_tar_gz ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/relish/commands/push.rb', line 39
def files_as_tar_gz
stream = StringIO.new
begin
tgz = Zlib::GzipWriter.new(stream)
tar = Archive::Tar::Minitar::Output.new(tgz)
files.each do |entry|
Archive::Tar::Minitar.pack_file(entry, tar)
end
ensure
tar.close if tar end
stream.string
end
|
#parameters ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/relish/commands/push.rb', line 31
def parameters
"".tap do |str|
str << "project_id=#{project}&"
str << "version_id=#{version}&" if version
str << "api_token=#{api_token}"
end
end
|
#post(tar_gz_data) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/relish/commands/push.rb', line 22
def post(tar_gz_data)
resource["pushes?#{parameters}"].post(tar_gz_data,
:content_type => 'application/x-gzip')
puts "sent:\n#{files.join("\n")}"
rescue RestClient::Exception => exception
warn exception.response
exit 1
end
|
#run ⇒ Object
18
19
20
|
# File 'lib/relish/commands/push.rb', line 18
def run
post files_as_tar_gz
end
|