replace_quotes 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.rubocop.yml +11 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +10 -0
- data/all.sh +15 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/code_test.sh +25 -0
- data/gem_console.sh +6 -0
- data/gem_install.sh +6 -0
- data/gem_test.sh +9 -0
- data/lib/replace_quotes/version.rb +4 -0
- data/lib/replace_quotes.rb +24 -0
- data/replace_quotes.gemspec +32 -0
- data/test_files/test1.txt +2 -0
- data/test_files/test1a.txt +2 -0
- data/test_files/test2.txt +2 -0
- data/test_files/test2a.txt +2 -0
- data/test_files/test3.txt +5 -0
- data/test_files/test3a.txt +5 -0
- data/test_files/test4.txt +2 -0
- data/test_files/test4a.txt +2 -0
- metadata +197 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42d7a6972e132f6145e3239f7492ec349075e883
|
4
|
+
data.tar.gz: cfbbef6c1208708ddf66370463d3b3b45958561a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f605bcb24b9157cd09b1cd90b9f0b3833092e71c7cc7b4de89123bd3383421ded5227d2d330ecde3090c8f3d63f89d18b10f260b5e3903107f8f4e1caf6bf09
|
7
|
+
data.tar.gz: b22b8e43c1681852523b1678cc95382dd047ed0735b15776a5032ad8313e2447c6003fec339f5dfd3200eb735304995963e1d51eed4f4663e8a6c6182212a511
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jason Hsu
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
[![Dependency Status](https://gemnasium.com/jhsu802701/replace_quotes.svg)](https://gemnasium.com/jhsu802701/replace_quotes)
|
2
|
+
[![Build Status](https://travis-ci.org/jhsu802701/replace_quotes.svg?branch=master)](https://travis-ci.org/jhsu802701/replace_quotes)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/jhsu802701/replace_quotes/badges/gpa.svg)](https://codeclimate.com/github/jhsu802701/replace_quotes)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/jhsu802701/replace_quotes/badges/coverage.svg)](https://codeclimate.com/github/jhsu802701/replace_quotes/coverage)
|
5
|
+
[![security](https://hakiri.io/github/jhsu802701/replace_quotes/master.svg)](https://hakiri.io/github/jhsu802701/replace_quotes/master)
|
6
|
+
|
7
|
+
# ReplaceQuotes
|
8
|
+
|
9
|
+
This gem is used for improving RuboCop compliance by replacing unnecessary double quotes with single quotes in a file. To avoid causing errors, ReplaceQuotes leaves double quotes alone when they are used in a line containing single quotes.
|
10
|
+
<br><br>
|
11
|
+
Before:
|
12
|
+
```
|
13
|
+
"There is Ruby on High Speed Rails, and there is Not Exactly."
|
14
|
+
"Make sure you choose the correct one."
|
15
|
+
|
16
|
+
"I hope we're using Ruby on High Speed Rails"
|
17
|
+
"There's Ruby on High Speed Rails, and there's Not Exactly."
|
18
|
+
```
|
19
|
+
After:
|
20
|
+
```
|
21
|
+
'There is Ruby on High Speed Rails, and there is Not Exactly.'
|
22
|
+
'Make sure you choose the correct one.'
|
23
|
+
|
24
|
+
"I hope we're using Ruby on High Speed Rails"
|
25
|
+
"There's Ruby on High Speed Rails, and there's Not Exactly."
|
26
|
+
```
|
27
|
+
|
28
|
+
## Installation
|
29
|
+
|
30
|
+
Add this line to your application's Gemfile:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
gem 'replace_quotes'
|
34
|
+
```
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install replace_quotes
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
In a Ruby script or console, enter the command `ReplaceQuotes.update(filename)`, where filename is the name of the file for which you wish to replace unnecessary double quotes with single quotes.
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
|
51
|
+
### Testing this gem
|
52
|
+
|
53
|
+
Enter `sh gem_test.sh`.
|
54
|
+
|
55
|
+
### Testing the source code
|
56
|
+
Enter `sh gem_code.sh`.
|
57
|
+
|
58
|
+
### Running this gem in irb
|
59
|
+
|
60
|
+
Enter `sh gem_console.sh`.
|
61
|
+
|
62
|
+
### Installing this gem
|
63
|
+
|
64
|
+
Enter `sh gem_install.sh`.
|
65
|
+
|
66
|
+
### Testing this gem and source code AND installing this gem
|
67
|
+
|
68
|
+
Enter `sh all.sh`.
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/replace_quotes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
73
|
+
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
78
|
+
|
data/Rakefile
ADDED
data/all.sh
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
gem uninstall replace_quotes
|
4
|
+
|
5
|
+
bin/setup
|
6
|
+
|
7
|
+
mkdir -p log/script
|
8
|
+
sh gem_test.sh 2>&1 | tee log/script/gem_test.log
|
9
|
+
sh code_test.sh 2>&1 | tee log/script/code_test.log
|
10
|
+
sh gem_install.sh 2>&1 | tee log/script/gem_install.log
|
11
|
+
|
12
|
+
echo 'Results are logged in:'
|
13
|
+
echo 'log/script/gem_test.log'
|
14
|
+
echo 'log/script/code_test.log'
|
15
|
+
echo 'log/script/gem_install.log'
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'replace_quotes'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/code_test.sh
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
gem uninstall replace_quotes
|
4
|
+
|
5
|
+
bin/setup
|
6
|
+
|
7
|
+
echo '----------'
|
8
|
+
echo 'rm -rf tmp'
|
9
|
+
rm -rf tmp
|
10
|
+
|
11
|
+
echo '-------'
|
12
|
+
echo 'rubocop'
|
13
|
+
rubocop
|
14
|
+
|
15
|
+
echo '-----------'
|
16
|
+
echo 'sandi_meter'
|
17
|
+
sandi_meter
|
18
|
+
|
19
|
+
echo '------------'
|
20
|
+
echo 'bundle-audit'
|
21
|
+
bundle-audit
|
22
|
+
|
23
|
+
echo '----------'
|
24
|
+
echo 'gemsurance'
|
25
|
+
gemsurance
|
data/gem_console.sh
ADDED
data/gem_install.sh
ADDED
data/gem_test.sh
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'replace_quotes/version'
|
2
|
+
require 'string_in_file'
|
3
|
+
|
4
|
+
#
|
5
|
+
module ReplaceQuotes
|
6
|
+
def self.update(path)
|
7
|
+
return if StringInFile.present('"', path) != true
|
8
|
+
path_old = path
|
9
|
+
path_new = "#{path_old}.new"
|
10
|
+
file_w = open(path_new, 'w')
|
11
|
+
File.readlines(path_old).each do |line|
|
12
|
+
if (line.include? '"') == true && (line.include? "'") == false
|
13
|
+
line_alt = line.tr('"', "'")
|
14
|
+
file_w.write(line_alt)
|
15
|
+
else
|
16
|
+
file_w.write(line)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
file_w.close
|
20
|
+
system("rm #{path_old}")
|
21
|
+
system("mv #{path_new} #{path_old}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
# Your new gem is a module by default. You may wish to use a class instead.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'replace_quotes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'replace_quotes'
|
8
|
+
spec.version = ReplaceQuotes::VERSION
|
9
|
+
spec.authors = ['Jason Hsu']
|
10
|
+
spec.email = ['rubygems@jasonhsu.com']
|
11
|
+
|
12
|
+
spec.summary = 'Replaces unnecessary double quotes with single quotes'
|
13
|
+
spec.description = 'Replaces unnecessary double quotes with single quotes'
|
14
|
+
spec.homepage = 'https://github.com/jhsu802701/replace_quotes'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'rubocop'
|
26
|
+
spec.add_development_dependency 'sandi_meter'
|
27
|
+
spec.add_development_dependency 'bundler-audit'
|
28
|
+
spec.add_development_dependency 'gemsurance'
|
29
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
30
|
+
|
31
|
+
spec.add_runtime_dependency 'string_in_file'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: replace_quotes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Hsu
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sandi_meter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler-audit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: gemsurance
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: codeclimate-test-reporter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: string_in_file
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Replaces unnecessary double quotes with single quotes
|
140
|
+
email:
|
141
|
+
- rubygems@jasonhsu.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".rubocop.yml"
|
149
|
+
- ".travis.yml"
|
150
|
+
- CODE_OF_CONDUCT.md
|
151
|
+
- Gemfile
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- all.sh
|
156
|
+
- bin/console
|
157
|
+
- bin/setup
|
158
|
+
- code_test.sh
|
159
|
+
- gem_console.sh
|
160
|
+
- gem_install.sh
|
161
|
+
- gem_test.sh
|
162
|
+
- lib/replace_quotes.rb
|
163
|
+
- lib/replace_quotes/version.rb
|
164
|
+
- replace_quotes.gemspec
|
165
|
+
- test_files/test1.txt
|
166
|
+
- test_files/test1a.txt
|
167
|
+
- test_files/test2.txt
|
168
|
+
- test_files/test2a.txt
|
169
|
+
- test_files/test3.txt
|
170
|
+
- test_files/test3a.txt
|
171
|
+
- test_files/test4.txt
|
172
|
+
- test_files/test4a.txt
|
173
|
+
homepage: https://github.com/jhsu802701/replace_quotes
|
174
|
+
licenses:
|
175
|
+
- MIT
|
176
|
+
metadata: {}
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
requirements: []
|
192
|
+
rubyforge_project:
|
193
|
+
rubygems_version: 2.4.5.1
|
194
|
+
signing_key:
|
195
|
+
specification_version: 4
|
196
|
+
summary: Replaces unnecessary double quotes with single quotes
|
197
|
+
test_files: []
|