Class: Thor::Tasks::Merb::Gem
- Inherits:
-
Thor
- Object
- Thor
- Thor::Tasks::Merb::Gem
- Defined in:
- lib/generators/templates/application/common/merb_thor/ops.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.begin_trans ⇒ Object
50 51 52 53 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 50 def self.begin_trans note "Beginning transaction" FileUtils.cp_r(Dir.pwd / "gems", Dir.pwd / ".original_gems") end |
.commit_trans ⇒ Object
55 56 57 58 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 55 def self.commit_trans note "Committing transaction" FileUtils.rm_rf(Dir.pwd / ".original_gems") end |
.rollback_trans ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 60 def self.rollback_trans if File.exist?(Dir.pwd / ".original_gems") note "Rolling back transaction" FileUtils.rm_rf(Dir.pwd / "gems") FileUtils.mv(Dir.pwd / ".original_gems", Dir.pwd / "gems") end exit! end |
Instance Method Details
#full_list ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 22 def full_list @idx.load_gems_in("gems/specifications") @list.map do |name, versions| dep = @idx.find_name(name).last unless dep self.class.error "A required dependency #{dep} was not found" self.class.rollback_trans end deps = dep.recursive_dependencies(dep, @idx) [dep] + deps end.flatten.uniq end |
#rescue_failures(error = StandardError, prc = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 36 def rescue_failures(error = StandardError, prc = nil) begin yield rescue error => e if prc prc.call(e) else puts e. puts e.backtrace end self.class.rollback_trans end end |