tabs2spaces 0.0.5
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/bin/tabs2spaces +24 -0
- data/lib/tabs2spaces/version.rb +3 -0
- data/lib/tabs2spaces.rb +41 -0
- data/tabs2spaces.gemspec +23 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3980ffa57661b0462321603263fcc49c670e9993
|
4
|
+
data.tar.gz: 2b1eb5bd6fc6b109dd4613b08e15b51794feefd5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 994020d2cf809a67b090a625832247b5b2007064f21db2bc3dcd1ff01fcc28775915bd357e235f2d44953b1dc81e27bab920eb283253cecbff3f462c121050f5
|
7
|
+
data.tar.gz: 427167922f81a1369cd425607668bcb41f8c4e4d5777fe47af83e7162c51ce517ccb16b5f24558fe95dc98c353ee1ad9c9934b7d47cf1598a220c6fae76080b5
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Tabs2spaces
|
2
|
+
===========
|
3
|
+
|
4
|
+
Covert all tabs in spaces using the shell command expand
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'tabs2spaces'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install tabs2spaces
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Example of basic usage convert tabs to 2 spaces in all files .rb inside the actual folder (./)
|
23
|
+
|
24
|
+
cd /ruby_project_folder
|
25
|
+
|
26
|
+
tabs2spaces
|
27
|
+
|
28
|
+
Parameters
|
29
|
+
|
30
|
+
tabs2paces -n NUMBER -p "PATTERN"
|
31
|
+
|
32
|
+
NUMBER: number of spaces to replace the tab by default is 2 (OPTIONAL)
|
33
|
+
PATTERN: Pattern to determine the files by default is "*.rb", use "*.js" (OPTIONAL)
|
34
|
+
|
35
|
+
Sintaxis
|
36
|
+
|
37
|
+
tabs2paces [options] DIRECTORY
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/tabs2spaces
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# Preconfigurations
|
4
|
+
require 'tabs2spaces'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:number => 2,
|
9
|
+
:pattern => "*.rb"
|
10
|
+
}
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: tabs2spaces.rb [options] DIRECTORY"
|
13
|
+
|
14
|
+
opts.on("-n", "--number [NUMBER]", Integer, "Number of spaces to remplace a tab (default: 2)") do |number|
|
15
|
+
options[:number] = number
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-p", "--pattern [PATTERN]", "Pattern of files to apply tabs2spaces (default: '*.rb')") do |pattern|
|
19
|
+
options[:pattern] = pattern
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
23
|
+
tabs2spaces = Tabs2spaces::Converter.new(ARGV[0], options)
|
24
|
+
tabs2spaces.convert
|
data/lib/tabs2spaces.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "tabs2spaces/version"
|
2
|
+
|
3
|
+
module Tabs2spaces
|
4
|
+
class Converter
|
5
|
+
|
6
|
+
def initialize(folder, options)
|
7
|
+
@folder = folder || "./"
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def file_expand(file)
|
12
|
+
puts "Expanding tabs on " + file
|
13
|
+
return `expand -t #{@options[:number]} -i #{file}`
|
14
|
+
end
|
15
|
+
|
16
|
+
def file_write(file, data)
|
17
|
+
begin
|
18
|
+
new_file = File.open(file, "w") do |f|
|
19
|
+
f.puts data
|
20
|
+
end
|
21
|
+
rescue IOError => e
|
22
|
+
puts e
|
23
|
+
ensure
|
24
|
+
new_file.close unless new_file == nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def convert
|
29
|
+
unless File.directory?(@folder)
|
30
|
+
new_file = file_expand @folder
|
31
|
+
file_write @folder, new_file
|
32
|
+
else
|
33
|
+
folder = File.join(@folder, '**', @options[:pattern])
|
34
|
+
Dir.glob(folder).each do |file|
|
35
|
+
new_file = file_expand file
|
36
|
+
file_write file, new_file
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/tabs2spaces.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tabs2spaces/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tabs2spaces"
|
8
|
+
spec.version = Tabs2spaces::VERSION
|
9
|
+
spec.authors = ["Sergio Marin"]
|
10
|
+
spec.email = ["higher.vnf@gmail.com"]
|
11
|
+
spec.description = %q{Covert all tabs in spaces using the shell command expand}
|
12
|
+
spec.summary = %q{A gem to convert tabs2spaces in all files on a project}
|
13
|
+
spec.homepage = "http://github.com/highercomve/tabs2spaces"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = ['tabs2spaces']
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tabs2spaces
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergio Marin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Covert all tabs in spaces using the shell command expand
|
42
|
+
email:
|
43
|
+
- higher.vnf@gmail.com
|
44
|
+
executables:
|
45
|
+
- tabs2spaces
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/tabs2spaces
|
55
|
+
- lib/tabs2spaces.rb
|
56
|
+
- lib/tabs2spaces/version.rb
|
57
|
+
- tabs2spaces.gemspec
|
58
|
+
homepage: http://github.com/highercomve/tabs2spaces
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.7
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: A gem to convert tabs2spaces in all files on a project
|
82
|
+
test_files: []
|