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
52 53 54 55 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 52 def self.begin_trans note "Beginning transaction" FileUtils.cp_r(Dir.pwd / "gems", Dir.pwd / ".original_gems") end |
.commit_trans ⇒ Object
57 58 59 60 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 57 def self.commit_trans note "Committing transaction" FileUtils.rm_rf(Dir.pwd / ".original_gems") end |
.rollback_trans ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 62 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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 23 def full_list @idx.load_gems_in("gems/specifications") @list.map do |name, versions| dep = ::Gem::Dependency.new(name, versions) spec = @idx.search(dep).last unless spec self.class.error "A required dependency #{dep} was not found" self.class.rollback_trans end deps = spec.recursive_dependencies(dep, @idx) [spec] + deps end.flatten.uniq end |
#rescue_failures(error = StandardError, prc = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/generators/templates/application/common/merb_thor/ops.rb', line 38 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 |