mongoid-textile 0.1.1 → 0.2.0

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
@@ -14,3 +14,4 @@ spec/reports
14
14
  test/tmp
15
15
  test/version_tmp
16
16
  tmp
17
+ Gemfile.lock
@@ -1,7 +1,6 @@
1
1
  rvm:
2
- - 1.8.7
3
- - 1.9.2
4
2
  - 1.9.3
5
- - ruby-head
6
- - ree
7
- - rbx-18mode
3
+
4
+ gemfile:
5
+ - Gemfile
6
+ - gemfiles/mongoid-2.4.gemfile
@@ -1,3 +1,13 @@
1
+ ## 0.2.0 - July 11, 2012
2
+
3
+ ### Improvements
4
+
5
+ * Adding support to Mongoid 3.
6
+
7
+ ### Major Changes (Backwards Incompatible)
8
+
9
+ * Mongoid Textile no longer supports Ruby 1.8.7 and 1.9.2 (if you use Mongoid 3).
10
+
1
11
  ## 0.1.1 - March 30, 2012
2
12
 
3
13
  ### Resolved Issues
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Mongoid::Textile [![Build Status](https://secure.travis-ci.org/tiagogodinho/mongoid-textile.png)](http://travis-ci.org/tiagogodinho/mongoid-textile) [![Build Status](https://gemnasium.com/tiagogodinho/mongoid-textile.png?travis)](http://gemnasium.com/tiagogodinho/mongoid-textile)
1
+ # Mongoid::Textile [![Build Status](https://secure.travis-ci.org/tiagogodinho/mongoid-textile.png)](http://travis-ci.org/tiagogodinho/mongoid-textile) [![Build Status](https://gemnasium.com/tiagogodinho/mongoid-textile.png)](http://gemnasium.com/tiagogodinho/mongoid-textile)
2
2
 
3
3
  Textile texts directly from MongoDB.
4
4
 
@@ -35,6 +35,10 @@ article = Article.create(text: 'h1. Proud to be a rails developer')
35
35
  article.text_formatted #=> <h1>Proud to be a rails developer</h1>
36
36
  ```
37
37
 
38
+ ## Compatibility
39
+
40
+ Mongoid Textile is tested against Ruby 1.9.3.
41
+
38
42
  ## Contributing
39
43
 
40
44
  1. Fork it
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task :default => 'spec'
7
+ task default: 'spec'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'mongoid', '~> 2.4'
4
+
5
+ gem 'bson_ext', '~> 1.6.0'
6
+
7
+ gemspec path: '../'
@@ -1,28 +1,28 @@
1
- require "mongoid-textile/version"
2
- require "active_support/concern"
3
- require "mongoid"
4
- require "redcloth"
1
+ require 'mongoid-textile/version'
2
+ require 'active_support/concern'
3
+ require 'mongoid'
4
+ require 'redcloth'
5
5
 
6
6
  module Mongoid
7
7
  module Textile
8
8
  extend ActiveSupport::Concern
9
-
9
+
10
10
  included do
11
11
  before_save :textile_to_html
12
12
  end
13
-
13
+
14
14
  def textile_to_html
15
15
  textile_fields.each do |textile_field_name|
16
16
  field_name = textile_field_name.gsub(/_formatted/, '')
17
-
17
+
18
18
  if self.fields[field_name.to_s].localized?
19
19
  values = self.send("#{field_name}_translations") || {}
20
20
  formatted_text = {}
21
-
21
+
22
22
  values.each do |key, value|
23
23
  formatted_text[key.to_s] = RedCloth.new(value.to_s).to_html
24
24
  end
25
-
25
+
26
26
  self.send("#{textile_field_name}_translations=", formatted_text)
27
27
  else
28
28
  value = self.send(field_name)
@@ -31,18 +31,18 @@ module Mongoid
31
31
  end
32
32
  end
33
33
  end
34
-
34
+
35
35
  private
36
-
36
+
37
37
  def textile_fields
38
38
  fields.collect{ |field| field.first }.select{ |field_name| field_name =~ /\w+_formatted/ }
39
39
  end
40
-
40
+
41
41
  module ClassMethods
42
42
  def textlize(*fields)
43
43
  fields.each do |field_name|
44
44
  if self.fields[field_name.to_s].localized?
45
- field("#{field_name}_formatted", :localize => true)
45
+ field("#{field_name}_formatted", localize: true)
46
46
  else
47
47
  field("#{field_name}_formatted")
48
48
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Textile
3
- VERSION = '0.1.1'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -1,25 +1,23 @@
1
- # encoding: UTF-8
2
-
3
1
  require File.expand_path('../lib/mongoid-textile/version', __FILE__)
4
2
 
5
3
  Gem::Specification.new do |gem|
6
- gem.authors = ["Lucas Renan", "Tiago Rafael Godinho"]
7
- gem.email = ["contato@lucasrenan.com", "tiagogodinho3@gmail.com"]
4
+ gem.authors = ['Lucas Renan', 'Tiago Rafael Godinho']
5
+ gem.email = ['contato@lucasrenan.com', 'tiagogodinho3@gmail.com']
8
6
  gem.description = %q{Textile texts directly from MongoDB.}
9
7
  gem.summary = %q{Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.}
10
- gem.homepage = ""
8
+ gem.homepage = ''
11
9
 
12
10
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
11
  gem.files = `git ls-files`.split("\n")
14
12
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- gem.name = "mongoid-textile"
16
- gem.require_paths = ["lib"]
13
+ gem.name = 'mongoid-textile'
14
+ gem.require_paths = ['lib']
17
15
  gem.version = Mongoid::Textile::VERSION
18
-
19
- gem.add_dependency 'mongoid', '~> 2.4.0'
16
+
17
+ gem.add_dependency 'mongoid', '>= 2.4'
20
18
  gem.add_dependency 'RedCloth', '~> 4.2.0'
21
-
22
- gem.add_development_dependency 'bson_ext', '~> 1.6.1'
23
- gem.add_development_dependency 'rspec', '~> 2.9.0'
24
- gem.add_development_dependency 'rake', '~> 0.9.2'
19
+
20
+ gem.add_development_dependency 'database_cleaner', '~> 0.8'
21
+ gem.add_development_dependency 'rspec', '~> 2.9'
22
+ gem.add_development_dependency 'rake', '~> 0.9.2'
25
23
  end
@@ -1,86 +1,86 @@
1
1
  # encoding: utf-8
2
2
 
3
- require "spec_helper"
3
+ require 'spec_helper'
4
4
 
5
5
  class Article
6
6
  include Mongoid::Document
7
7
  include Mongoid::Textile
8
-
8
+
9
9
  field :text
10
-
10
+
11
11
  textlize :text
12
12
  end
13
13
 
14
14
  class Post
15
15
  include Mongoid::Document
16
16
  include Mongoid::Textile
17
-
18
- field :text, :localize => true
19
-
17
+
18
+ field :text, localize: true
19
+
20
20
  textlize :text
21
21
  end
22
22
 
23
23
  describe Mongoid::Textile do
24
- let(:article) { Article.create(:text => "h1. proud to be a rails developer") }
25
-
26
- it "should build a dynamic field for textilized fields" do
24
+ let(:article) { Article.create(text: 'h1. proud to be a rails developer') }
25
+
26
+ it 'should build a dynamic field for textilized fields' do
27
27
  article.should respond_to(:text_formatted)
28
28
  end
29
-
30
- it "should set formatted field from textile to html" do
31
- article.text_formatted.should eq("<h1>proud to be a rails developer</h1>")
29
+
30
+ it 'should set formatted field from textile to html' do
31
+ article.text_formatted.should eq('<h1>proud to be a rails developer</h1>')
32
32
  end
33
33
 
34
- it "should change textlized text" do
35
- article.text = "p. ruby makes me happy"
34
+ it 'should change textlized text' do
35
+ article.text = 'p. ruby makes me happy'
36
36
  article.save
37
37
 
38
- article.text_formatted.should eq("<p>ruby makes me happy</p>")
38
+ article.text_formatted.should eq('<p>ruby makes me happy</p>')
39
39
  end
40
-
41
- context "when text is nil" do
42
- let(:article) { Article.create(:text => nil) }
43
-
44
- it "should set formatted field with an empty string" do
45
- article.text_formatted.should eq("")
40
+
41
+ context 'when text is nil' do
42
+ let(:article) { Article.create(text: nil) }
43
+
44
+ it 'should set formatted field with an empty string' do
45
+ article.text_formatted.should eq('')
46
46
  end
47
47
  end
48
48
 
49
- context "when text is localized and is not present" do
49
+ context 'when text is localized and is not present' do
50
50
  let(:post) { Post.create }
51
51
 
52
- it "should set formatted translations field with an empty hash" do
52
+ it 'should set formatted translations field with an empty hash' do
53
53
  post.text_formatted_translations.should eq({})
54
54
  post.text_formatted.should eq(nil)
55
55
  end
56
56
  end
57
-
58
- context "when text is empty" do
59
- let(:article) { Article.create(:text => "") }
60
-
61
- it "should set formatted field with an empty string" do
62
- article.text_formatted.should eq("")
57
+
58
+ context 'when text is empty' do
59
+ let(:article) { Article.create(text: '') }
60
+
61
+ it 'should set formatted field with an empty string' do
62
+ article.text_formatted.should eq('')
63
63
  end
64
64
  end
65
-
65
+
66
66
  context 'multiple languages' do
67
- let(:post) { Post.create(:text_translations => { 'en' => 'h1. ruby makes me happy', 'de' => 'h1. ruby macht mich glücklich' }) }
68
-
67
+ let(:post) { Post.create(text_translations: { en: 'h1. ruby makes me happy', de: 'h1. ruby macht mich glücklich' }) }
68
+
69
69
  context 'in english' do
70
70
  before :all do
71
71
  I18n.locale = :en
72
72
  end
73
-
73
+
74
74
  it 'should set formatted field from textile to html' do
75
75
  post.text_formatted.should eq('<h1>ruby makes me happy</h1>')
76
76
  end
77
77
  end
78
-
78
+
79
79
  context 'in german' do
80
80
  before :all do
81
81
  I18n.locale = :de
82
82
  end
83
-
83
+
84
84
  it 'should set formatted field from textile to html' do
85
85
  post.text_formatted.should eq('<h1>ruby macht mich glücklich</h1>')
86
86
  end
@@ -1,29 +1,23 @@
1
- require "mongoid-textile"
1
+ require 'mongoid-textile'
2
+ require 'database_cleaner'
2
3
 
3
4
  RSpec.configure do |config|
4
- # Remove this line if you don"t want RSpec"s should and should_not
5
- # methods or matchers
6
- require "rspec/expectations"
7
- config.include RSpec::Matchers
5
+ config.before(:suite) do
6
+ if Mongoid.respond_to? :connect_to
7
+ Mongoid.connect_to('mongoid-textile') # Mongoid 3
8
+ else
9
+ Mongoid.master = Mongo::Connection.new.db('mongoid-textile') # Mongoid 2
10
+ end
8
11
 
9
- # == Mock Framework
10
- config.mock_with :rspec
11
-
12
- config.color_enabled = true
13
- config.full_backtrace = true
14
-
15
- config.before :suite do
16
- Mongoid.configure do |config|
17
- config.master = Mongo::Connection.new.db("mongoid-textile")
18
- end
12
+ DatabaseCleaner.strategy = :truncation
13
+ DatabaseCleaner.clean_with(:truncation)
19
14
  end
20
15
 
21
- config.after :each do
22
- Mongoid.master.collections.select {|c| c.name !~ /^system/ }.each(&:drop)
16
+ config.before(:each) do
17
+ DatabaseCleaner.start
23
18
  end
24
19
 
25
- config.after :suite do
26
- Mongoid.master.connection.drop_database("mongoid-textile")
27
- Mongoid.master.connection.close
20
+ config.after(:each) do
21
+ DatabaseCleaner.clean
28
22
  end
29
- end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-textile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,24 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-30 00:00:00.000000000 Z
13
+ date: 2012-07-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mongoid
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ~>
20
+ - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 2.4.0
22
+ version: '2.4'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ~>
28
+ - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 2.4.0
30
+ version: '2.4'
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: RedCloth
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -45,13 +45,13 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: 4.2.0
47
47
  - !ruby/object:Gem::Dependency
48
- name: bson_ext
48
+ name: database_cleaner
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.1
54
+ version: '0.8'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 1.6.1
62
+ version: '0.8'
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: rspec
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +67,7 @@ dependencies:
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: 2.9.0
70
+ version: '2.9'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: 2.9.0
78
+ version: '2.9'
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: rake
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -105,10 +105,10 @@ files:
105
105
  - .travis.yml
106
106
  - CHANGELOG.md
107
107
  - Gemfile
108
- - Gemfile.lock
109
108
  - LICENSE
110
109
  - README.md
111
110
  - Rakefile
111
+ - gemfiles/mongoid-2.4.gemfile
112
112
  - lib/mongoid-textile.rb
113
113
  - lib/mongoid-textile/version.rb
114
114
  - mongoid-textile.gemspec
@@ -126,15 +126,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
126
  - - ! '>='
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
+ segments:
130
+ - 0
131
+ hash: 4348872174340008729
129
132
  required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  none: false
131
134
  requirements:
132
135
  - - ! '>='
133
136
  - !ruby/object:Gem::Version
134
137
  version: '0'
138
+ segments:
139
+ - 0
140
+ hash: 4348872174340008729
135
141
  requirements: []
136
142
  rubyforge_project:
137
- rubygems_version: 1.8.19
143
+ rubygems_version: 1.8.24
138
144
  signing_key:
139
145
  specification_version: 3
140
146
  summary: Mongoid Textile caches Textile texts on MongoDB to eliminate reprocessing.
@@ -1,49 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mongoid-textile (0.1.0)
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.2.2)
13
- activesupport (= 3.2.2)
14
- builder (~> 3.0.0)
15
- activesupport (3.2.2)
16
- i18n (~> 0.6)
17
- multi_json (~> 1.0)
18
- bson (1.6.1)
19
- bson_ext (1.6.1)
20
- bson (~> 1.6.1)
21
- builder (3.0.0)
22
- diff-lcs (1.1.3)
23
- i18n (0.6.0)
24
- mongo (1.6.1)
25
- bson (~> 1.6.1)
26
- mongoid (2.4.7)
27
- activemodel (~> 3.1)
28
- mongo (~> 1.3)
29
- tzinfo (~> 0.3.22)
30
- multi_json (1.2.0)
31
- rake (0.9.2.2)
32
- rspec (2.9.0)
33
- rspec-core (~> 2.9.0)
34
- rspec-expectations (~> 2.9.0)
35
- rspec-mocks (~> 2.9.0)
36
- rspec-core (2.9.0)
37
- rspec-expectations (2.9.0)
38
- diff-lcs (~> 1.1.3)
39
- rspec-mocks (2.9.0)
40
- tzinfo (0.3.32)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- bson_ext (~> 1.6.1)
47
- mongoid-textile!
48
- rake (~> 0.9.2)
49
- rspec (~> 2.9.0)