adjustn 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 507c06ba52c377d7897ed740dc1d92733a9a5516228ba34fd087f1f13540e13b
4
- data.tar.gz: b82ed949bf2af07ad8719fdd11be0ac64921147304f139a0ffc25ac62ff4eeb4
3
+ metadata.gz: bb18fa686bd7bbb8de364ed96466daf517d2c4205327b04f68ae88924aa6469c
4
+ data.tar.gz: e524c7446a9f6ec133ba0933c5c5945d3b9b4fa3a5c97c643b7ba2f0c3c8bbb8
5
5
  SHA512:
6
- metadata.gz: 532c9faa753a17ca9a703568af916abeef24c9b1bef8acccc80a6d79c0ab43900d888e18d0fe1956ac31ead2600ecc1612b759d22837262066d564ccc6a42706
7
- data.tar.gz: 92101b2bbb87905e3d64f35d5b57469fd99e3f231086afbc9ca20e6dfdda8462da8ffeda42a3e92fb78244cfc946ba6d4b6ecdcf212f0b0f767402b9191038c0
6
+ metadata.gz: e40aa225697f0208b5ac6aff0783559878850e4f0ea43f0c240137036537819bce1bd4d391dfdbcf5c9fbee76dbd460f2935499db4cf162d6481214fcb3352cc
7
+ data.tar.gz: 3beefe7581b6efa9ac56c3b298f78a075225434bde837a7e9f725b5d13125adf6a147599e8a6165d3e0bc099f7e19f0e74d4663d23c2a51513f666540ecd5247
File without changes
data/README.md CHANGED
@@ -1,52 +1,30 @@
1
- adjustn
2
- ==============
1
+ # adjustn
3
2
 
4
- [![Build Status](https://secure.travis-ci.org/kachick/adjustn.png)](http://travis-ci.org/kachick/adjustn)
3
+ ![Build Status](https://github.com/kachick/adjustn/actions/workflows/test_behaviors.yml/badge.svg?branch=main)
5
4
  [![Gem Version](https://badge.fury.io/rb/adjustn.png)](http://badge.fury.io/rb/adjustn)
6
5
 
7
- A tiny text tool for adjusting new line characters(CR LF CRLF).
6
+ A tiny text tool for adjusting new line characters(CR LF CRLF).
8
7
  In short, Like unix2dos/dos2unix on Ruby.
9
8
 
10
- Features
11
- --------
12
-
13
9
  * CR (Mac)
14
10
  * LF (Unix)
15
11
  * CRLF (Windows)
16
12
 
13
+ Convertible above
17
14
 
18
- Usage
19
- -----
20
-
21
- ### Overview
22
-
23
- ```shell
24
- $ adjustn LF path [*path]
25
- ```
15
+ ## Usage
26
16
 
27
- Requirements
28
- ------------
17
+ Require Ruby 2.6 or later
29
18
 
30
- * [Ruby 2.5 or later](http://travis-ci.org/#!/kachick/adjustn)
31
-
32
- Install
33
- -------
19
+ ### Overview
34
20
 
35
- ```shell
21
+ ```console
36
22
  $ gem install adjustn
23
+ $ adjustn.rb LF path [*path]
24
+ Done!
37
25
  ```
38
26
 
39
- Link
40
- ----
41
-
42
- * [code](https://github.com/kachick/adjustn)
43
- * [issues](https://github.com/kachick/adjustn/issues)
44
- * [CI](http://travis-ci.org/#!/kachick/adjustn)
45
- * [gem](https://rubygems.org/gems/adjustn)
46
-
47
- License
48
- -------
27
+ ## Links
49
28
 
50
- The MIT X11 License
51
- Copyright (c) 2012 Kenichi Kamiya
52
- See MIT-LICENSE for further details.
29
+ * [Repository](https://github.com/kachick/adjustn)
30
+ * [API documents](https://kachick.github.io/adjustn/)
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # coding: us-ascii
3
+ # frozen_string_literal: true
3
4
  # adjustn
4
5
  # A tiny tool for adjusting new line characters(CR LF CRLF)
5
6
 
@@ -7,10 +8,8 @@
7
8
 
8
9
  require_relative '../lib/adjustn'
9
10
 
10
- $VERBOSE = true
11
-
12
11
  unless ARGV.length >= 2
13
12
  abort "Usage: #{$PROGRAM_NAME} {cr|lf|crlf} *pathnames"
14
13
  end
15
14
 
16
- AdjustN.run ARGV.shift, *ARGV
15
+ AdjustN.run(ARGV.shift, *ARGV)
data/lib/adjustn.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
3
+
2
4
  # adjustn
3
5
  # A tiny tool for adjusting new line characters(CR LF CRLF)
4
6
 
@@ -1,10 +1,10 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
3
+
2
4
  # Copyright (C) 2012 Kenichi Kamiya
3
5
 
4
6
  module AdjustN
5
-
6
7
  module NewlineChar
7
-
8
8
  AUTONYMS = {
9
9
  cr: :cr,
10
10
  lf: :lf,
@@ -15,12 +15,12 @@ module AdjustN
15
15
  dos: :crlf
16
16
  }.freeze
17
17
 
18
- LF = "\x0a".freeze
19
- CR = "\x0d".freeze
20
- CRLF = (CR + LF).freeze
18
+ LF = "\x0a"
19
+ CR = "\x0d"
20
+ CRLF = (CR + LF)
21
+
22
+ Pair = Struct.new(:before, :after)
21
23
 
22
- Pair = Struct.new :before, :after
23
-
24
24
  PAIRS = {
25
25
  lf: Pair.new(/#{CRLF}|#{CR}/, LF).freeze,
26
26
  cr: Pair.new(/#{CRLF}|#{LF}/, CR).freeze,
@@ -28,19 +28,15 @@ module AdjustN
28
28
  }.freeze
29
29
 
30
30
  class << self
31
-
32
31
  # @param [String] str
33
32
  # @return [Symbol] :cr, :lf, :crlf
34
33
  def autonym(str)
35
- if /\A(cr|lf|crlf|mac|unix|win|dos)\z/i =~ str
36
- AUTONYMS.fetch str.downcase.to_sym
34
+ if /\A(cr|lf|crlf|mac|unix|win|dos)\z/i.match?(str)
35
+ AUTONYMS.fetch(str.downcase.to_sym)
37
36
  else
38
37
  raise TypeError
39
38
  end
40
39
  end
41
-
42
40
  end
43
-
44
41
  end
45
-
46
- end
42
+ end
@@ -1,9 +1,8 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
2
3
 
3
4
  module AdjustN
4
-
5
5
  class << self
6
-
7
6
  # @param [Symbol, String] after_code
8
7
  # @return [void]
9
8
  def run(after_code, *pathnames)
@@ -12,32 +11,30 @@ module AdjustN
12
11
  before, after = *pair_for(after_code)
13
12
 
14
13
  pathnames.each do |pathname|
15
- source = File.binread pathname
14
+ source = File.binread(pathname)
16
15
 
17
16
  if output = gsub_for!(source, before, after)
18
- File.open pathname, 'wb' do |f|
17
+ File.open(pathname, 'wb') do |f|
19
18
  f << output
20
19
  end
21
20
  else
22
- $stderr.puts %!Already adjuted the file "#{pathname}"!
21
+ $stderr.puts %Q!Already adjuted the file "#{pathname}"!
23
22
  end
24
23
  end
25
24
  end
26
-
25
+
27
26
  private
28
-
27
+
29
28
  # @return [NewlineChar::Pair]
30
29
  def pair_for(want)
31
30
  want = NewlineChar.autonym(want)
32
31
  NewlineChar::PAIRS.fetch(want)
33
32
  end
34
-
33
+
35
34
  # @return [String, nil]
36
35
  # @note for easy testing
37
36
  def gsub_for!(source, before, after)
38
- source.gsub!(before){after}
37
+ source.gsub!(before) { after }
39
38
  end
40
-
41
39
  end
42
-
43
40
  end
@@ -1,7 +1,6 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
2
3
 
3
4
  module AdjustN
4
-
5
- VERSION = '0.1.0'.freeze
6
-
5
+ VERSION = '0.2.0'
7
6
  end
metadata CHANGED
@@ -1,115 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adjustn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Kamiya
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: test-declare
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.0.3
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.0.3
27
- - !ruby/object:Gem::Dependency
28
- name: yard
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 0.9.20
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '2'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 0.9.20
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '2'
47
- - !ruby/object:Gem::Dependency
48
- name: rake
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '10'
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: '20'
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '10'
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: '20'
67
- - !ruby/object:Gem::Dependency
68
- name: bundler
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '2'
74
- - - "<"
75
- - !ruby/object:Gem::Version
76
- version: '3'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: '2'
84
- - - "<"
85
- - !ruby/object:Gem::Version
86
- version: '3'
87
- description: A tiny text tool for adjusting new line characters
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ A tiny text tool for adjusting new line characters(CR LF CRLF).
15
+ In short, Like unix2dos/dos2unix on Ruby.
88
16
  email:
89
17
  - kachick1+ruby@gmail.com
90
18
  executables:
91
- - adjustn
19
+ - adjustn.rb
92
20
  extensions: []
93
21
  extra_rdoc_files: []
94
22
  files:
95
- - ".gitignore"
96
- - ".travis.yml"
97
- - Gemfile
98
- - MIT-LICENSE
23
+ - MIT-LICENSE.txt
99
24
  - README.md
100
- - Rakefile
101
- - adjustn.gemspec
102
- - bin/adjustn
25
+ - exe/adjustn.rb
103
26
  - lib/adjustn.rb
104
27
  - lib/adjustn/newlinechar.rb
105
28
  - lib/adjustn/singleton_class.rb
106
29
  - lib/adjustn/version.rb
107
- - test/test_lib.rb
108
- homepage: http://kachick.github.com/adjustn
30
+ homepage: https://github.com/kachick/adjustn
109
31
  licenses:
110
32
  - MIT
111
- metadata: {}
112
- post_install_message:
33
+ metadata:
34
+ documentation_uri: https://kachick.github.io/adjustn/
35
+ homepage_uri: https://github.com/kachick/adjustn
36
+ source_code_uri: https://github.com/kachick/adjustn
37
+ bug_tracker_uri: https://github.com/kachick/adjustn/issues
38
+ post_install_message:
113
39
  rdoc_options: []
114
40
  require_paths:
115
41
  - lib
@@ -117,17 +43,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
43
  requirements:
118
44
  - - ">="
119
45
  - !ruby/object:Gem::Version
120
- version: '0'
46
+ version: 2.6.0
121
47
  required_rubygems_version: !ruby/object:Gem::Requirement
122
48
  requirements:
123
49
  - - ">="
124
50
  - !ruby/object:Gem::Version
125
51
  version: '0'
126
52
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.6
129
- signing_key:
53
+ rubygems_version: 3.2.15
54
+ signing_key:
130
55
  specification_version: 4
131
- summary: A tiny text tool for adjusting new line characters
132
- test_files:
133
- - test/test_lib.rb
56
+ summary: Adjusting new line characters
57
+ test_files: []
data/.gitignore DELETED
@@ -1,34 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- coverage.data
7
- InstalledFiles
8
- lib/bundler/man
9
- pkg
10
- rdoc
11
- spec/reports
12
- test/tmp
13
- test/version_tmp
14
- tmp
15
-
16
- # bundler
17
- vendor/
18
-
19
- # YARD artifacts
20
- .yardoc
21
- _yardoc
22
- doc/
23
-
24
- # tmp-old
25
- .old
26
-
27
- # editor
28
- *~
29
- *#*
30
- .redcar
31
-
32
- # other
33
- *.lock
34
- .rbx
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - ruby-head
5
- - 2.6
6
- - 2.5
7
- - rbx-3
8
- - jruby-head
9
-
10
- matrix:
11
- allow_failures:
12
- - rvm: ruby-head
13
- - rvm: rbx-3
14
- - rvm: jruby-head
15
-
16
- before_install:
17
- - gem install bundler
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- # coding: us-ascii
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- group :development do
8
- gem 'rake'
9
- end
10
-
11
- group :test do
12
- gem 'rake'
13
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
-
4
- require 'rake/testtask'
5
-
6
- task default: [:test]
7
-
8
- Rake::TestTask.new do |tt|
9
- tt.verbose = true
10
- end
data/adjustn.gemspec DELETED
@@ -1,34 +0,0 @@
1
- # coding: us-ascii
2
-
3
- require File.expand_path('../lib/adjustn/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- # specific
7
-
8
- gem.name = 'adjustn'
9
- gem.description = %q{A tiny text tool for adjusting new line characters}
10
- gem.summary = gem.description.dup
11
- gem.license = 'MIT'
12
- gem.version = AdjustN::VERSION.dup
13
-
14
- gem.add_development_dependency 'test-declare', '~> 0.0.3'
15
- gem.add_development_dependency 'yard', '>= 0.9.20', '< 2'
16
- gem.add_development_dependency 'rake', '>= 10', '< 20'
17
- gem.add_development_dependency 'bundler', '>= 2', '< 3'
18
-
19
- if RUBY_ENGINE == 'rbx'
20
- gem.add_dependency 'rubysl', '~> 2.0'
21
- gem.add_dependency 'rubysl-test-unit', '~> 2.0'
22
- end
23
-
24
- # common
25
-
26
- gem.homepage = "http://kachick.github.com/#{gem.name}"
27
- gem.authors = ['Kenichi Kamiya']
28
- gem.email = ['kachick1+ruby@gmail.com']
29
- gem.files = `git ls-files`.split($\)
30
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
31
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
32
- gem.require_paths = ['lib']
33
- end
34
-
data/test/test_lib.rb DELETED
@@ -1,29 +0,0 @@
1
- # coding: us-ascii
2
-
3
- $VERBOSE = true
4
-
5
- require 'test/declare'
6
- require_relative '../lib/adjustn'
7
-
8
-
9
- CR, LF, CRLF = AdjustN::NewlineChar::CR,
10
- AdjustN::NewlineChar::LF, AdjustN::NewlineChar::CRLF
11
-
12
- before, after = *AdjustN.__send__(:pair_for, :cr)
13
- sample = "1#{LF}2#{CR}3#{CRLF}4#{LF}#{CRLF}5#{CR}#{CRLF}6#{CRLF}#{LF}7#{CR}#{CR}8#{LF}#{LF}9#{CRLF}#{CRLF}"
14
- The(AdjustN.__send__ :gsub_for!, sample.dup, before, after) {
15
- is_a String
16
- is "1#{CR}2#{CR}3#{CR}4#{CR}#{CR}5#{CR}#{CR}6#{CR}#{CR}7#{CR}#{CR}8#{CR}#{CR}9#{CR}#{CR}"
17
- }
18
-
19
- before, after = *AdjustN.__send__(:pair_for, :lf)
20
- The(AdjustN.__send__ :gsub_for!, sample.dup, before, after) {
21
- is_a String
22
- is "1#{LF}2#{LF}3#{LF}4#{LF}#{LF}5#{LF}#{LF}6#{LF}#{LF}7#{LF}#{LF}8#{LF}#{LF}9#{LF}#{LF}"
23
- }
24
-
25
- before, after = *AdjustN.__send__(:pair_for, :crlf)
26
- The(AdjustN.__send__ :gsub_for!, sample.dup, before, after) {
27
- is_a String
28
- is "1#{CRLF}2#{CRLF}3#{CRLF}4#{CRLF}#{CRLF}5#{CRLF}#{CRLF}6#{CRLF}#{CRLF}7#{CRLF}#{CRLF}8#{CRLF}#{CRLF}9#{CRLF}#{CRLF}"
29
- }