linebreak 1.3.1 → 2.0.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.tar.gz.sig +0 -0
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/.yardopts +5 -0
- data/Gemfile +23 -0
- data/{History.txt → HISTORY.md} +27 -7
- data/LICENSE.md +15 -0
- data/README.md +255 -0
- data/Rakefile +46 -19
- data/lib/aef/linebreak.rb +142 -20
- data/lib/aef/linebreak/version.rb +30 -0
- data/lib/linebreak.rb +22 -0
- data/lib/linebreak/bare.rb +20 -0
- data/linebreak.gemspec +55 -0
- data/spec/linebreak_spec.rb +29 -133
- data/spec/spec_helper.rb +22 -131
- metadata +135 -107
- metadata.gz.sig +0 -0
- data/COPYING.txt +0 -674
- data/Manifest.txt +0 -23
- data/README.rdoc +0 -232
- data/bin/linebreak +0 -61
- data/lib/aef/linebreak/commands/encode.rb +0 -73
- data/lib/aef/linebreak/commands/encodings.rb +0 -88
- data/lib/aef/linebreak/commands/version.rb +0 -38
- data/lib/aef/linebreak/linebreak.rb +0 -124
- data/lib/aef/linebreak/pathname_conversion.rb +0 -44
- data/lib/aef/linebreak/string_extension.rb +0 -22
- data/spec/fixtures/mac.txt +0 -1
- data/spec/fixtures/mac_unix.txt +0 -2
- data/spec/fixtures/unix.txt +0 -3
- data/spec/fixtures/unix_windows.txt +0 -3
- data/spec/fixtures/unix_windows_mac.txt +0 -3
- data/spec/fixtures/windows.txt +0 -3
- data/spec/fixtures/windows_mac.txt +0 -2
- data/spec/spec.opts +0 -4
data.tar.gz.sig
CHANGED
Binary file
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
4
|
+
|
5
|
+
This file is part of Linebreak.
|
6
|
+
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
+
purpose with or without fee is hereby granted, provided that the above
|
9
|
+
copyright notice and this permission notice appear in all copies.
|
10
|
+
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
18
|
+
=end
|
19
|
+
|
20
|
+
source 'http://rubygems.org'
|
21
|
+
|
22
|
+
# Specify your gem's dependencies in weekling.gemspec
|
23
|
+
gemspec
|
data/{History.txt → HISTORY.md}
RENAMED
@@ -1,4 +1,18 @@
|
|
1
|
-
|
1
|
+
2.0.0 / 2012-03-10
|
2
|
+
==================
|
3
|
+
|
4
|
+
* 1 major enhancement
|
5
|
+
|
6
|
+
* Changed to ISC based license
|
7
|
+
|
8
|
+
* 3 minor enhancements
|
9
|
+
|
10
|
+
* Slightly restructured project
|
11
|
+
* Extracted the command-line tool into linebreak-cli gem
|
12
|
+
* Documentation converted to YARD syntax
|
13
|
+
|
14
|
+
1.3.1 / 2009-09-14
|
15
|
+
==================
|
2
16
|
|
3
17
|
* 1 major bugfix
|
4
18
|
|
@@ -8,7 +22,8 @@
|
|
8
22
|
|
9
23
|
* Implemented autoloading
|
10
24
|
|
11
|
-
|
25
|
+
1.3.0 / 2009-08-11
|
26
|
+
==================
|
12
27
|
|
13
28
|
* 3 major enhancements
|
14
29
|
|
@@ -23,7 +38,8 @@
|
|
23
38
|
* Used the Pathname class where possible
|
24
39
|
* Upgraded to use the latest hoe gem
|
25
40
|
|
26
|
-
|
41
|
+
1.2.0 / 2009-04-05
|
42
|
+
==================
|
27
43
|
|
28
44
|
* 2 major enhancements
|
29
45
|
|
@@ -42,7 +58,8 @@
|
|
42
58
|
|
43
59
|
* Fixed some bugs related to Ruby 1.8.6
|
44
60
|
|
45
|
-
|
61
|
+
1.1.1 / 2009-03-08
|
62
|
+
==================
|
46
63
|
|
47
64
|
* minor enhancement
|
48
65
|
|
@@ -50,7 +67,8 @@
|
|
50
67
|
* Some test refactoring
|
51
68
|
* Some more comments
|
52
69
|
|
53
|
-
|
70
|
+
1.1.0 / 2009-03-01
|
71
|
+
==================
|
54
72
|
|
55
73
|
* 2 major enhancements
|
56
74
|
|
@@ -61,7 +79,8 @@
|
|
61
79
|
|
62
80
|
* Added support for custom string linebreak encodings in library
|
63
81
|
|
64
|
-
|
82
|
+
1.0.1 / 2009-02-24
|
83
|
+
==================
|
65
84
|
|
66
85
|
* 1 minor enhancement
|
67
86
|
|
@@ -71,7 +90,8 @@
|
|
71
90
|
|
72
91
|
* Bugfixes for commandline use
|
73
92
|
|
74
|
-
|
93
|
+
1.0.0 / 2009-02-24
|
94
|
+
==================
|
75
95
|
|
76
96
|
* 1 major enhancement
|
77
97
|
|
data/LICENSE.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
2
|
+
|
3
|
+
Linebreak is licensed under the following ISC-style license:
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
11
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
Linebreak
|
2
|
+
=========
|
3
|
+
|
4
|
+
[](
|
5
|
+
https://secure.travis-ci.org/aef/linebreak)
|
6
|
+
|
7
|
+
* [Documentation][docs]
|
8
|
+
* [Project][project]
|
9
|
+
|
10
|
+
[docs]: http://rdoc.info/github/aef/linebreak/
|
11
|
+
[project]: https://github.com/aef/linebreak/
|
12
|
+
|
13
|
+
Description
|
14
|
+
-----------
|
15
|
+
|
16
|
+
Linebreak is a Ruby library for conversion of text between linebreak encoding
|
17
|
+
formats of unix, windows or mac.
|
18
|
+
|
19
|
+
A command-line tool is available as separate gem named linebreak-cli.
|
20
|
+
Earlier versions of Linebreak were called BreakVerter.
|
21
|
+
|
22
|
+
Features / Problems
|
23
|
+
-------------------
|
24
|
+
|
25
|
+
This project tries to conform to:
|
26
|
+
|
27
|
+
* [Semantic Versioning (2.0.0-rc.1)][semver]
|
28
|
+
* [Ruby Packaging Standard (0.5-draft)][rps]
|
29
|
+
* [Ruby Style Guide][style]
|
30
|
+
* [Gem Packaging: Best Practices][gem]
|
31
|
+
|
32
|
+
[semver]: http://semver.org/
|
33
|
+
[rps]: http://chneukirchen.github.com/rps/
|
34
|
+
[style]: https://github.com/bbatsov/ruby-style-guide
|
35
|
+
[gem]: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
|
36
|
+
|
37
|
+
Additional facts:
|
38
|
+
|
39
|
+
* Written purely in Ruby.
|
40
|
+
* Documented with YARD.
|
41
|
+
* Intended to be used with Ruby 1.8.7 or higher.
|
42
|
+
* Extends core classes. This can be disabled through bare mode.
|
43
|
+
* Cryptographically signed gem and git tags.
|
44
|
+
|
45
|
+
Synopsis
|
46
|
+
--------
|
47
|
+
|
48
|
+
This documentation defines the public interface of the software. Don't rely
|
49
|
+
on elements marked as private. Those should be hidden in the documentation
|
50
|
+
by default.
|
51
|
+
|
52
|
+
### Loading
|
53
|
+
|
54
|
+
In most cases you want to load the library by the following command:
|
55
|
+
|
56
|
+
~~~~~ ruby
|
57
|
+
require 'linebreak'
|
58
|
+
~~~~~
|
59
|
+
|
60
|
+
In a bundler Gemfile you should use the following:
|
61
|
+
|
62
|
+
~~~~~ ruby
|
63
|
+
gem 'linebreak'
|
64
|
+
~~~~~
|
65
|
+
|
66
|
+
By default, Linebreak extends the String class to make all Strings support the
|
67
|
+
linebreak helper methods. The decision to modify Ruby's core classes should be
|
68
|
+
in the hand of the end user (e.g. the application developer). So if you don't
|
69
|
+
want the core extensions to be loaded or if you are using this library as a
|
70
|
+
component in another library you should load this library in bare mode:
|
71
|
+
|
72
|
+
~~~~~ ruby
|
73
|
+
require 'linebreak/bare'
|
74
|
+
~~~~~
|
75
|
+
|
76
|
+
Or for bundler Gemfiles:
|
77
|
+
|
78
|
+
~~~~~ ruby
|
79
|
+
gem 'linebreak', require: 'linebreak/bare'
|
80
|
+
~~~~~
|
81
|
+
|
82
|
+
### Library
|
83
|
+
|
84
|
+
You can convert Strings to a target linebreak encoding. The default encoding is
|
85
|
+
:unix. You can also choose :mac and :windows. Notice that the :mac encoding is
|
86
|
+
deprecated. Modern Apple machines also use :unix linebreak encoding, while
|
87
|
+
Commodore machines also use the :mac linebreak encoding.
|
88
|
+
|
89
|
+
~~~~~ ruby
|
90
|
+
windows_string = "Abcdef\r\nAbcdef\r\nAbcdef"
|
91
|
+
|
92
|
+
windows_string.linebreak_encode(:unix)
|
93
|
+
#=> "Abcdef\nAbcdef\nAbcdef"
|
94
|
+
~~~~~
|
95
|
+
|
96
|
+
You can detect which decoding systems are used in a String:
|
97
|
+
|
98
|
+
~~~~~ ruby
|
99
|
+
mixed_unix_and_mac_string = "Abcdef\rAbcdef\nAbcdef"
|
100
|
+
|
101
|
+
mixed_unix_and_mac_string.linebreak_encodings
|
102
|
+
#=> #<Set: {:unix, :mac}>
|
103
|
+
~~~~~
|
104
|
+
|
105
|
+
You can also easily ensure that a String contains exactly the linebreak
|
106
|
+
encodings you expect it to contain:
|
107
|
+
|
108
|
+
~~~~~ ruby
|
109
|
+
mixed_windows_and_mac_string = "Abcdef\r\nAbcdef\rAbcdef"
|
110
|
+
|
111
|
+
mixed_windows_and_mac_string.linebreak_encoding?(:windows)
|
112
|
+
#=> false
|
113
|
+
|
114
|
+
mixed_windows_and_mac_string.linebreak_encoding?(:windows, :mac)
|
115
|
+
#=> true
|
116
|
+
~~~~~
|
117
|
+
|
118
|
+
Note that the expected linebreak systems could also be given as an Array or a
|
119
|
+
Set.
|
120
|
+
|
121
|
+
If you prefer not the use the core extensions (e.g. in bare mode) you can use
|
122
|
+
this library in the following way:
|
123
|
+
|
124
|
+
~~~~~ ruby
|
125
|
+
Aef::Linebreak.encode("Abcdef\nAbcdef\nAbcdef", :mac)
|
126
|
+
#=> "Abcdef\rAbcdef\rAbcdef"
|
127
|
+
|
128
|
+
Aef::Linebreak.encodings("Abcdef\r\nAbcdef\nAbcdef")
|
129
|
+
#=> #<Set: {:unix, :windows}>
|
130
|
+
|
131
|
+
Aef::Linebreak.encoding?("Abcdef\nAbcdef\nAbcdef", :unix, :windows)
|
132
|
+
#=> false
|
133
|
+
|
134
|
+
Aef::Linebreak.encoding?("Abcdef\nAbcdef\nAbcdef", :unix)
|
135
|
+
#=> true
|
136
|
+
~~~~~
|
137
|
+
|
138
|
+
Or you can manually extend a String to support the linebreak helper methods like
|
139
|
+
this:
|
140
|
+
|
141
|
+
~~~~~ ruby
|
142
|
+
some_string.extend Aef::Linebreak
|
143
|
+
~~~~~
|
144
|
+
|
145
|
+
Requirements
|
146
|
+
------------
|
147
|
+
|
148
|
+
* Ruby 1.8.7 or higher
|
149
|
+
|
150
|
+
Installation
|
151
|
+
------------
|
152
|
+
|
153
|
+
On *nix systems you may need to prefix the command with sudo to get root
|
154
|
+
privileges.
|
155
|
+
|
156
|
+
### High security (recommended)
|
157
|
+
|
158
|
+
There is a high security installation option available through rubygems. It is
|
159
|
+
highly recommended over the normal installation, although it may be a bit less
|
160
|
+
comfortable. To use the installation method, you will need my [gem signing
|
161
|
+
public key][gemkey], which I use for cryptographic signatures on all my gems.
|
162
|
+
|
163
|
+
Add the key to your rubygems' trusted certificates by the following command:
|
164
|
+
|
165
|
+
gem cert --add aef-gem.pem
|
166
|
+
|
167
|
+
Now you can install the gem while automatically verifying it's signature by the
|
168
|
+
following command:
|
169
|
+
|
170
|
+
gem install linebreak -P HighSecurity
|
171
|
+
|
172
|
+
Please notice that you may need other keys for dependent libraries, so you may
|
173
|
+
have to install dependencies manually.
|
174
|
+
|
175
|
+
[gemkey]: http://aef.name/crypto/aef-gem.pem
|
176
|
+
|
177
|
+
### Normal
|
178
|
+
|
179
|
+
gem install linebreak
|
180
|
+
|
181
|
+
### Automated testing
|
182
|
+
|
183
|
+
Go into the root directory of the installed gem and run the following command
|
184
|
+
to fetch all development dependencies:
|
185
|
+
|
186
|
+
bundle
|
187
|
+
|
188
|
+
Afterwards start the test runner:
|
189
|
+
|
190
|
+
rake spec
|
191
|
+
|
192
|
+
If something goes wrong you should be noticed through failing examples.
|
193
|
+
|
194
|
+
Development
|
195
|
+
-----------
|
196
|
+
|
197
|
+
### Bugs Reports and Feature Requests
|
198
|
+
|
199
|
+
Please use the [issue tracker][issues] on github.com to let me know about errors
|
200
|
+
or ideas for improvement of this software.
|
201
|
+
|
202
|
+
[issues]: https://github.com/aef/linebreak/issues/
|
203
|
+
|
204
|
+
### Source code
|
205
|
+
|
206
|
+
This software is developed in the source code management system git hosted
|
207
|
+
at github.com. You can download the most recent sourcecode through the
|
208
|
+
following command:
|
209
|
+
|
210
|
+
git clone https://github.com/aef/linebreak.git
|
211
|
+
|
212
|
+
The final commit before each released gem version will be marked by a tag
|
213
|
+
named like the version with a prefixed lower-case "v", as required by Semantic
|
214
|
+
Versioning. Every tag will be signed by my [OpenPGP public key][openpgp] which
|
215
|
+
enables you to verify your copy of the code cryptographically.
|
216
|
+
|
217
|
+
[openpgp]: http://aef.name/crypto/aef-openpgp.asc
|
218
|
+
|
219
|
+
Add the key to your GnuPG keyring by the following command:
|
220
|
+
|
221
|
+
gpg --import aef-openpgp.asc
|
222
|
+
|
223
|
+
This command will tell you if your code is of integrity and authentic:
|
224
|
+
|
225
|
+
git tag -v [TAG NAME]
|
226
|
+
|
227
|
+
### Contribution
|
228
|
+
|
229
|
+
Help on making this software better is always very appreciated. If you want
|
230
|
+
your changes to be included in the official release, please clone my project
|
231
|
+
on github.com, create a named branch to commit and push your changes into and
|
232
|
+
send me a pull request afterwards.
|
233
|
+
|
234
|
+
Please make sure to write tests for your changes so that I won't break them
|
235
|
+
when changing other things on the library. Also notice that I can't promise
|
236
|
+
to include your changes before reviewing them.
|
237
|
+
|
238
|
+
License
|
239
|
+
-------
|
240
|
+
|
241
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
242
|
+
|
243
|
+
This file is part of Linebreak.
|
244
|
+
|
245
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
246
|
+
purpose with or without fee is hereby granted, provided that the above
|
247
|
+
copyright notice and this permission notice appear in all copies.
|
248
|
+
|
249
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
250
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
251
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
252
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
253
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
254
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
255
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,21 +1,48 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
4
|
+
|
5
|
+
This file is part of Linebreak.
|
6
|
+
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
+
purpose with or without fee is hereby granted, provided that the above
|
9
|
+
copyright notice and this permission notice appear in all copies.
|
10
|
+
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
18
|
+
=end
|
19
|
+
|
20
|
+
require 'bundler/gem_tasks'
|
21
|
+
require 'rake'
|
22
|
+
require 'pathname'
|
23
|
+
require 'yard'
|
24
|
+
require 'rspec/core/rake_task'
|
25
|
+
|
26
|
+
RSpec::Core::RakeTask.new
|
27
|
+
|
28
|
+
YARD::Rake::YardocTask.new('doc')
|
29
|
+
|
30
|
+
desc "Removes temporary project files"
|
31
|
+
task :clean do
|
32
|
+
%w{doc coverage pkg .yardoc .rbx Gemfile.lock}.map{|name| Pathname.new(name) }.each do |path|
|
33
|
+
path.rmtree if path.exist?
|
34
|
+
end
|
35
|
+
|
36
|
+
Pathname.glob('*.gem').each &:delete
|
37
|
+
Pathname.glob('**/*.rbc').each &:delete
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Opens an interactive console with the library loaded"
|
41
|
+
task :console do
|
42
|
+
Bundler.setup
|
43
|
+
require 'pry'
|
44
|
+
require 'linebreak'
|
45
|
+
Pry.start
|
19
46
|
end
|
20
47
|
|
21
|
-
|
48
|
+
task :default => :spec
|