djanowski-snippets 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ task :default => :spec
12
12
 
13
13
  desc "Run all specs in spec directory (excluding plugin specs)"
14
14
  Spec::Rake::SpecTask.new(:spec) do |t|
15
- # t.spec_opts = ['--options', File.join(File.dirname(__FILE__), 'spec', 'spec.opts')]
15
+ t.spec_opts = ['--options', File.join(File.dirname(__FILE__), 'spec', 'spec.opts')]
16
16
  t.spec_files = FileList['spec/**/*_spec.rb']
17
17
  end
18
18
 
data/lib/snippet.rb CHANGED
@@ -11,7 +11,6 @@ class Snippet < ActiveRecord::Base
11
11
  end
12
12
 
13
13
  def parse(text, parser = nil)
14
- parser = 'html' if parser.blank?
15
14
  klass = Snippets::Parsers.const_get(parser.to_s.classify)
16
15
  klass.parse(text)
17
16
  end
@@ -24,6 +23,7 @@ class Snippet < ActiveRecord::Base
24
23
  private
25
24
 
26
25
  def compile_text
26
+ self.parser = 'html' if parser.blank?
27
27
  self.compiled_text = Snippet.parse(text, parser)
28
28
  end
29
29
 
@@ -1,8 +1,8 @@
1
1
  module Snippets
2
2
  module Helper
3
- def snippet(slug, &block)
3
+ def snippet(slug, options = {}, &block)
4
4
  text = capture(&block) if block_given?
5
- Snippet.get(slug, :text => text)
5
+ Snippet.get(slug, {:text => text}.merge(options))
6
6
  end
7
7
  end
8
8
  end
@@ -1,10 +1,8 @@
1
- require 'erb'
2
-
3
1
  module Snippets
4
2
  module Parsers
5
3
  class Html
6
4
  def self.parse(text)
7
- ERB::Util.h(text)
5
+ text.to_s
8
6
  end
9
7
  end
10
8
  end
@@ -0,0 +1,11 @@
1
+ require 'erb'
2
+
3
+ module Snippets
4
+ module Parsers
5
+ class PlainText
6
+ def self.parse(text)
7
+ ERB::Util.h(text)
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/snippets.rb CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  require 'snippet'
6
6
  require 'snippets/parsers/html'
7
+ require 'snippets/parsers/plain_text'
7
8
  require 'snippets/parsers/textile'
8
9
 
9
10
  module Snippets
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djanowski-snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Janowski
@@ -25,6 +25,7 @@ files:
25
25
  - lib/snippet.rb
26
26
  - lib/snippets/helper.rb
27
27
  - lib/snippets/parsers/html.rb
28
+ - lib/snippets/parsers/plain_text.rb
28
29
  - lib/snippets/parsers/textile.rb
29
30
  - lib/snippets.rb
30
31
  - rails/init.rb