jm81-dm-filters 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -0
- data/.gitignore +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +7 -3
- data/VERSION +1 -1
- data/dm-filters.gemspec +2 -2
- data/lib/dm-filters.rb +2 -2
- data/lib/filters/bible_ml.rb +20 -0
- data/lib/filters/linebreaker.rb +0 -0
- data/spec/dm-filters_spec.rb +0 -0
- data/spec/filters/bible_ml_spec.rb +14 -0
- data/spec/filters/fixtures/gen11/input.xml +0 -0
- data/spec/filters/fixtures/gen11/output.xml +0 -0
- data/spec/filters/linebreaker_spec.rb +0 -0
- data/spec/filters_resource_spec.rb +0 -0
- data/spec/spec_helper.rb +0 -0
- metadata +10 -6
data/.document
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
@@ -4,8 +4,12 @@ require 'rake'
|
|
4
4
|
begin
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "dm-filters"
|
8
|
-
gem.summary = %Q{
|
7
|
+
gem.name = "jm81-dm-filters"
|
8
|
+
gem.summary = %Q{Apply text filters to DataMapper properties}
|
9
|
+
gem.description = <<EOF
|
10
|
+
This module enables a property in a DataMapper::Resource class to be filtered
|
11
|
+
on save into another property, using per-row and/or per-property filters
|
12
|
+
EOF
|
9
13
|
gem.email = "jmorgan@morgancreative.net"
|
10
14
|
gem.homepage = "http://github.com/jm81/dm-filters"
|
11
15
|
gem.authors = ["Jared Morgan"]
|
@@ -13,7 +17,7 @@ begin
|
|
13
17
|
gem.add_dependency('dm-core', '>= 0.10.0')
|
14
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
19
|
end
|
16
|
-
|
20
|
+
Jeweler::GemcutterTasks.new
|
17
21
|
rescue LoadError
|
18
22
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
23
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/dm-filters.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-filters}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jared Morgan"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-10-02}
|
13
13
|
s.email = %q{jmorgan@morgancreative.net}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/lib/dm-filters.rb
CHANGED
@@ -11,7 +11,7 @@ require 'extlib'
|
|
11
11
|
# should be defined before to filtered property.
|
12
12
|
|
13
13
|
module Filters
|
14
|
-
VERSION = "0.
|
14
|
+
VERSION = "0.3.0"
|
15
15
|
|
16
16
|
# A hash, with each entry of the form:
|
17
17
|
# Filter name (used in +filters+ property) =>
|
@@ -20,7 +20,7 @@ module Filters
|
|
20
20
|
# Classes are assumed to respond to +to_html+.
|
21
21
|
AVAILABLE_FILTERS = {
|
22
22
|
'Smartypants' => [['rubypants', 'RubyPants']],
|
23
|
-
'Markdown' => [['rdiscount', 'RDiscount'], ['bluecloth', 'BlueCloth']],
|
23
|
+
'Markdown' => [['maruku', 'Maruku'], ['rdiscount', 'RDiscount'], ['bluecloth', 'BlueCloth']],
|
24
24
|
'Textile' => [['redcloth', 'RedCloth']],
|
25
25
|
'BibleML' => [[File.dirname(__FILE__) + '/filters/bible_ml', 'BibleML']],
|
26
26
|
'Linebreaker' => [[File.dirname(__FILE__) + '/filters/linebreaker', 'Linebreaker']],
|
data/lib/filters/bible_ml.rb
CHANGED
@@ -36,10 +36,12 @@ class BibleML
|
|
36
36
|
strip_comments.
|
37
37
|
block_quotes.
|
38
38
|
inline_quotes.
|
39
|
+
references.
|
39
40
|
wikipedia_links.
|
40
41
|
to_s
|
41
42
|
txt = RubyPants.new(txt).to_html
|
42
43
|
txt = RDiscount.new(txt).to_html
|
44
|
+
txt.gsub(/&amp;/, '&') # Get rid of double &'s
|
43
45
|
end
|
44
46
|
|
45
47
|
# Convert fg:pp tags to Primary Passage links
|
@@ -126,6 +128,24 @@ class BibleML
|
|
126
128
|
self
|
127
129
|
end
|
128
130
|
|
131
|
+
def references
|
132
|
+
@xml.elements.each("//fg:ref") do | ref_el |
|
133
|
+
label = ''
|
134
|
+
|
135
|
+
if ref_el.has_elements? || ref_el.has_text?
|
136
|
+
ref_el.children.each do | child |
|
137
|
+
label << child.to_s
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
label = label.empty? ? nil : label.to_s
|
142
|
+
a_tag = reference_a(ref_el.attributes['p'], ref_el.attributes['v'], label)
|
143
|
+
|
144
|
+
ref_el.parent.replace_child(ref_el, a_tag)
|
145
|
+
end
|
146
|
+
self
|
147
|
+
end
|
148
|
+
|
129
149
|
def wikipedia_links
|
130
150
|
@xml.elements.each("//fg:wp") do | wp_el |
|
131
151
|
a = REXML::Element.new("a")
|
data/lib/filters/linebreaker.rb
CHANGED
File without changes
|
data/spec/dm-filters_spec.rb
CHANGED
File without changes
|
@@ -68,6 +68,20 @@ describe BibleML do
|
|
68
68
|
"<a href='http://www.biblegateway.com/passage/?search=exodus%205'>Full Chapter</a>"
|
69
69
|
end
|
70
70
|
|
71
|
+
it "should convert fg:ref tag without label to link" do
|
72
|
+
BibleML.new('<fg:ref p="Exodus 5:1-5" />').
|
73
|
+
references.
|
74
|
+
to_s.should ==
|
75
|
+
"<a href='http://www.biblegateway.com/passage/?search=exodus%205:1-5'>Exodus 5:1-5</a>"
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should convert fg:ref tag with label to link" do
|
79
|
+
BibleML.new('<fg:ref p="Exodus 5:1-5">This passage</fg:ref>').
|
80
|
+
references.
|
81
|
+
to_s.should ==
|
82
|
+
"<a href='http://www.biblegateway.com/passage/?search=exodus%205:1-5'>This passage</a>"
|
83
|
+
end
|
84
|
+
|
71
85
|
it "should create link from reference with verses" do
|
72
86
|
BibleML.new('').bg_link("Genesis 1:10").should ==
|
73
87
|
"http://www.biblegateway.com/passage/?search=genesis%201:10"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jm81-dm-filters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Morgan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-03 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,10 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.10.0
|
34
34
|
version:
|
35
|
-
description:
|
35
|
+
description: |
|
36
|
+
This module enables a property in a DataMapper::Resource class to be filtered
|
37
|
+
on save into another property, using per-row and/or per-property filters
|
38
|
+
|
36
39
|
email: jmorgan@morgancreative.net
|
37
40
|
executables: []
|
38
41
|
|
@@ -61,7 +64,8 @@ files:
|
|
61
64
|
- spec/spec_helper.rb
|
62
65
|
has_rdoc: true
|
63
66
|
homepage: http://github.com/jm81/dm-filters
|
64
|
-
licenses:
|
67
|
+
licenses: []
|
68
|
+
|
65
69
|
post_install_message:
|
66
70
|
rdoc_options:
|
67
71
|
- --charset=UTF-8
|
@@ -84,8 +88,8 @@ requirements: []
|
|
84
88
|
rubyforge_project:
|
85
89
|
rubygems_version: 1.3.5
|
86
90
|
signing_key:
|
87
|
-
specification_version:
|
88
|
-
summary:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Apply text filters to DataMapper properties
|
89
93
|
test_files:
|
90
94
|
- spec/dm-filters_spec.rb
|
91
95
|
- spec/filters/bible_ml_spec.rb
|