shortcode 0.1.1 → 0.1.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 CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .DS_Store
19
+ gemfiles/*.lock
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - ruby-head
8
+ - jruby-19mode
9
+ - jruby-head
10
+ script: bundle exec rspec
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ - rvm: jruby-head
16
+ exclude:
17
+ - rvm: 1.9.2
18
+ gemfile: gemfiles/rails_4.0.gemfile
19
+
20
+ gemfile:
21
+ - gemfiles/rails_3.0.gemfile
22
+ - gemfiles/rails_3.1.gemfile
23
+ - gemfiles/rails_3.2.gemfile
24
+ - gemfiles/rails_4.0.gemfile
data/Appraisals ADDED
@@ -0,0 +1,15 @@
1
+ appraise "rails-3.0" do
2
+ gem "rails", "~> 3.0.20"
3
+ end
4
+
5
+ appraise "rails-3.1" do
6
+ gem "rails", "~> 3.1.12"
7
+ end
8
+
9
+ appraise "rails-3.2" do
10
+ gem "rails", "~> 3.2.17"
11
+ end
12
+
13
+ appraise "rails-4.0" do
14
+ gem "rails", "~> 4.0.3"
15
+ end
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in shortcode.gemspec
4
4
  gemspec
5
+
6
+ gem "appraisal", "1.0.0.beta3"
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Shortcode
2
2
 
3
+ [![Build Status](https://travis-ci.org/kernow/shortcode.png?branch=master)](https://travis-ci.org/kernow/shortcode)
4
+
3
5
  A ruby gem for parsing Wordpress style shortcodes. The gem uses a [PEG](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (Parsing Expression Grammar) parser rather than using regular expressions so its easier to understand, test and extend.
4
6
 
5
7
  ## Installation
@@ -99,7 +101,7 @@ Sometimes the data passed to the template from the shortcode it not enough. Lets
99
101
  In a rails app you could return image records to the template using something like this:
100
102
 
101
103
  ```ruby
102
- class CustomPrsenter
104
+ class CustomPresenter
103
105
 
104
106
  def self.for
105
107
  :quote
@@ -121,7 +123,7 @@ class CustomPrsenter
121
123
  private
122
124
 
123
125
  def images
124
- @attributes.ids.split(',').collect { |n| Image.find(n) }
126
+ Image.where("id IN (?)", @attributes[:ids])
125
127
  end
126
128
  end
127
129
  ```
@@ -131,7 +133,7 @@ end
131
133
  To register a presenter simply call `Shortcode.register_presenter` passing the presenter class e.g.
132
134
 
133
135
  ```ruby
134
- Shortcode.register_presenter(CustomPrsenter)
136
+ Shortcode.register_presenter(CustomPresenter)
135
137
  ```
136
138
 
137
139
  ## Contributing
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "1.0.0.beta3"
6
+ gem "rails", "~> 3.0.20"
7
+
8
+ gemspec :path=>".././"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "1.0.0.beta3"
6
+ gem "rails", "~> 3.1.12"
7
+
8
+ gemspec :path=>".././"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "1.0.0.beta3"
6
+ gem "rails", "~> 3.2.17"
7
+
8
+ gemspec :path=>".././"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", "1.0.0.beta3"
6
+ gem "rails", "~> 4.0.3"
7
+
8
+ gemspec :path=>".././"
data/lib/shortcode.rb CHANGED
@@ -6,8 +6,7 @@ module Shortcode
6
6
  extend self
7
7
 
8
8
  attr_accessor :configuration, :presenters
9
- @@presenters = {}
10
-
9
+ self.presenters = {}
11
10
 
12
11
  def setup
13
12
  self.configuration ||= Configuration.new
@@ -41,4 +40,6 @@ require 'shortcode/presenter'
41
40
  require 'shortcode/transformer'
42
41
  require 'shortcode/tag'
43
42
  require 'shortcode/exceptions'
44
- require 'shortcode/railtie' if defined?(Rails)
43
+ require 'shortcode/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
44
+
45
+ Shortcode.setup {}
@@ -1,17 +1,20 @@
1
1
  class Shortcode::Configuration
2
2
  # Sets the template parser to use, supports :erb and :haml, default is :haml
3
3
  attr_accessor :template_parser
4
- @template_parser = :haml
5
4
 
6
5
  # Sets the template parser to use, supports :erb and :haml, default is :haml
7
6
  attr_accessor :template_path
8
- @template_path = "app/views/shortcode_templates"
9
7
 
10
8
  # Set the supported block_tags
11
9
  attr_accessor :block_tags
12
- @block_tags = [:quote]
13
10
 
14
11
  # Set the supported self_closing_tags
15
12
  attr_accessor :self_closing_tags
16
- @self_closing_tags = [:youtube]
13
+
14
+ def initialize
15
+ @template_parser = :haml
16
+ @template_path = "app/views/shortcode_templates"
17
+ @block_tags = []
18
+ @self_closing_tags = []
19
+ end
17
20
  end
@@ -1,3 +1,3 @@
1
1
  module Shortcode
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/shortcode.gemspec CHANGED
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "rspec"
27
- spec.add_development_dependency "rails", "~> 4"
28
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shortcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-23 00:00:00.000000000 Z
12
+ date: 2014-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parslet
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rails
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: '4'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: '4'
110
94
  description: Gem for parsing wordpress style shortcodes
111
95
  email:
112
96
  - jamie@kernowsoul.com
@@ -116,10 +100,16 @@ extra_rdoc_files: []
116
100
  files:
117
101
  - .gitignore
118
102
  - .rbenv-version
103
+ - .travis.yml
104
+ - Appraisals
119
105
  - Gemfile
120
106
  - LICENSE.txt
121
107
  - README.md
122
108
  - Rakefile
109
+ - gemfiles/rails_3.0.gemfile
110
+ - gemfiles/rails_3.1.gemfile
111
+ - gemfiles/rails_3.2.gemfile
112
+ - gemfiles/rails_4.0.gemfile
123
113
  - lib/shortcode.rb
124
114
  - lib/shortcode/configuration.rb
125
115
  - lib/shortcode/exceptions.rb