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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5c483c9e6777124fe091ed2c0690820f7652c8a93c66a3d3b9253cada57d2fc
4
- data.tar.gz: 38d7d216fd4e7a3bb3f1bef1485352037e4e2e60a87e3c97eda8db2952f82844
3
+ metadata.gz: d2d4f13c299246f00bae6051f341cbe768dd1e6bff6e605de3cd9e30e51f74a5
4
+ data.tar.gz: a0ff902ec617456bbffb774b918abdef9d87b32d967351611712a03092a0f277
5
5
  SHA512:
6
- metadata.gz: 7749435b2ddba65ebdfdf984cc1641d9246fb49b41ca1c109cf2a95637edab639c7196c6a880aa7068c9223110f05949218ceb79990aef7574c58326511d851d
7
- data.tar.gz: bc9a9eedf7bb86779ddf1f0b6a725a174a7decee735bd0879d556199f3888bec4ae29712a95f5c7754374a9b3f213782f0c2b8abd7d2ef5d703539b99ea82c3e
6
+ metadata.gz: 712074c23807b21810df46e94badaa78fd08b9bbe3bb38242505914ab63666efe0c645ad26a01349b0a6a364865e29d3aa2010c0f42fd19bdaeff0765ce93ad1
7
+ data.tar.gz: 696f74b7234ae7fe2498e489fa1e57bd57fe9104166a917d4e0267fa2027a026b3f98acc2c7ddf5b8f8f5c647b38e39043ee5817fc26e239556b1b99d8513ffe
@@ -4,3 +4,4 @@ rvm:
4
4
  - 2.2
5
5
  - 2.3
6
6
  - 2.4
7
+ - 2.5
@@ -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
- ## Experimental features
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
  ```
@@ -79,7 +79,7 @@ module Git
79
79
 
80
80
  def run_commands(commands)
81
81
  if options[:dry]
82
- commands.each { |args| puts args.join(' ') }
82
+ commands.each { |args| puts Array(args).join(' ') }
83
83
  else
84
84
  commands.each { |args| Open3.capture3(*args) }
85
85
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Gsub
3
- VERSION = '0.0.8'.freeze
3
+ VERSION = '0.0.9'.freeze
4
4
  end
5
5
  end
@@ -9,12 +9,9 @@ RSpec.configure do |config|
9
9
  end
10
10
 
11
11
  describe 'git-gsub' do
12
- def run_in_directory_with_a_file(filename, content)
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
- it 'should substitute files' do
29
- run_in_directory_with_a_file 'README.md', 'Git Subversion Bzr' do
30
- Git::Gsub.run %w[Bzr Mercurial]
31
- expect(File.read('README.md')).to eq 'Git Subversion Mercurial'
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
- run_in_directory_with_a_file 'README.md', 'GitGsub git_gsub git-gsub' do
37
- Git::Gsub.run %w[GitGsub SvnGsub --camel --kebab --snake]
38
- expect(File.read('README.md')).to eq 'SvnGsub svn_gsub svn-gsub'
39
- end
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
- run_in_directory_with_a_file 'README.md', %(<h1 class="foo">) do
44
- Git::Gsub.run [%(<h1 class="foo">), %(<h1 class="bar">)]
45
- expect(File.read('README.md')).to eq %(<h1 class="bar">)
46
- end
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
- run_in_directory_with_a_file 'README.md', %(Hello this is @git) do
51
- Git::Gsub.run [%(@git), %(@@svn)]
52
- expect(File.read('README.md')).to eq %(Hello this is @@svn)
53
- end
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
- run_in_directory_with_a_file 'README.md', %(Hello this is "git") do
58
- Git::Gsub.run [%("git"), %('svn')]
59
- expect(File.read('README.md')).to eq %(Hello this is 'svn')
60
- end
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
- run_in_directory_with_a_file 'README.md', %({git{svn}) do
65
- Git::Gsub.run [%({git{svn}), %({hg{svn})]
66
- expect(File.read('README.md')).to eq %({hg{svn})
67
- end
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
- run_in_directory_with_a_file 'README.md', %(foo@example.com) do
72
- Git::Gsub.run [%(@example), %(bar@example)]
73
- expect(File.read('README.md')).to eq %(foobar@example.com)
74
- end
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
- run_in_directory_with_a_file 'README.md', 'Git Subversion Bzr' do
79
- Git::Gsub.run %w[Bzr Darcs]
80
- expect(`ls`).to eql "README.md\n"
81
- end
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
- run_in_directory_with_a_file 'README-git_gsub.md', 'GitGsub git_gsub git-gsub' do
86
- Git::Gsub.run %w[GitGsub SvnGsub --snake --rename]
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
- run_in_directory_with_a_file 'lib/git.rb', 'puts "Git"' do
92
- Git::Gsub.run %w[git svn --camel --rename]
93
- expect(`ls lib`).to eql "svn.rb\n"
94
- expect(File.read('lib/svn.rb')).to eq 'puts "Svn"'
95
- end
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
- run_in_directory_with_a_file 'README-git_gsub.md', 'GitGsub git_gsub git-gsub' do
100
- expect {
101
- Git::Gsub.run %w[Atlanta Chicago --snake --rename]
102
- }.not_to raise_error
103
- end
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.8
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-06-01 00:00:00.000000000 Z
11
+ date: 2018-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport