autopage 0.0.3 → 0.0.4
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/History.txt +16 -0
- data/Manifest.txt +12 -0
- data/README.rdoc +48 -0
- data/Rakefile +28 -0
- data/TODO +1 -0
- data/config/website.yml +2 -0
- data/lib/autopage.rb +66 -0
- data/lib/init.rb +1 -0
- data/spec/autopage_spec.rb +31 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +18 -5
data/History.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
== 0.0.4 2009-04-15
|
2
|
+
|
3
|
+
* 1 fix manifest bug which cause gem without content
|
4
|
+
replace 'rake gem' with [ find . -type f | egrep -v "(.git\/|nbproject\/|pkg\/|script\/|\.gitignore$|\.gem$)" | sed 's/\.\///g' > Manifest.txt ]
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
== 0.0.2 2009-04-14
|
9
|
+
|
10
|
+
* 1 fix spec bug
|
11
|
+
* include init.rb to make this gem suitable for rails plugin
|
12
|
+
|
13
|
+
== 0.0.1 2009-04-13
|
14
|
+
|
15
|
+
* 1 major enhancement:
|
16
|
+
* Initial release
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= auto_page
|
2
|
+
|
3
|
+
* http://autopage.rubyforge.org
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A Rails Plugin to autogenerate long text content to multipage.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* can not install idstab jquery plugin during gem installation.
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
<%= @blog.content.tab_page(300) %>
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* require install jrails plugin
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* gem install autopage
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2009 Eiffel Q
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/autopage'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('autopage', Autopage::VERSION) do |p|
|
7
|
+
p.developer('eiffel qiu', 'eiffelqiu@gmail.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.rubyforge_name = p.name # TODO this is default value
|
10
|
+
# p.extra_deps = [
|
11
|
+
# ['activesupport','>= 2.0.2'],
|
12
|
+
# ]
|
13
|
+
p.need_tar = false
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"]
|
16
|
+
]
|
17
|
+
|
18
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
19
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
20
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
21
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
|
+
|
27
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
28
|
+
# task :default => [:spec, :features]
|
data/TODO
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
replace 'rake gem' with [ find . -type f | egrep -v "(.git\/|nbproject\/|pkg\/|script\/|\.gitignore$|\.gem$)" | sed 's/\.\///g' > Manifest.txt ]
|
data/config/website.yml
ADDED
data/lib/autopage.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
##
|
5
|
+
# A Rails Plugin to autogenerate long text content to multipage.
|
6
|
+
#
|
7
|
+
module Autopage
|
8
|
+
VERSION = '0.0.4'
|
9
|
+
|
10
|
+
def self.included(base)
|
11
|
+
base.extend ClassMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Split String into array with fixed length characters
|
16
|
+
#
|
17
|
+
# "xxxxxxxxx".split_page(3) #=> ['xxx','xxx','xxx']
|
18
|
+
#
|
19
|
+
# @return [Array]
|
20
|
+
#
|
21
|
+
# @api public
|
22
|
+
def split_page(width=200)
|
23
|
+
scan(/.{1,#{width}}/u)
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Split String into array with fixed length characters and
|
28
|
+
# wrapped into jQuery tabs by idsTab plugin
|
29
|
+
#
|
30
|
+
# "xxxxxx".split_page(3) #=> '<ul class="idTabs"><li><a href='#page1'>1</a></li><li><a href='#page2'>2</a></li></ul><div id='page1'>xxx</div><div id='page2'>xxx</div>'
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
#
|
34
|
+
# @api public
|
35
|
+
def tab_page(width=200)
|
36
|
+
tabs = split_page(width)
|
37
|
+
ret = %{<ul class='idTabs'>}
|
38
|
+
tabs.each_with_index do |p,n|
|
39
|
+
ret += %{<li><a href='#page#{n+1}'>#{n+1}</a></li>}
|
40
|
+
end
|
41
|
+
ret += '</ul>'
|
42
|
+
tabs.each_with_index do |p,n|
|
43
|
+
ret += %{<div id='page#{n+1}'>#{p}</div>}
|
44
|
+
end
|
45
|
+
ret.strip.chomp
|
46
|
+
end
|
47
|
+
|
48
|
+
module ClassMethods
|
49
|
+
##
|
50
|
+
# Split String into array with fixed length characters, provide a class method for convinience
|
51
|
+
#
|
52
|
+
# "xxxxxxxxx".split_page(3) #=> ['xxx','xxx','xxx']
|
53
|
+
#
|
54
|
+
# @return [Array]
|
55
|
+
#
|
56
|
+
# @api public
|
57
|
+
def split_page(content, width=200)
|
58
|
+
content.scan(/.{1,#{width}}/u)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
class String
|
65
|
+
include Autopage
|
66
|
+
end
|
data/lib/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'autopage'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
class String
|
4
|
+
include Autopage
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "autopage" do
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
@array = "xxxxxx".split_page(3)
|
11
|
+
@array1 = "xxxxxx".split_page(5)
|
12
|
+
@array2 = "xxxxxx".split_page(10)
|
13
|
+
@htmlStr = "xxxxxx".tab_page(3)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#split_page' do
|
17
|
+
it 'split_page should return an array' do
|
18
|
+
@array.should be_kind_of(Array)
|
19
|
+
@array.should == ['xxx','xxx']
|
20
|
+
@array1.should == ['xxxxx','x']
|
21
|
+
@array2.should == ['xxxxxx']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#tab_page' do
|
26
|
+
it 'tab_page should return an html tab code' do
|
27
|
+
@htmlStr.should be_kind_of(String)
|
28
|
+
@htmlStr.strip.should == %{<ul class='idTabs'><li><a href='#page1'>1</a></li><li><a href='#page2'>2</a></li></ul><div id='page1'>xxx</div><div id='page2'>xxx</div>}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autopage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eiffel qiu
|
@@ -39,10 +39,23 @@ executables: []
|
|
39
39
|
|
40
40
|
extensions: []
|
41
41
|
|
42
|
-
extra_rdoc_files:
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
extra_rdoc_files:
|
43
|
+
- Manifest.txt
|
44
|
+
- README.rdoc
|
45
|
+
- History.txt
|
46
|
+
files:
|
47
|
+
- Manifest.txt
|
48
|
+
- Rakefile
|
49
|
+
- README.rdoc
|
50
|
+
- tasks/rspec.rake
|
51
|
+
- spec/autopage_spec.rb
|
52
|
+
- spec/spec.opts
|
53
|
+
- spec/spec_helper.rb
|
54
|
+
- lib/init.rb
|
55
|
+
- lib/autopage.rb
|
56
|
+
- config/website.yml
|
57
|
+
- History.txt
|
58
|
+
- TODO
|
46
59
|
has_rdoc: true
|
47
60
|
homepage: http://autopage.rubyforge.org
|
48
61
|
post_install_message:
|