par 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.markdown +73 -0
- data/Rakefile +5 -0
- data/lib/par.rb +13 -0
- data/par.gemspec +10 -0
- data/test/helper.rb +24 -0
- data/test/par_test.rb +31 -0
- metadata +73 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Damian Janowski & Michel Martens
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
Par
|
2
|
+
===
|
3
|
+
|
4
|
+
Paragraph reformatter.
|
5
|
+
|
6
|
+
Description
|
7
|
+
-----------
|
8
|
+
|
9
|
+
Par is a lightweight binding for [par](http://www.nicemice.net/par/), a
|
10
|
+
handy Unix tool for formatting paragraphs.
|
11
|
+
|
12
|
+
Note that you need to have the command line tool installed. On Mac OSX,
|
13
|
+
it may be as easy as executing `sudo port install par`. On Debian, try
|
14
|
+
`sudo apt-get install par`.
|
15
|
+
|
16
|
+
Usage
|
17
|
+
-----
|
18
|
+
|
19
|
+
Check this couple tests to see how it works.
|
20
|
+
|
21
|
+
class ParTest < Test::Unit::TestCase
|
22
|
+
test "should format the paragraphs to the default 60 characters wide" do
|
23
|
+
source = "Similique quibusdam consectetur provident sit aut in. Quia dolorem qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam voluptatem autem in."
|
24
|
+
|
25
|
+
assert_equal <<-EOS, Par.new(source)
|
26
|
+
Similique quibusdam consectetur provident sit aut in. Quia dolorem
|
27
|
+
qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis
|
28
|
+
eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam
|
29
|
+
voluptatem autem in.
|
30
|
+
EOS
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should relay the passed parameters to par" do
|
34
|
+
assert_equal <<-EOS, Par.new(" #{source}", :p => 2)
|
35
|
+
Similique quibusdam consectetur provident sit aut in. Quia dolorem
|
36
|
+
qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis
|
37
|
+
eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam
|
38
|
+
voluptatem autem in.
|
39
|
+
EOS
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
Installation
|
45
|
+
------------
|
46
|
+
|
47
|
+
$ gem install par
|
48
|
+
|
49
|
+
License
|
50
|
+
-------
|
51
|
+
|
52
|
+
Copyright (c) 2010 Damian Janowski & Michel Martens
|
53
|
+
|
54
|
+
Permission is hereby granted, free of charge, to any person
|
55
|
+
obtaining a copy of this software and associated documentation
|
56
|
+
files (the "Software"), to deal in the Software without
|
57
|
+
restriction, including without limitation the rights to use,
|
58
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
59
|
+
copies of the Software, and to permit persons to whom the
|
60
|
+
Software is furnished to do so, subject to the following
|
61
|
+
conditions:
|
62
|
+
|
63
|
+
The above copyright notice and this permission notice shall be
|
64
|
+
included in all copies or substantial portions of the Software.
|
65
|
+
|
66
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
67
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
68
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
69
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
70
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
71
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
72
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
73
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/lib/par.rb
ADDED
data/par.gemspec
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "par"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.summary = "Paragraph reformatter."
|
5
|
+
s.description = "Par is a lightweight binding for par, a handy Unix tool for formatting paragraphs."
|
6
|
+
s.authors = ["Damian Janowski", "Michel Martens"]
|
7
|
+
s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
|
8
|
+
s.homepage = "http://github.com/djanowski/par"
|
9
|
+
s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/par.rb", "par.gemspec", "test/helper.rb", "test/par_test.rb"]
|
10
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "par")
|
4
|
+
|
5
|
+
def assert(value)
|
6
|
+
return if value
|
7
|
+
|
8
|
+
file, line = caller[0].split(":")
|
9
|
+
code = File.readlines(file)[line.to_i - 1]
|
10
|
+
|
11
|
+
puts " ✗ #{code.strip}"
|
12
|
+
puts " #{file}:#{line}"
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup(&block)
|
17
|
+
@_setup = block
|
18
|
+
end
|
19
|
+
|
20
|
+
def test(name = nil, &block)
|
21
|
+
@_test = name
|
22
|
+
|
23
|
+
block.call(@_setup.call)
|
24
|
+
end
|
data/test/par_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), "helper")
|
4
|
+
|
5
|
+
setup do
|
6
|
+
"Similique quibusdam consectetur provident sit aut in. Quia dolorem qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam voluptatem autem in."
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should format the paragraphs to the default 60 characters wide" do |source|
|
10
|
+
expected = <<-EOS
|
11
|
+
Similique quibusdam consectetur provident sit aut in. Quia dolorem
|
12
|
+
qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis
|
13
|
+
eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam
|
14
|
+
voluptatem autem in.
|
15
|
+
EOS
|
16
|
+
|
17
|
+
assert Par.new(source) == expected
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should relay the passed parameters to par" do |source|
|
21
|
+
expected = <<-EOS
|
22
|
+
Similique quibusdam consectetur provident sit aut in. Quia dolorem
|
23
|
+
qui nihil expedita quod. Doloremque nobis et labore. Fugit facilis
|
24
|
+
eveniet similique voluptatem dolore rerum laboriosam occaecati. Veniam
|
25
|
+
voluptatem autem in.
|
26
|
+
EOS
|
27
|
+
|
28
|
+
assert Par.new(" #{source}", p: 2) == expected
|
29
|
+
end
|
30
|
+
|
31
|
+
puts " ✔ All tests passed"
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: par
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Damian Janowski
|
13
|
+
- Michel Martens
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-05 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Par is a lightweight binding for par, a handy Unix tool for formatting paragraphs.
|
23
|
+
email:
|
24
|
+
- djanowski@dimaion.com
|
25
|
+
- michel@soveran.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- LICENSE
|
34
|
+
- README.markdown
|
35
|
+
- Rakefile
|
36
|
+
- lib/par.rb
|
37
|
+
- par.gemspec
|
38
|
+
- test/helper.rb
|
39
|
+
- test/par_test.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/djanowski/par
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.7
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Paragraph reformatter.
|
72
|
+
test_files: []
|
73
|
+
|