snippetize 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in snippetize.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mathieu Gagné
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Snippetize
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'snippetize'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install snippetize
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ module Snippetize
2
+ module ActionViewExtensions
3
+ module SnippetizeHelper
4
+
5
+ def snippetize string
6
+ string.gsub(/\{(.*?)\}/) do |s|
7
+ snippet = Snippetize::Snippet.new($1)
8
+ render partial: snippet.path, locals: snippet.locals
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+
16
+ ActionView::Base.send :include, Snippetize::ActionViewExtensions::SnippetizeHelper
@@ -0,0 +1,13 @@
1
+ module Snippetize
2
+ class Snippet
3
+
4
+ attr_accessor :partial, :path, :locals
5
+
6
+ def initialize(snippet)
7
+ @partial, params = snippet.split(/[\s]/, 2)
8
+ @locals = Rack::Utils.parse_nested_query(params).try(:symbolize_keys!)
9
+ @path = "#{Snippetize.location}/#{@partial}"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Snippetize
2
+ VERSION = "0.0.2"
3
+ end
data/lib/snippetize.rb ADDED
@@ -0,0 +1,29 @@
1
+ require 'snippetize/version'
2
+ require 'snippetize/snippet'
3
+ require 'snippetize/action_view_extensions/snippetize_helper'
4
+
5
+ module Snippetize
6
+
7
+ mattr_accessor :delimiters
8
+ @@delimiters = %w({ })
9
+
10
+ mattr_accessor :location
11
+ @@location = 'snippets'
12
+
13
+ mattr_accessor :templating_engine
14
+ @@templating_engine = 'erb'
15
+
16
+ def self.setup
17
+ yield self
18
+ end
19
+
20
+ protected
21
+
22
+ def start_delimiter
23
+ @start_delimiter ||= Snippetize.delimiters[0]
24
+ end
25
+
26
+ def end_delimiter
27
+ @end_delimiter ||= Snippetize.delimiters[1]
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'snippetize/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "snippetize"
8
+ gem.version = Snippetize::VERSION
9
+ gem.authors = ["Mathieu Gagné"]
10
+ gem.email = ["mathieu@motioneleven.com"]
11
+ gem.description = %q{Snippetize allows you to include re-usable code and partials in html or plain text fields.}
12
+ gem.summary = %q{Snippetize allows you to include re-usable code and partials in html or plain text fields. Stay dry and reuse your partials using shortcode. Use it for including forms, videos, maps or simply preformated html snippets.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snippetize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mathieu Gagné
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-07 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Snippetize allows you to include re-usable code and partials in html
15
+ or plain text fields.
16
+ email:
17
+ - mathieu@motioneleven.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/snippetize.rb
28
+ - lib/snippetize/action_view_extensions/snippetize_helper.rb
29
+ - lib/snippetize/snippet.rb
30
+ - lib/snippetize/version.rb
31
+ - snippetize.gemspec
32
+ homepage: ''
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.23
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Snippetize allows you to include re-usable code and partials in html or plain
56
+ text fields. Stay dry and reuse your partials using shortcode. Use it for including
57
+ forms, videos, maps or simply preformated html snippets.
58
+ test_files: []