Permalink
Browse files

Merge branch 'add_hammer' into experimental

closes #267

* add_hammer:
  Rakefile: Gem.source_index is also deperecated, use Gem::Specification but be backward-compatible with older versions of rubygems.
  Janus tools/hammer: Fix the installation script for using find_gem instead.
  Rakefile: Add a method to find an installed gem.
  Janus tools/hammer: Add installation task.
  Janus Tools: Add hammer.

Conflicts:
	.gitmodules
	Rakefile
  • Loading branch information...
2 parents 3a904dd + baad78a commit 50fb70e05f752a8adf25095a24f18f1cbdfc93aa @kalbasit kalbasit committed Nov 2, 2011
Showing with 58 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +23 −0 Rakefile
  3. +1 −0 janus-tools/hammer
  4. +13 −0 janus-tools/janus/plugin/hammer.vim
  5. +18 −0 janus-tools/tasks/hammer.rake
View
3 .gitmodules
@@ -73,3 +73,6 @@
[submodule "janus-core/surround"]
path = janus-core/surround
url = git://github.com/tpope/vim-surround.git
+[submodule "janus-tools/hammer"]
+ path = janus-tools/hammer
+ url = git://github.com/robgleeson/hammer.vim.git
View
23 Rakefile
@@ -1,4 +1,8 @@
module Janus
+ # Errors
+ JanusError = Class.new Exception
+ RubyGemsNotFoundError = Class.new JanusError
+
module VIM
extend self
@@ -24,6 +28,25 @@ def expand(file)
File.expand_path(file)
end
+# Find an installed gem
+#
+# @param [String] The gem name to search for
+# @return [Array] The found gems
+def find_gem(gem_name)
+ begin
+ require 'rubygems'
+ if Gem.const_defined?(:Specification)
+ Gem::Specification.find_all_by_name(gem_name)
+ elsif Gem.respond_to?(:source_index)
+ Gem.source_index.find_name(gem_name)
+ else
+ Gem.cache.find_name(gem_name)
+ end
+ rescue LoadError
+ raise Janus::RubyGemsNotFoundError
+ end
+end
+
namespace :plugins do
task :install do
# dummy task for plugin installation tasks.
1 janus-tools/hammer
@@ -0,0 +1 @@
+Subproject commit 8cf24763ed792fe54ab4afb42c1dde896341a325
View
13 janus-tools/janus/plugin/hammer.vim
@@ -0,0 +1,13 @@
+function s:setupMarkup()
+ map <buffer> <Leader>p :Hammer<CR>
+endfunction
+
+if executable("redcarpet")
+ " define buffer-local preview for markdown files
+ au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
+endif
+
+if executable("redcloth")
+ " define buffer-local preview for textile files
+ au BufRead,BufNewFile *.textile call s:setupMarkup()
+endif
View
18 janus-tools/tasks/hammer.rake
@@ -0,0 +1,18 @@
+namespace :plugins do
+ desc "Install the hammer plugin."
+ task :install_hammer do
+ begin
+ if find_gem('github-markup').length == 0
+ sh "gem install github-markup"
+ end
+ if find_gem('redcarpet').length == 0
+ sh "gem install redcarpet"
+ end
+ rescue Janus::RubyGemsNotFoundError
+ puts "Could not install github-markup and redcarpet, please install them manually."
+ puts "gem install github-markup redcarpet"
+ end
+ end
+
+ task :install => :install_hammer
+end

0 comments on commit 50fb70e

Please sign in to comment.