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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 663e385d757df24b6440c7d7e92ddd6b2202e11e
4
- data.tar.gz: 2ed6e778eb932f43ba439c7a7cd9867f7a4943c7
3
+ metadata.gz: 7431a136f0186b985ed5385a62e94963c7fbe4a1
4
+ data.tar.gz: fac65f4bf4ac9a9e7bb0c9a0d8bc6264050b2feb
5
5
  SHA512:
6
- metadata.gz: 1967de4a7095b418c48ff541aeec312a753b1eb7368e8e82301a493b6eee83859d85b046c84bb6f5a7c5f7436d741bd42211219e97ab55c02dd5c85ef0fd44b1
7
- data.tar.gz: 8298a1c94447cd3c53e3695fbeac6e714c9d91f400e9304ff9bcb6dbb5847ea694af792f728bd90a389887fcaf7f5a4100408609df6a84cd21a117c4ba2cd29f
6
+ metadata.gz: 46582a68c19fd1dd3829f96b572e71616d952c78d770d8f8fbb50ea0b8d1516ebfe7f399af8553010b5f47f788f1bba08c683c59fe8f5ab88a731e435c9c16fd
7
+ data.tar.gz: 3855136a11c65f0bbe6dfd297883bf8ed360a0cf9467f5c6a62198e490af98d8a42a59a43d1c92985f41dcac06b86bc68cbf513607843f88e3725d41f9cf17d6
@@ -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 unless args.include?('--no-rename')
11
- replace unless args.include?('--no-replace')
12
- rename_remote unless args.include?('--no-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
- next unless (text =~ from_regex rescue nil)
58
- File.open(path, 'w') { |f| f.write(gsub(text)) }
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
@@ -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.1"
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}
@@ -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.1
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-16 00:00:00.000000000 Z
11
+ date: 2013-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler