linebreak-cli 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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.md +98 -0
- data/LICENSE.md +15 -0
- data/README.md +196 -0
- data/Rakefile +48 -0
- data/bin/linebreak +55 -0
- data/lib/aef/linebreak/cli.rb +48 -0
- data/lib/aef/linebreak/cli/commands/encode.rb +80 -0
- data/lib/aef/linebreak/cli/commands/encodings.rb +97 -0
- data/lib/aef/linebreak/cli/commands/version.rb +48 -0
- data/lib/aef/linebreak/cli/pathname_conversion.rb +56 -0
- data/lib/aef/linebreak/cli/version.rb +32 -0
- data/linebreak-cli.gemspec +62 -0
- data/spec/cli_spec.rb +163 -0
- data/spec/fixtures/mac.txt +1 -0
- data/spec/fixtures/mac_unix.txt +2 -0
- data/spec/fixtures/unix.txt +3 -0
- data/spec/fixtures/unix_windows.txt +3 -0
- data/spec/fixtures/unix_windows_mac.txt +3 -0
- data/spec/fixtures/windows.txt +3 -0
- data/spec/fixtures/windows_mac.txt +2 -0
- data/spec/spec_helper.rb +116 -0
- metadata +223 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
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::CLI.
|
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.md
ADDED
@@ -0,0 +1,98 @@
|
|
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
|
+
==================
|
16
|
+
|
17
|
+
* 1 major bugfix
|
18
|
+
|
19
|
+
* Fixed issues with loading the gem in some situations
|
20
|
+
|
21
|
+
* 1 minor enhancement
|
22
|
+
|
23
|
+
* Implemented autoloading
|
24
|
+
|
25
|
+
1.3.0 / 2009-08-11
|
26
|
+
==================
|
27
|
+
|
28
|
+
* 3 major enhancements
|
29
|
+
|
30
|
+
* Included methods for linebreak system detection and ensuring
|
31
|
+
* Overhauled commandline tool to support detection and ensuring
|
32
|
+
* BreakVerter renamed to Linebreak for better recognition
|
33
|
+
|
34
|
+
* 4 minor enhancements
|
35
|
+
|
36
|
+
* String extension now loadable via require
|
37
|
+
* Most of the specifications now run on JRuby
|
38
|
+
* Used the Pathname class where possible
|
39
|
+
* Upgraded to use the latest hoe gem
|
40
|
+
|
41
|
+
1.2.0 / 2009-04-05
|
42
|
+
==================
|
43
|
+
|
44
|
+
* 2 major enhancements
|
45
|
+
|
46
|
+
* Namespaced into module Aef
|
47
|
+
* Instance method added for on demand inclusion into the String class
|
48
|
+
|
49
|
+
* 5 minor enhancements
|
50
|
+
|
51
|
+
* Better metadata for gem
|
52
|
+
* Test refactoring
|
53
|
+
* Minor refactorings
|
54
|
+
* Improved documentation
|
55
|
+
* Added test for --version command
|
56
|
+
|
57
|
+
* 1 minor bugfix
|
58
|
+
|
59
|
+
* Fixed some bugs related to Ruby 1.8.6
|
60
|
+
|
61
|
+
1.1.1 / 2009-03-08
|
62
|
+
==================
|
63
|
+
|
64
|
+
* minor enhancement
|
65
|
+
|
66
|
+
* Added a --version command to output version and licensing information
|
67
|
+
* Some test refactoring
|
68
|
+
* Some more comments
|
69
|
+
|
70
|
+
1.1.0 / 2009-03-01
|
71
|
+
==================
|
72
|
+
|
73
|
+
* 2 major enhancements
|
74
|
+
|
75
|
+
* Added automated tests for the commandline tool
|
76
|
+
* Tested compatibility with ruby 1.9.1
|
77
|
+
|
78
|
+
* 1 minor enhancement
|
79
|
+
|
80
|
+
* Added support for custom string linebreak encodings in library
|
81
|
+
|
82
|
+
1.0.1 / 2009-02-24
|
83
|
+
==================
|
84
|
+
|
85
|
+
* 1 minor enhancement
|
86
|
+
|
87
|
+
* Now tested on Windows XP
|
88
|
+
|
89
|
+
* 1 minor bugfix
|
90
|
+
|
91
|
+
* Bugfixes for commandline use
|
92
|
+
|
93
|
+
1.0.0 / 2009-02-24
|
94
|
+
==================
|
95
|
+
|
96
|
+
* 1 major enhancement
|
97
|
+
|
98
|
+
* Birthday!
|
data/LICENSE.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
2
|
+
|
3
|
+
Linebreak::CLI 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,196 @@
|
|
1
|
+
Linebreak::CLI
|
2
|
+
==============
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/aef/linebreak-cli.png)](
|
5
|
+
https://secure.travis-ci.org/aef/linebreak-cli)
|
6
|
+
|
7
|
+
* [Documentation][docs]
|
8
|
+
* [Project][project]
|
9
|
+
|
10
|
+
[docs]: http://rdoc.info/github/aef/linebreak-cli/
|
11
|
+
[project]: https://github.com/aef/linebreak-cli/
|
12
|
+
|
13
|
+
Description
|
14
|
+
-----------
|
15
|
+
|
16
|
+
Linebreak::CLI is a Ruby command-line tool for conversion of text
|
17
|
+
between linebreak encoding formats of unix, windows or mac.
|
18
|
+
|
19
|
+
Before Linebreak 2.0.0 this tool was part of the linebreak gem.
|
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
|
+
* Intended to be used with Ruby 1.8.7 or higher.
|
41
|
+
* Cryptographically signed gem and git tags.
|
42
|
+
|
43
|
+
Synopsis
|
44
|
+
--------
|
45
|
+
|
46
|
+
This documentation defines the public interface of the software. Don't rely
|
47
|
+
on elements marked as private. Those should be hidden in the documentation
|
48
|
+
by default.
|
49
|
+
|
50
|
+
### Command-line tool
|
51
|
+
|
52
|
+
The default output encoding is unix. You can also choose mac and windows.
|
53
|
+
|
54
|
+
linebreak encode --system windows unix.txt windows.txt
|
55
|
+
|
56
|
+
If no target file is specified the output will be sent to STDOUT.
|
57
|
+
|
58
|
+
linebreak encode --system windows mac.txt > windows.txt
|
59
|
+
|
60
|
+
You can set the default with the environment variable LINEBREAK_SYSTEM.
|
61
|
+
|
62
|
+
export LINEBREAK_SYSTEM=mac
|
63
|
+
|
64
|
+
linebreak encode windows.txt mac.txt
|
65
|
+
|
66
|
+
If you do not specify an output file, output will be put to STDOUT. If you also
|
67
|
+
do not specify an input file, input will be expected from STDIN.
|
68
|
+
|
69
|
+
You can also detect the linebreak systems contained in a file in the following
|
70
|
+
way:
|
71
|
+
|
72
|
+
linebreak encodings windows_mac.txt
|
73
|
+
|
74
|
+
If you want to ensure that a file contains the exact encodings systems you
|
75
|
+
specified, you can use the following command:
|
76
|
+
|
77
|
+
linebreak encodings --ensure unix,windows,mac unix.txt
|
78
|
+
|
79
|
+
The results will be outputted. In case of a file containing other linebreak
|
80
|
+
encoding systems there will be an exit code of 1.
|
81
|
+
|
82
|
+
It is also possible to specify multiple input files or none to expect input from
|
83
|
+
STDIN.
|
84
|
+
|
85
|
+
Requirements
|
86
|
+
------------
|
87
|
+
|
88
|
+
* Ruby 1.8.7 or higher
|
89
|
+
* user-choices
|
90
|
+
|
91
|
+
Installation
|
92
|
+
------------
|
93
|
+
|
94
|
+
On *nix systems you may need to prefix the command with sudo to get root
|
95
|
+
privileges.
|
96
|
+
|
97
|
+
### High security (recommended)
|
98
|
+
|
99
|
+
There is a high security installation option available through rubygems. It is
|
100
|
+
highly recommended over the normal installation, although it may be a bit less
|
101
|
+
comfortable. To use the installation method, you will need my [gem signing
|
102
|
+
public key][gemkey], which I use for cryptographic signatures on all my gems.
|
103
|
+
|
104
|
+
Add the key to your rubygems' trusted certificates by the following command:
|
105
|
+
|
106
|
+
gem cert --add aef-gem.pem
|
107
|
+
|
108
|
+
Now you can install the gem while automatically verifying it's signature by the
|
109
|
+
following command:
|
110
|
+
|
111
|
+
gem install linebreak-cli -P HighSecurity
|
112
|
+
|
113
|
+
Please notice that you may need other keys for dependent libraries, so you may
|
114
|
+
have to install dependencies manually.
|
115
|
+
|
116
|
+
[gemkey]: http://aef.name/crypto/aef-gem.pem
|
117
|
+
|
118
|
+
### Normal
|
119
|
+
|
120
|
+
gem install linebreak-cli
|
121
|
+
|
122
|
+
### Automated testing
|
123
|
+
|
124
|
+
Go into the root directory of the installed gem and run the following command
|
125
|
+
to fetch all development dependencies:
|
126
|
+
|
127
|
+
bundle
|
128
|
+
|
129
|
+
Afterwards start the test runner:
|
130
|
+
|
131
|
+
rake spec
|
132
|
+
|
133
|
+
If something goes wrong you should be noticed through failing examples.
|
134
|
+
|
135
|
+
Development
|
136
|
+
-----------
|
137
|
+
|
138
|
+
### Bugs Reports and Feature Requests
|
139
|
+
|
140
|
+
Please use the [issue tracker][issues] on github.com to let me know about errors
|
141
|
+
or ideas for improvement of this software.
|
142
|
+
|
143
|
+
[issues]: https://github.com/aef/linebreak-cli/issues/
|
144
|
+
|
145
|
+
### Source code
|
146
|
+
|
147
|
+
This software is developed in the source code management system git hosted
|
148
|
+
at github.com. You can download the most recent sourcecode through the
|
149
|
+
following command:
|
150
|
+
|
151
|
+
git clone https://github.com/aef/linebreak-cli.git
|
152
|
+
|
153
|
+
The final commit before each released gem version will be marked by a tag
|
154
|
+
named like the version with a prefixed lower-case "v", as required by Semantic
|
155
|
+
Versioning. Every tag will be signed by my [OpenPGP public key][openpgp] which
|
156
|
+
enables you to verify your copy of the code cryptographically.
|
157
|
+
|
158
|
+
[openpgp]: http://aef.name/crypto/aef-openpgp.asc
|
159
|
+
|
160
|
+
Add the key to your GnuPG keyring by the following command:
|
161
|
+
|
162
|
+
gpg --import aef-openpgp.asc
|
163
|
+
|
164
|
+
This command will tell you if your code is of integrity and authentic:
|
165
|
+
|
166
|
+
git tag -v [TAG NAME]
|
167
|
+
|
168
|
+
### Contribution
|
169
|
+
|
170
|
+
Help on making this software better is always very appreciated. If you want
|
171
|
+
your changes to be included in the official release, please clone my project
|
172
|
+
on github.com, create a named branch to commit and push your changes into and
|
173
|
+
send me a pull request afterwards.
|
174
|
+
|
175
|
+
Please make sure to write tests for your changes so that I won't break them
|
176
|
+
when changing other things on the library. Also notice that I can't promise
|
177
|
+
to include your changes before reviewing them.
|
178
|
+
|
179
|
+
License
|
180
|
+
-------
|
181
|
+
|
182
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
183
|
+
|
184
|
+
This file is part of Linebreak::CLI.
|
185
|
+
|
186
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
187
|
+
purpose with or without fee is hereby granted, provided that the above
|
188
|
+
copyright notice and this permission notice appear in all copies.
|
189
|
+
|
190
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
191
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
192
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
193
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
194
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
195
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
196
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
=begin
|
3
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
4
|
+
|
5
|
+
This file is part of Linebreak::CLI.
|
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 'aef/linebreak/cli'
|
45
|
+
Pry.start
|
46
|
+
end
|
47
|
+
|
48
|
+
task :default => :spec
|
data/bin/linebreak
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
=begin
|
4
|
+
Copyright Alexander E. Fischer <aef@raxys.net>, 2009-2012
|
5
|
+
|
6
|
+
This file is part of Linebreak::CLI.
|
7
|
+
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
9
|
+
purpose with or without fee is hereby granted, provided that the above
|
10
|
+
copyright notice and this permission notice appear in all copies.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
14
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
19
|
+
=end
|
20
|
+
|
21
|
+
require 'aef/linebreak/cli'
|
22
|
+
require 'user-choices'
|
23
|
+
|
24
|
+
commands_available = {
|
25
|
+
:encode => 'Convert all linebreak encodings of a file',
|
26
|
+
:encodings => 'Detect linebreak encoding systems of a file',
|
27
|
+
:version => 'More information about this program',
|
28
|
+
:'--version' => :version,
|
29
|
+
:'-v' => :version,
|
30
|
+
:'-V' => :version
|
31
|
+
}
|
32
|
+
|
33
|
+
command_name = ARGV.shift
|
34
|
+
command_name = command_name.to_sym if command_name
|
35
|
+
|
36
|
+
if commands_available[command_name].nil?
|
37
|
+
puts "Usage: linebreak COMMAND"
|
38
|
+
puts
|
39
|
+
puts 'Available commands:'
|
40
|
+
puts
|
41
|
+
padding = commands_available.keys.map{|symbol| symbol.to_s}.max{|a,b| a.size <=> b.size}.size
|
42
|
+
commands_available.each do |command_name, description|
|
43
|
+
unless description.is_a?(Symbol)
|
44
|
+
printf "%-#{padding}s\t%s\n", command_name, description
|
45
|
+
end
|
46
|
+
end
|
47
|
+
exit false
|
48
|
+
else
|
49
|
+
if commands_available[command_name].is_a?(Symbol)
|
50
|
+
command_name = commands_available[command_name]
|
51
|
+
end
|
52
|
+
|
53
|
+
command = Aef::Linebreak::CLI.const_get("#{command_name.to_s.capitalize}Command").new
|
54
|
+
S4tUtils.with_pleasant_exceptions {command.execute}
|
55
|
+
end
|