Class: Fjords::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Fjords::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/fjords/rake_task.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
, :domain_file.
-
#name ⇒ Object
, :domain_file.
-
#password ⇒ Object
, :domain_file.
-
#path ⇒ Object
, :domain_file.
-
#username ⇒ Object
, :domain_file.
Instance Method Summary collapse
-
#initialize(*args, &task_block) ⇒ RakeTask
constructor
A new instance of RakeTask.
- #run_task ⇒ Object
Constructor Details
#initialize(*args, &task_block) ⇒ RakeTask
Returns a new instance of RakeTask.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fjords/rake_task.rb', line 11 def initialize(*args, &task_block) @name = args.shift || :fjords desc "Push files to Fjords" unless ::Rake.application.last_comment task name, *args do |_, task_args| RakeFileUtils.send(:verbose, verbose) do task_block.call(*[self, task_args].slice(0, task_block.arity)) if task_block run_task end end end |
Instance Attribute Details
#domain ⇒ Object
, :domain_file
9 10 11 |
# File 'lib/fjords/rake_task.rb', line 9 def domain @domain end |
#name ⇒ Object
, :domain_file
9 10 11 |
# File 'lib/fjords/rake_task.rb', line 9 def name @name end |
#password ⇒ Object
, :domain_file
9 10 11 |
# File 'lib/fjords/rake_task.rb', line 9 def password @password end |
#path ⇒ Object
, :domain_file
9 10 11 |
# File 'lib/fjords/rake_task.rb', line 9 def path @path end |
#username ⇒ Object
, :domain_file
9 10 11 |
# File 'lib/fjords/rake_task.rb', line 9 def username @username end |
Instance Method Details
#run_task ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fjords/rake_task.rb', line 24 def run_task if !::Fjords::Client.logged_in? if !username || !password puts "Username and password are required" exit(1) end ::Fjords::Client.login(username, password) end push_path = path || Dir.pwd # puts "Deploying..." cmd = "bundle exec fjords push" cmd << %Q{ --path="#{push_path}" --no-progress} if domain cmd << %Q{ --domain="#{opts.domain}"} cmd << %Q{ --overwrite} end # cmd << %Q{ --domain-file="#{opts.domain_file}"} if opts.domain_file require 'pty' begin PTY.spawn(cmd) do |stdin, stdout, pid| begin stdin.each { |line| print line } rescue Errno::EIO end end rescue PTY::ChildExited # puts "The child process exited!" end end |