carpetbomb 0.1.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8202ff020b4878e64eae36148e5fd4a7272c3de
4
+ data.tar.gz: 0da4035006c1a3a47139d1af85b296dcd5a00d4b
5
+ SHA512:
6
+ metadata.gz: 552b768661942931273898b4738db9696261d65397d791eb57857c2758f2de759717d10293917357a6c3e53e9ac0c6083fbf7db04279d9325562c3ec6fd9d532
7
+ data.tar.gz: ba3bcd7d2a797b5cd1a04381d1fca2b90fc0d2e693206433e183f4e8f889833c4e07e9618319bbf01f57626e9e303afd93d7ac82c412b2f86a13a7e088095913
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in so_meta.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ carpetbomb (0.0.7)
5
+ redcarpet (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ redcarpet (3.0.0)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ carpetbomb!
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alberto Grespan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # Carpetbomb
2
+
3
+ **Markdown and erb template handler for Ruby on Rails using [Redcarpet](https://github.com/vmg/redcarpet).**
4
+
5
+ ## Dependencies
6
+
7
+ It depends on Redcarpet v3.0.0.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add to your project Gemfile:
13
+ ~~~sh
14
+ gem 'carpetbomb'
15
+ ~~~
16
+
17
+ Run the following command to install it:
18
+ ~~~sh
19
+ bundle install
20
+ ~~~
21
+
22
+ Run the generator:
23
+ ~~~sh
24
+ rails generate carpetbomb:install
25
+ ~~~
26
+
27
+ That's it.
28
+
29
+ ## Uninstall
30
+
31
+ Run the generator:
32
+ ~~~sh
33
+ rails generate carpetbomb:uninstall
34
+ ~~~
35
+
36
+ Remove the gem from the Gemfile, and run bundle.
37
+
38
+ ## Usage
39
+
40
+ This gem adds three posible markdown template handlers to the existing Rails
41
+ template handlers:
42
+
43
+ `.md`, `.mdown` and `.markdown` all of them will work and will be parsed first
44
+ with Ruby on Rails erb template, so you can add whatever erb syntax you want.
45
+ After that it will be parsed by Redcarpet to handle the markdown part.
46
+
47
+ It's really simple to start using markdown templates. Create a view or rename it
48
+ to `viewname.html.md` and that's it.
49
+ ~~~erb
50
+ # viewname.html.md
51
+ <%= content_for :page_title, 'Ticketing - Index' %>
52
+
53
+ # Hi from the index page.
54
+
55
+ This is the home directory!
56
+ ~~~
57
+
58
+ ## Configuration
59
+
60
+ The configuration file for this gem in installed when you use the `rails generate carpetbomb:install`
61
+ command, and it's located in `config/initializers/carpetbomb.rb`. You can
62
+ change any Redcarpet options within that file.
63
+
64
+ You can check those options [here](https://github.com/vmg/redcarpet).
65
+
66
+ ## Contributions
67
+
68
+ Just send a pull request!
69
+
70
+ ## Thanks
71
+
72
+ Thanks to Lindsey Bieda for [this tutorial](http://rarlindseysmash.com/posts/how-to-gem-like-jem).
73
+ And to Joliss for her [markdown-rails](https://github.com/joliss/markdown-rails)
74
+ I practically copied the core of gem.
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/carpetbomb/version', __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "carpetbomb"
7
+ s.version = Carpetbomb::VERSION
8
+ s.authors = ["albertogg"]
9
+ s.email = ["albertogrespan@gmail.com"]
10
+ s.homepage = "https://github.com/albertogg/carpetbomb"
11
+ s.summary = %q{Markdown and erb template handler for Ruby on Rails using Redcarpet.}
12
+ s.description = %q{Markdown and erb (side by side) template handler for Ruby on Rails using Redcarpet.}
13
+
14
+ s.files = `git ls-files`.split($/)
15
+ s.require_path = %w[lib]
16
+ s.license = 'MIT'
17
+
18
+ s.add_dependency "redcarpet", "~> 3.0.0"
19
+ end
data/lib/carpetbomb.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'carpetbomb/engine'
2
+ require 'carpetbomb/version'
@@ -0,0 +1,40 @@
1
+ module Carpetbomb
2
+ class << self
3
+ attr_accessor :renderer
4
+ end
5
+
6
+ def self.configure
7
+ yield self
8
+ end
9
+
10
+ def self.render(&block)
11
+ self.renderer = block
12
+ end
13
+
14
+ class Handler
15
+ def initialize
16
+ end
17
+
18
+ def call(template)
19
+ # If the template has any erb tags in it, they will be parsed first.
20
+ # then with the result we call redcarpet to parse the markdown template.
21
+ erb = ActionView::Template.registered_template_handler(:erb)
22
+ source = erb.call(template)
23
+ <<-SOURCE
24
+ Carpetbomb.renderer.call(begin;#{source};end).html_safe
25
+ SOURCE
26
+ end
27
+ end
28
+ end
29
+
30
+ handler = Carpetbomb::Handler.new
31
+
32
+ [:md, :mdown, :markdown].each do |extension|
33
+ if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
34
+ ActionView::Template
35
+ elsif defined? ActionView::Template::Handlers and ActionView::Template::Handlers.respond_to? :register_template_handler
36
+ ActionView::Template::Handlers
37
+ else
38
+ raise "Couldn't find 'register_template_handler' method in ActionView module."
39
+ end.register_template_handler(extension, handler)
40
+ end
@@ -0,0 +1,3 @@
1
+ module Carpetbomb
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails/generators'
2
+
3
+ module Carpetbomb
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates Carpetbomb Initializer for your application"
9
+
10
+ def copy_initializer
11
+ template "carpetbomb.rb", "config/initializers/carpetbomb.rb"
12
+
13
+ puts "Install complete! please check config/initializers/carpetbomb.rb to customize Redcarpet options."
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module Carpetbomb
2
+ module Generators
3
+ class UninstallGenerator < Rails::Generators::Base
4
+
5
+ def uninstall_initializer
6
+ remove_file "config/initializers/carpetbomb.rb"
7
+
8
+ puts "Uninstall complete!"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ # If you want to add Redcarpet options, this is the file you need to use.
2
+ # Just follow the Redcarpet documentation and everything will be fine, or
3
+ # at least I hope so.
4
+ #
5
+ # Check the Redcarpet README for more information.
6
+ #
7
+ # https://github.com/vmg/redcarpet
8
+ #
9
+ Carpetbomb.configure do |config|
10
+
11
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
12
+ :autolink => true,
13
+ :space_after_headers => true,
14
+ :fenced_code_blocks => true)
15
+
16
+ config.render do |markdown_source|
17
+ markdown.render(markdown_source)
18
+ end
19
+ end
20
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carpetbomb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - albertogg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redcarpet
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ description: Markdown and erb (side by side) template handler for Ruby on Rails using
28
+ Redcarpet.
29
+ email:
30
+ - albertogrespan@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - .gitignore
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE
39
+ - README.md
40
+ - carpetbomb.gemspec
41
+ - lib/carpetbomb.rb
42
+ - lib/carpetbomb/engine.rb
43
+ - lib/carpetbomb/version.rb
44
+ - lib/generators/carpetbomb/install_generator.rb
45
+ - lib/generators/carpetbomb/uninstall_generator.rb
46
+ - lib/generators/templates/carpetbomb.rb
47
+ homepage: https://github.com/albertogg/carpetbomb
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.1.4
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Markdown and erb template handler for Ruby on Rails using Redcarpet.
71
+ test_files: []