Class: Guard::ReadmeOnGithub
- Defined in:
- lib/guard/readme-on-github.rb
Instance Method Summary collapse
- #asset_dir ⇒ Object
- #copy_assets ⇒ Object
- #run_all ⇒ Object
- #run_on_change(paths) ⇒ Object
- #start ⇒ Object
- #this_dir ⇒ Object
Instance Method Details
#asset_dir ⇒ Object
16 17 18 |
# File 'lib/guard/readme-on-github.rb', line 16 def asset_dir File.join(this_dir, 'readme-on-github', 'assets') end |
#copy_assets ⇒ Object
20 21 22 23 24 |
# File 'lib/guard/readme-on-github.rb', line 20 def copy_assets %w[github.css github-logo.png github-logo-hover.png jquery.js github.js].each do |filename| FileUtils.cp "#{asset_dir}/#{filename}", "/tmp/#{filename}" end end |
#run_all ⇒ Object
31 32 33 |
# File 'lib/guard/readme-on-github.rb', line 31 def run_all true end |
#run_on_change(paths) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/guard/readme-on-github.rb', line 35 def run_on_change(paths) paths.each do |path| text = GithubFlavoredMarkdown.gfm(File.read(path)) html = RDiscount.new(text).to_html github = File.read("#{asset_dir}/github.html") File.open('/tmp/markdown-preview.html', 'w') do |f| f.puts github.sub(/INSERT_BODY/, html) end end puts 'compiled markdown' true end |
#start ⇒ Object
26 27 28 29 |
# File 'lib/guard/readme-on-github.rb', line 26 def start copy_assets true end |
#this_dir ⇒ Object
12 13 14 |
# File 'lib/guard/readme-on-github.rb', line 12 def this_dir File.('..', __FILE__) end |