Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 50fb70e05f752a8adf25095a24f18f1cbdfc93aa 2 parents 3a904dd + baad78a
Wael M. Nasreddine eMxyzptlk authored
3  .gitmodules
View
@@ -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
23 Rakefile
View
@@ -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
13 janus-tools/janus/plugin/hammer.vim
View
@@ -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
18 janus-tools/tasks/hammer.rake
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.