rmv 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/VERSION +1 -1
  2. data/bin/refact +12 -0
  3. data/bin/rmv +2 -21
  4. data/lib/rmv.rb +25 -0
  5. data/rmv.gemspec +5 -5
  6. metadata +25 -23
  7. data/lib/EMPTY +0 -0
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + "/../lib/rmv"
3
+
4
+ if ARGV.length != 2
5
+ abort "Usage: #{File.basename($0)} FROM TO"
6
+ end
7
+
8
+ from, to = ARGV
9
+ re = Regexp.compile(/(.*)(#{from})(.*)/)
10
+ target = "\\1#{to}\\3"
11
+
12
+ rmv(re, target)
data/bin/rmv CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + "/../lib/rmv"
2
3
 
3
4
  if ARGV.length != 2
4
5
  abort "Usage: rmv SOURCE_REGEX TARGET_WITH_SUBSTITUTIONS"
@@ -6,25 +7,5 @@ end
6
7
 
7
8
  re, target = ARGV
8
9
  re = Regexp.compile(re)
9
- require "fileutils"
10
- include FileUtils::Verbose
11
-
12
- files = Dir["**/*"].map do |path|
13
- if path =~ re
14
- [path, path.sub(re, target)]
15
- else
16
- nil
17
- end
18
- end.compact
19
-
20
- uniq_files = files.map{|f| f.last}.uniq
21
-
22
- if uniq_files.length != files.length
23
- (files.map{|f| f.last} - uniq_files).uniq
24
- abort "targets are not unique: #{(files - uniq_files).uniq.inspect}"
25
- end
26
-
27
- files.each do |from, to|
28
- mv from, to
29
- end
30
10
 
11
+ rmv(re, target)
@@ -0,0 +1,25 @@
1
+ require "fileutils"
2
+ include FileUtils::Verbose
3
+
4
+ def rmv(re, target)
5
+
6
+ files = Dir["**/*"].map do |path|
7
+ if path =~ re
8
+ [path, path.sub(re, target)]
9
+ else
10
+ nil
11
+ end
12
+ end.compact
13
+
14
+ uniq_files = files.map{|f| f.last}.uniq
15
+
16
+ if uniq_files.length != files.length
17
+ (files.map{|f| f.last} - uniq_files).uniq
18
+ abort "targets are not unique: #{(files - uniq_files).uniq.inspect}"
19
+ end
20
+
21
+ files.each do |from, to|
22
+ mv from, to
23
+ end
24
+
25
+ end
@@ -5,15 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rmv}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kyle Maxwell"]
12
- s.date = %q{2011-04-13}
13
- s.default_executable = %q{rmv}
12
+ s.date = %q{2011-04-16}
14
13
  s.description = %q{regex mv}
15
14
  s.email = %q{kyle@kylemaxwell.com}
16
- s.executables = ["rmv"]
15
+ s.executables = ["rmv", "refact"]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
19
18
  "README.rdoc"
@@ -26,8 +25,9 @@ Gem::Specification.new do |s|
26
25
  "README.rdoc",
27
26
  "Rakefile",
28
27
  "VERSION",
28
+ "bin/refact",
29
29
  "bin/rmv",
30
- "lib/EMPTY",
30
+ "lib/rmv.rb",
31
31
  "rmv.gemspec",
32
32
  "test/helper.rb",
33
33
  "test/test_rmv.rb"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmv
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kyle Maxwell
@@ -15,13 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-13 00:00:00 -07:00
19
- default_executable: rmv
18
+ date: 2011-04-16 00:00:00 -07:00
19
+ default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :development
24
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ name: shoulda
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
26
  - - ">="
@@ -30,12 +29,12 @@ dependencies:
30
29
  segments:
31
30
  - 0
32
31
  version: "0"
33
- name: shoulda
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
32
  prerelease: false
37
33
  type: :development
38
- requirement: &id002 !ruby/object:Gem::Requirement
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
38
  none: false
40
39
  requirements:
41
40
  - - ~>
@@ -46,12 +45,12 @@ dependencies:
46
45
  - 0
47
46
  - 0
48
47
  version: 1.0.0
49
- name: bundler
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
48
  prerelease: false
53
49
  type: :development
54
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: jeweler
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
55
54
  none: false
56
55
  requirements:
57
56
  - - ~>
@@ -62,12 +61,12 @@ dependencies:
62
61
  - 5
63
62
  - 2
64
63
  version: 1.5.2
65
- name: jeweler
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
64
  prerelease: false
69
65
  type: :development
70
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: rcov
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
71
70
  none: false
72
71
  requirements:
73
72
  - - ">="
@@ -76,12 +75,14 @@ dependencies:
76
75
  segments:
77
76
  - 0
78
77
  version: "0"
79
- name: rcov
80
- version_requirements: *id004
78
+ prerelease: false
79
+ type: :development
80
+ requirement: *id004
81
81
  description: regex mv
82
82
  email: kyle@kylemaxwell.com
83
83
  executables:
84
84
  - rmv
85
+ - refact
85
86
  extensions: []
86
87
 
87
88
  extra_rdoc_files:
@@ -95,8 +96,9 @@ files:
95
96
  - README.rdoc
96
97
  - Rakefile
97
98
  - VERSION
99
+ - bin/refact
98
100
  - bin/rmv
99
- - lib/EMPTY
101
+ - lib/rmv.rb
100
102
  - rmv.gemspec
101
103
  - test/helper.rb
102
104
  - test/test_rmv.rb
data/lib/EMPTY DELETED
File without changes