pdzioba-areeya_textile 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2009 Paweł Dzioba
2
+
3
+ Niniejszym gwarantuje się, bez opłat, że każda osoba, która wejdzie w
4
+ posiadanie kopii tego oprogramowania i związanych z nim plików dokumentacji
5
+ (dalej „Oprogramowanie”) może wprowadzać do obrotu Oprogramowanie bez
6
+ żadnych ograniczeń, w tym bez ograniczeń prawa do użytkowania, kopiowania,
7
+ modyfikowania, łączenia, publikowania, dystrybuowania, sublicencjonowania
8
+ i/lub sprzedaży kopii Oprogramowania a także zezwalania osobie, której
9
+ Oprogramowanie zostało dostarczone czynienia tego samego, z zastrzeżeniem
10
+ następujących warunków:
11
+
12
+ Powyższa nota zastrzegająca prawa autorskie oraz niniejsza nota zezwalająca
13
+ muszą zostać włączone do wszystkich kopii lub istotnych części Oprogramowania.
14
+
15
+ Oprogramowanie jest dostarczone takim, jakie jest, bez jakiejkolwiek gwarancji,
16
+ wyraźnej lub dorozumianej, nie wyłączając gwarancji przydatności handlowej lub
17
+ przydatności do określonych celów a także braku wad prawnych. W żadnym przypadku
18
+ twórca lub posiadacz praw autorskich nie może ponosić odpowiedzialności z tytułu
19
+ roszczeń lub wyrządzonej szkody a także żadnej innej odpowiedzialności czy to
20
+ wynikającej z umowy, deliktu, czy jakiejkolwiek innej podstawy powstałej w
21
+ związku z oprogramowaniem lub użytkowaniem go lub wprowadzaniem go do obrotu.
data/README.rdoc ADDED
@@ -0,0 +1,37 @@
1
+ = areeya_textile
2
+
3
+ Prosty plugin do obsługi Textile w modelach ActiveRecord. Wymaga RedCloth[http://redcloth.org] oraz RSpec.
4
+
5
+ Paweł Dzioba <pdzioba@me.com>
6
+
7
+ GitHub Projekt: http://github.com/pdzioba/areeya_textile
8
+
9
+ == Instalacja:
10
+
11
+ Jako plugin:
12
+
13
+ script/plugin install git://github.com/pdzioba/areeya_textile.git
14
+
15
+ Jako gem:
16
+
17
+ sudo gem install pdzioba-areeya_textile --source=http://gems.github.com
18
+
19
+ lub wpisując w config/environment.rb w aplikacji:
20
+
21
+ Rails::Initializer.run do |config|
22
+ ...
23
+ config.gem "RedCloth", :version => ">= 4.1.1", :source => "http://code.whytheluckystiff.net"
24
+ config.gem 'pdzioba-areeya_textile', :lib => 'areeya_textile', :source => 'http://gems.github.com'
25
+ ...
26
+ end
27
+
28
+ == Wykorzystanie:
29
+
30
+ class Page < ActiveRecord::Base
31
+ acts_as_textile :body
32
+ end
33
+
34
+ @page = Page.find(:first)
35
+ @page.body.to_s #=> "h2. Textile Headline"
36
+ @page.body.to_html #=> "<h2>Textile Headline</h2>"
37
+
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{areeya_textile}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Pawe\305\202 Dzioba"]
9
+ s.date = %q{2009-01-18}
10
+ s.description = %q{Prosty plugin do obsługi Textile w modelach ActiveRecord.}
11
+ s.email = %q{pdzioba@me.com}
12
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ s.files = ["init.rb", "LICENSE", "README.rdoc", "areeya_textile.gemspec", "lib/areeya_textile.rb", "lib/model_extensions.rb", "rails/init.rb", "spec/model_extensions_spec.rb", "spec/schema.rb", "spec/spec_helper.rb"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/pdzioba/areeya_textile}
16
+ s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--charset=UTF-8"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = %q{1.3.1}
19
+ s.summary = %q{}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 2
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), "rails", "init")
@@ -0,0 +1,3 @@
1
+ module AreeyaTextile; end
2
+
3
+ require File.dirname(__FILE__) + '/model_extensions'
@@ -0,0 +1,26 @@
1
+ require 'redcloth'
2
+
3
+ module AreeyaTextile::ModelExtensions
4
+ module ActsMethods
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ def acts_as_textile(*columns)
11
+ columns.each do |col|
12
+ class_eval <<-EOV
13
+ def #{col.to_s}
14
+ if @#{col.to_s}
15
+ unless self.#{col.to_s}_changed?
16
+ return @#{col.to_s}
17
+ end
18
+ end
19
+ @#{col.to_s} = RedCloth.new(self['#{col.to_s}'].to_s)
20
+ end
21
+ EOV
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ require File.dirname(__FILE__) + '/../lib/areeya_textile'
2
+
3
+ ActiveRecord::Base.send(:include, AreeyaTextile::ModelExtensions::ActsMethods)
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ class Page < ActiveRecord::Base
4
+ acts_as_textile :content
5
+ end
6
+
7
+ describe 'Atrybut z acts_as_textile' do
8
+ before(:each) do
9
+ @page = Page.create(:name => 'Title', :content => 'h2. Textile Test Text')
10
+ end
11
+
12
+ it "powinien zwrócić obiekt RedCloth::TextileDoc" do
13
+ @page.content.class.should == RedCloth::TextileDoc
14
+ end
15
+
16
+ it "powinien zwrócić oryginalną zawartość przy wywołaniu .to_s" do
17
+ @page.content.to_s.should == 'h2. Textile Test Text'
18
+ end
19
+
20
+ it "powinien zwrócić przetworzoną zawartość przy wywołaniu .to_html" do
21
+ @page.content.to_html.should == '<h2>Textile Test Text</h2>'
22
+ end
23
+ end
data/spec/schema.rb ADDED
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :pages, :force => true do |t|
3
+ t.string :name
4
+ t.string :content
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ begin
2
+ require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
3
+ rescue LoadError
4
+ puts "Plugin wymaga zainstalowania rspec'a w aplikacji."
5
+ exit
6
+ end
7
+
8
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
9
+
10
+ load(File.join(File.dirname(__FILE__), "schema.rb"))
11
+
12
+ Object.send(:remove_const, :Page) if defined?(Page)
13
+
14
+ Spec::Runner.configure do |config|
15
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdzioba-areeya_textile
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - "Pawe\xC5\x82 Dzioba"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-18 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "Prosty plugin do obs\xC5\x82ugi Textile w modelach ActiveRecord."
17
+ email: pdzioba@me.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.rdoc
25
+ files:
26
+ - init.rb
27
+ - LICENSE
28
+ - README.rdoc
29
+ - areeya_textile.gemspec
30
+ - lib/areeya_textile.rb
31
+ - lib/model_extensions.rb
32
+ - rails/init.rb
33
+ - spec/model_extensions_spec.rb
34
+ - spec/schema.rb
35
+ - spec/spec_helper.rb
36
+ has_rdoc: true
37
+ homepage: http://github.com/pdzioba/areeya_textile
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --main
41
+ - README.rdoc
42
+ - --inline-source
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.2.0
62
+ signing_key:
63
+ specification_version: 2
64
+ summary: ""
65
+ test_files: []
66
+