namer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/namer.rb +15 -5
- data/namer.gemspec +1 -1
- data/spec/namer_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7431a136f0186b985ed5385a62e94963c7fbe4a1
|
4
|
+
data.tar.gz: fac65f4bf4ac9a9e7bb0c9a0d8bc6264050b2feb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46582a68c19fd1dd3829f96b572e71616d952c78d770d8f8fbb50ea0b8d1516ebfe7f399af8553010b5f47f788f1bba08c683c59fe8f5ab88a731e435c9c16fd
|
7
|
+
data.tar.gz: 3855136a11c65f0bbe6dfd297883bf8ed360a0cf9467f5c6a62198e490af98d8a42a59a43d1c92985f41dcac06b86bc68cbf513607843f88e3725d41f9cf17d6
|
data/lib/namer.rb
CHANGED
@@ -7,9 +7,9 @@ class Namer
|
|
7
7
|
args.each do |arg|
|
8
8
|
next unless arg.include?(':')
|
9
9
|
@from, @to = arg.split(':')
|
10
|
-
rename
|
11
|
-
replace
|
12
|
-
rename_remote
|
10
|
+
rename unless args.include?('--no-rename')
|
11
|
+
replace unless args.include?('--no-replace')
|
12
|
+
rename_remote unless args.include?('--no-remote')
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -27,6 +27,11 @@ class Namer
|
|
27
27
|
str.gsub(from_regex, "\\1#{@to}\\2")
|
28
28
|
end
|
29
29
|
|
30
|
+
def inline_gsub(str)
|
31
|
+
return str unless split_str = str.split(/# -- replace\n/)[1]
|
32
|
+
split_str.gsub(/^\s*# /, '')
|
33
|
+
end
|
34
|
+
|
30
35
|
def rename_remote
|
31
36
|
url = remote
|
32
37
|
new_url = gsub(url)
|
@@ -54,8 +59,13 @@ class Namer
|
|
54
59
|
dir("**/*").each do |path|
|
55
60
|
next unless File.file?(path)
|
56
61
|
text = File.read(path)
|
57
|
-
|
58
|
-
|
62
|
+
begin
|
63
|
+
text = gsub(text)
|
64
|
+
text = inline_gsub(text)
|
65
|
+
rescue Exception => e
|
66
|
+
ensure
|
67
|
+
File.open(path, 'w') { |f| f.write(text) }
|
68
|
+
end
|
59
69
|
end
|
60
70
|
end
|
61
71
|
end
|
data/namer.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "namer"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["Winton Welsh"]
|
9
9
|
spec.email = ["mail@wintoni.us"]
|
10
10
|
spec.description = %q{Project template manager}
|
data/spec/namer_spec.rb
CHANGED
@@ -7,6 +7,10 @@ describe Namer do
|
|
7
7
|
FileUtils.rm_rf(fixture)
|
8
8
|
FileUtils.mkdir_p("#{fixture}/project")
|
9
9
|
|
10
|
+
File.open("#{fixture}/project.rb", 'w') do |f|
|
11
|
+
f.write("fail\n# -- replace\n# success")
|
12
|
+
end
|
13
|
+
|
10
14
|
File.open("#{fixture}/project/project.rb", 'w') do |f|
|
11
15
|
f.write("project\nProject\nMyProject")
|
12
16
|
end
|
@@ -19,6 +23,7 @@ describe Namer do
|
|
19
23
|
namer = Namer.new([ "project:new_project", "Project:NewProject" ])
|
20
24
|
namer.remote.should == "https://github.com/winton/new_project.git"
|
21
25
|
|
26
|
+
File.read("#{fixture}/new_project.rb").should == "success"
|
22
27
|
File.read("#{fixture}/new_project/new_project.rb").should == "new_project\nNewProject\nMyProject"
|
23
28
|
end
|
24
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: namer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|