git-gsub 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +12 -0
- data/README.md +6 -1
- data/lib/git/gsub.rb +1 -1
- data/lib/git/gsub/version.rb +1 -1
- data/spec/git_gsub_spec.rb +82 -55
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2d4f13c299246f00bae6051f341cbe768dd1e6bff6e605de3cd9e30e51f74a5
|
4
|
+
data.tar.gz: a0ff902ec617456bbffb774b918abdef9d87b32d967351611712a03092a0f277
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712074c23807b21810df46e94badaa78fd08b9bbe3bb38242505914ab63666efe0c645ad26a01349b0a6a364865e29d3aa2010c0f42fd19bdaeff0765ce93ad1
|
7
|
+
data.tar.gz: 696f74b7234ae7fe2498e489fa1e57bd57fe9104166a917d4e0267fa2027a026b3f98acc2c7ddf5b8f8f5c647b38e39043ee5817fc26e239556b1b99d8513ffe
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.0.9]
|
5
|
+
### Fixed
|
6
|
+
- Make `--dry-run` works with `--rename`([#10](https://github.com/fujimura/git-gsub/pull/10))
|
7
|
+
|
8
|
+
## [0.0.8]
|
9
|
+
### Fixed
|
10
|
+
- Fix bug on passing file names to `Open3.capture3`[c05a05c](https://github.com/fujimura/git-gsub/commit/c05a05cd413d5a389c781b6649b42a46a825c4db)
|
11
|
+
|
12
|
+
## [0.0.7]
|
13
|
+
### Fixed
|
14
|
+
- Fix escaping @([#8](https://github.com/fujimura/git-gsub/pull/8)) Thanks @amatsuda!
|
15
|
+
|
4
16
|
## [0.0.6]
|
5
17
|
### Added
|
6
18
|
- Add option to substitute in camel/kebab/snake case
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Usage: git gsub [options] FROM TO [PATHS]
|
|
16
16
|
|
17
17
|
## Example
|
18
18
|
|
19
|
+
### Normal substutution
|
20
|
+
|
19
21
|
To substitute `Git` with `Subversion`:
|
20
22
|
|
21
23
|
```
|
@@ -47,7 +49,8 @@ index c30f093..03b7c4c 100755
|
|
47
49
|
+Subversion::Gsub.run
|
48
50
|
```
|
49
51
|
|
50
|
-
|
52
|
+
### Case-converting substitution
|
53
|
+
|
51
54
|
To substitute `CommonLisp` with `VisualBasic` with case-awareness:
|
52
55
|
|
53
56
|
```
|
@@ -66,6 +69,8 @@ index 2185dbf..393dbc6 100644
|
|
66
69
|
+# VisualBasic visual_basic visual-basic
|
67
70
|
```
|
68
71
|
|
72
|
+
### Substitute and rename file
|
73
|
+
|
69
74
|
Substitute and rename file:
|
70
75
|
|
71
76
|
```
|
data/lib/git/gsub.rb
CHANGED
data/lib/git/gsub/version.rb
CHANGED
data/spec/git_gsub_spec.rb
CHANGED
@@ -9,12 +9,9 @@ RSpec.configure do |config|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe 'git-gsub' do
|
12
|
-
def
|
12
|
+
def run_in_tmp_repo
|
13
13
|
Dir.mktmpdir do |dir|
|
14
14
|
Dir.chdir dir do
|
15
|
-
dirname = File.dirname(filename)
|
16
|
-
FileUtils.mkdir_p(dirname) unless File.exists?(dirname)
|
17
|
-
File.open(filename, 'w') { |f| f << content }
|
18
15
|
`git init`
|
19
16
|
`git config --local user.email "you@example.com"`
|
20
17
|
`git config --local user.name "Your Name"`
|
@@ -25,81 +22,111 @@ describe 'git-gsub' do
|
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
def commit_file(name, content)
|
26
|
+
FileUtils.mkdir_p(File.dirname(name))
|
27
|
+
File.write(name, content)
|
28
|
+
`git add .`
|
29
|
+
`git commit -m 'Add #{name}'`
|
30
|
+
end
|
31
|
+
|
32
|
+
around do |example|
|
33
|
+
run_in_tmp_repo do
|
34
|
+
example.run
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
38
|
+
it 'should substitute files' do
|
39
|
+
commit_file 'README.md', 'Git Subversion Bzr'
|
40
|
+
Git::Gsub.run %w[Bzr Mercurial]
|
41
|
+
|
42
|
+
expect(File.read('README.md')).to eq 'Git Subversion Mercurial'
|
43
|
+
end
|
44
|
+
|
35
45
|
it 'should substitute files with case conversion' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
46
|
+
commit_file 'README.md', 'GitGsub git_gsub git-gsub'
|
47
|
+
Git::Gsub.run %w[GitGsub SvnGsub --camel --kebab --snake]
|
48
|
+
|
49
|
+
expect(File.read('README.md')).to eq 'SvnGsub svn_gsub svn-gsub'
|
40
50
|
end
|
41
51
|
|
42
52
|
it 'should escape well' do
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
53
|
+
commit_file 'README.md', %(<h1 class="foo">)
|
54
|
+
Git::Gsub.run [%(<h1 class="foo">), %(<h1 class="bar">)]
|
55
|
+
|
56
|
+
expect(File.read('README.md')).to eq %(<h1 class="bar">)
|
47
57
|
end
|
48
58
|
|
49
|
-
it do
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
it 'should substutute @' do
|
60
|
+
commit_file 'README.md', %(foo@example.com)
|
61
|
+
Git::Gsub.run [%(@example), %(bar@example)]
|
62
|
+
|
63
|
+
expect(File.read('README.md')).to eq %(foobar@example.com)
|
54
64
|
end
|
55
65
|
|
56
|
-
it do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
it 'should substitute consequenting @' do
|
67
|
+
commit_file 'README.md', %(Hello this is @git)
|
68
|
+
Git::Gsub.run [%(@git), %(@@svn)]
|
69
|
+
|
70
|
+
expect(File.read('README.md')).to eq %(Hello this is @@svn)
|
61
71
|
end
|
62
72
|
|
63
|
-
it do
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
73
|
+
it %(should substitute " to ') do
|
74
|
+
commit_file 'README.md', %(Hello this is "git")
|
75
|
+
Git::Gsub.run [%("git"), %('svn')]
|
76
|
+
|
77
|
+
expect(File.read('README.md')).to eq %(Hello this is 'svn')
|
68
78
|
end
|
69
79
|
|
70
|
-
it do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
it %(should substitute ' to ") do
|
81
|
+
commit_file 'README.md', %(Hello this is 'git')
|
82
|
+
Git::Gsub.run [%('git'), %("svn")]
|
83
|
+
|
84
|
+
expect(File.read('README.md')).to eq %(Hello this is "svn")
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should substitute text including { and }'do
|
88
|
+
commit_file 'README.md', %({git{svn})
|
89
|
+
Git::Gsub.run [%({git{svn}), %({hg{svn})]
|
90
|
+
|
91
|
+
expect(File.read('README.md')).to eq %({hg{svn})
|
75
92
|
end
|
76
93
|
|
77
94
|
it 'should not create backup file' do
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
95
|
+
commit_file 'README.md', 'Git Subversion Bzr'
|
96
|
+
Git::Gsub.run %w[Bzr Darcs]
|
97
|
+
|
98
|
+
expect(`ls`).to eql "README.md\n"
|
82
99
|
end
|
83
100
|
|
84
101
|
it 'should rename with --rename' do
|
85
|
-
|
86
|
-
|
87
|
-
expect(`ls`).to eql "README-svn_gsub.md\n"
|
88
|
-
expect(File.read('README-svn_gsub.md')).to eq 'SvnGsub svn_gsub git-gsub'
|
89
|
-
end
|
102
|
+
commit_file 'README-git_gsub.md', 'GitGsub git_gsub git-gsub'
|
103
|
+
Git::Gsub.run %w[GitGsub SvnGsub --snake --rename]
|
90
104
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
105
|
+
expect(`ls`).to eql "README-svn_gsub.md\n"
|
106
|
+
expect(File.read('README-svn_gsub.md')).to eq 'SvnGsub svn_gsub git-gsub'
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should rename with --rename' do
|
110
|
+
commit_file 'lib/git.rb', 'puts "Git"'
|
111
|
+
Git::Gsub.run %w[git svn --camel --rename]
|
112
|
+
|
113
|
+
expect(`ls lib`).to eql "svn.rb\n"
|
114
|
+
expect(File.read('lib/svn.rb')).to eq 'puts "Svn"'
|
96
115
|
end
|
97
116
|
|
98
117
|
it 'should do nothing if no file found' do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
118
|
+
commit_file 'README-git_gsub.md', 'GitGsub git_gsub git-gsub'
|
119
|
+
|
120
|
+
expect {
|
121
|
+
Git::Gsub.run %w[Atlanta Chicago --snake --rename]
|
122
|
+
}.not_to raise_error
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should output command with dry-run' do
|
126
|
+
commit_file 'README-git_gsub.md', 'GitGsub git_gsub git-gsub'
|
127
|
+
|
128
|
+
expect {
|
129
|
+
Git::Gsub.run %w[GitGsub SvnGsub --snake --rename --dry-run]
|
130
|
+
}.to output(/Svn/).to_stdout
|
104
131
|
end
|
105
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-gsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fujimura Daisuke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|