Module: Hoe::Markdown

Includes:
Rake::DSL
Included in:
Standalone
Defined in:
lib/hoe/markdown.rb,
lib/hoe/markdown/util.rb,
lib/hoe/markdown/version.rb,
lib/hoe/markdown/standalone.rb

Defined Under Namespace

Modules: Util Classes: Standalone

Constant Summary collapse

VERSION =
"1.6.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#markdown_linkify_filesObject

Optional: used to specify which markdown files to linkify. [default: any markdown files found in ‘files`].



10
11
12
# File 'lib/hoe/markdown.rb', line 10

def markdown_linkify_files
  @markdown_linkify_files
end

Instance Method Details

#default_markdown_linkify_filesObject



12
13
14
# File 'lib/hoe/markdown.rb', line 12

def default_markdown_linkify_files
  spec.files.grep(/\.md$/)
end

#define_markdown_tasks(*additional_files) ⇒ Object



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

def define_markdown_tasks(*additional_files)
  @markdown_linkify_files ||= default_markdown_linkify_files
  @markdown_linkify_files = @markdown_linkify_files.append(*additional_files).uniq
  return if markdown_linkify_files.empty?

  namespace_name = "markdown:linkify"
  linkify_tasks = []

  namespace namespace_name do
    markdown_linkify_files.each do |mdfile_path|
      mdfile_name = File.basename(mdfile_path)
      task_name = mdfile_name.downcase.split(".")[0..-2].join(".")

      desc "hyperlink github issues and usernames in #{mdfile_name}"
      task task_name do
        original_markdown = markdown = File.read(mdfile_path)

        markdown = Hoe::Markdown::Util.linkify_github_usernames(markdown)
        if spec.["bug_tracker_uri"]
          markdown = Hoe::Markdown::Util.linkify_github_issues(markdown, spec.["bug_tracker_uri"])
        else
          warn "Spec metadata URI for 'bugs' is missing, skipping linkification of issues and pull requests"
        end

        if markdown == original_markdown
          puts "markdown:linkify: no changes to #{mdfile_path}"
        else
          puts "markdown:linkify: updating #{mdfile_path}"
          File.open(mdfile_path, "w") { |f| f.write markdown }
        end
      end
      linkify_tasks << "#{namespace_name}:#{task_name}"
    end
  end

  desc "hyperlink github issues and usernames in markdown files"
  task namespace_name => linkify_tasks
end

#initialize_markdownObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hoe/markdown.rb', line 16

def initialize_markdown
  @markdown_linkify_files = nil

  if File.exist?("CHANGELOG.md")
    self.history_file = "CHANGELOG.md"
  end

  if File.exist?("README.md")
    self.readme_file = "README.md"
  end
end