mongoid-textile 0.0.1

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,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.0.1 (2012-01-11)
2
+
3
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'bson_ext'
4
+ gem 'rake'
5
+
6
+ # Specify your gem's dependencies in mongoid-textile.gemspec
7
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongoid-textile (0.0.1)
5
+ RedCloth (>= 4.2.0)
6
+ mongoid (>= 2.4.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ RedCloth (4.2.9)
12
+ activemodel (3.1.3)
13
+ activesupport (= 3.1.3)
14
+ builder (~> 3.0.0)
15
+ i18n (~> 0.6)
16
+ activesupport (3.1.3)
17
+ multi_json (~> 1.0)
18
+ bson (1.5.2)
19
+ bson_ext (1.5.2)
20
+ bson (= 1.5.2)
21
+ builder (3.0.0)
22
+ diff-lcs (1.1.3)
23
+ i18n (0.6.0)
24
+ mongo (1.5.2)
25
+ bson (= 1.5.2)
26
+ mongoid (2.4.0)
27
+ activemodel (~> 3.1)
28
+ mongo (~> 1.3)
29
+ tzinfo (~> 0.3.22)
30
+ multi_json (1.0.4)
31
+ rake (0.9.2.2)
32
+ rspec (2.8.0)
33
+ rspec-core (~> 2.8.0)
34
+ rspec-expectations (~> 2.8.0)
35
+ rspec-mocks (~> 2.8.0)
36
+ rspec-core (2.8.0)
37
+ rspec-expectations (2.8.0)
38
+ diff-lcs (~> 1.1.2)
39
+ rspec-mocks (2.8.0)
40
+ tzinfo (0.3.31)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bson_ext
47
+ mongoid-textile!
48
+ rake
49
+ rspec (= 2.8.0)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Lucas Renan e Tiago Rafael Godinho
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,52 @@
1
+ # Mongoid::Textile
2
+
3
+ Textile texts directly from MongoDB.
4
+
5
+ Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'mongoid-textile'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install mongoid-textile
20
+
21
+ ## Usage
22
+
23
+ ``` ruby
24
+ class Article
25
+ include Mongoid::Document
26
+
27
+ field :text
28
+
29
+ textlize :text
30
+ end
31
+
32
+ article = Article.create(text: 'h1. Proud to be a rails developer')
33
+
34
+ article.text_formatted #=> <h1>Proud to be a rails developer</h1>
35
+ ```
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
44
+
45
+ ## Maintainers
46
+
47
+ * Lucas Renan (https://github.com/lucasrenan)
48
+ * Tiago Rafael Godinho (https://github.com/tiagogodinho)
49
+
50
+ ## License
51
+
52
+ MIT License. Copyright 2012 Lucas Renan e Tiago Rafael Godinho
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: 'spec'
@@ -0,0 +1,32 @@
1
+ require "mongoid-textile/version"
2
+ require 'active_support/concern'
3
+ require 'mongoid'
4
+ require 'redcloth'
5
+
6
+ module Mongoid
7
+ module Textile
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ before_save :textile_to_html
12
+ end
13
+
14
+ module InstanceMethods
15
+ def textile_to_html
16
+ textile_fields = fields.collect{|f| f.first}.select{|f| f =~ /\w+_formatted/}
17
+ textile_fields.each do |f|
18
+ value = self.send(f.split(/(\w+)_formatted/).reject(&:blank?).first).nil? ? "" : self.send(f.split(/(\w+)_formatted/).reject(&:blank?).first)
19
+ self.send "#{f}=".to_sym, RedCloth.new(value).to_html
20
+ end
21
+ end
22
+ end
23
+
24
+ module ClassMethods
25
+ def textlize(*fields)
26
+ fields.each do |f|
27
+ field("#{f}_formatted")
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Mongoid
2
+ module Textile
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/mongoid-textile/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Lucas Renan", "Tiago Rafael Godinho"]
6
+ gem.email = ["contato@lucasrenan.com", "tiagogodinho3@gmail.com"]
7
+ gem.description = %q{Textile texts directly from MongoDB.}
8
+ gem.summary = %q{Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "mongoid-textile"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Mongoid::Textile::VERSION
17
+
18
+ gem.add_dependency 'RedCloth', '>= 4.2.0'
19
+ gem.add_dependency 'mongoid', '>= 2.4.0'
20
+
21
+ gem.add_development_dependency 'rspec', '2.8.0'
22
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ Mongoid.configure do |config|
4
+ config.master = Mongo::Connection.new.db('mongoid-textile')
5
+ end
6
+
7
+ class Article
8
+ include Mongoid::Document
9
+ include Mongoid::Textile
10
+
11
+ field :text
12
+
13
+ textlize :text
14
+ end
15
+
16
+ describe Mongoid::Textile do
17
+ let(:article) { Article.create(text: 'h1. proud to be a rails developer') }
18
+
19
+ it 'should build a dynamic field for textilized fields' do
20
+ article.should respond_to(:text_formatted)
21
+ end
22
+
23
+ it 'should set formatted field from textile to html' do
24
+ article.text_formatted.should eq('<h1>proud to be a rails developer</h1>')
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'mongoid-textile'
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid-textile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lucas Renan
9
+ - Tiago Rafael Godinho
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-01-12 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: RedCloth
17
+ requirement: &2156040280 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 4.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2156040280
26
+ - !ruby/object:Gem::Dependency
27
+ name: mongoid
28
+ requirement: &2156039600 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2156039600
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &2156039020 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - =
43
+ - !ruby/object:Gem::Version
44
+ version: 2.8.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2156039020
48
+ description: Textile texts directly from MongoDB.
49
+ email:
50
+ - contato@lucasrenan.com
51
+ - tiagogodinho3@gmail.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - .gitignore
57
+ - .rspec
58
+ - CHANGELOG.md
59
+ - Gemfile
60
+ - Gemfile.lock
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - lib/mongoid-textile.rb
65
+ - lib/mongoid-textile/version.rb
66
+ - mongoid-textile.gemspec
67
+ - spec/mongoid-textile_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: ''
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.13
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.
93
+ test_files:
94
+ - spec/mongoid-textile_spec.rb
95
+ - spec/spec_helper.rb