Module: Hoe::Debug

Includes:
Rake::DSL
Defined in:
lib/hoe/debug.rb

Overview

Debug plugin for hoe.

Tasks Provided:

check_manifest

Verify the manifest.

config_hoe

Create a fresh ~/.hoerc file.

debug_gem

Show information about the gem.

Constant Summary collapse

DIFF =

:stopdoc:

if Hoe::WINDOZE
  "diff.exe"
else
  if system("gdiff", __FILE__, __FILE__)
    "gdiff" # solaris and kin suck
  else
    "diff"
  end
end

Instance Method Summary collapse

Instance Method Details

#check_manifestObject

Verifies your Manifest.txt against the files in your project.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/hoe/debug.rb', line 72

def check_manifest
  f = "Manifest.tmp"
  require "find"
  files = []
  with_config do |config, _|
    exclusions = config["exclude"]

    Find.find "." do |path|
      next unless File.file? path
      next if path =~ exclusions
      files << path[2..-1]
    end

    files = files.sort.join "\n"

    File.open f, "w" do |fp| fp.puts files end

    verbose = { :verbose => Rake.application.options.trace || Rake.verbose }

    begin
      sh "#{DIFF} -du Manifest.txt #{f}", verbose
    ensure
      rm f, **verbose
    end
  end
end

#define_debug_tasksObject

Define tasks for plugin.



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
58
59
60
61
62
63
64
65
66
67
# File 'lib/hoe/debug.rb', line 33

def define_debug_tasks
  desc "Create a fresh ~/.hoerc file."
  task :config_hoe do
    with_config do |config, path|
      File.open(path, "w") do |f|
        YAML.dump(Hoe::DEFAULT_CONFIG.merge(config), f)
      end

      editor = ENV["EDITOR"] || "vi"
      system "#{editor} #{path}" if ENV["SHOW_EDITOR"] != "no"
    end
  end

  desc "Verify the manifest."
  task :check_manifest => :clean do
    check_manifest
  end

  desc "Show information about the gem."
  task :debug_gem do
    puts spec.to_ruby
  end

  task :isolate # stub
  task :irb => :isolate do
    name = spec.name.gsub("-", "/")
    file = (spec.files.grep(/^lib\/#{name}\.rb$/).first ||
            spec.files.grep(/^lib\/[^\/]*\.rb$/).first)

    require = File.basename(file, ".rb") if file
    require &&= "-r#{require}"

    ruby "#{Hoe::RUBY_FLAGS} -S irb #{require}"
  end
end