xcode-project-renamer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.textile +19 -0
- data/Rakefile +1 -0
- data/bin/xcode-project-renamer +6 -0
- data/lib/xcode-project-renamer.rb +89 -0
- data/lib/xcode-project-renamer/version.rb +7 -0
- data/xcode-project-renamer.gemspec +24 -0
- metadata +55 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.textile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
h1. XCodeProjectRenamer
|
2
|
+
|
3
|
+
Use this gem to deep rename any XCode project.
|
4
|
+
|
5
|
+
h2. Install
|
6
|
+
|
7
|
+
@gem install xcode-project-renamer@
|
8
|
+
|
9
|
+
h2. Usage
|
10
|
+
|
11
|
+
# Navigate into you project, right where you @*.xcodeproj@ file is located
|
12
|
+
# @xcode-project-renamer oldname newname@
|
13
|
+
|
14
|
+
h2. Example
|
15
|
+
|
16
|
+
You are having a project called @FaceTime@.
|
17
|
+
|
18
|
+
# Navigate to where the @FaceTime@ directory and the @FaceTime.xcodeproj@ is located.
|
19
|
+
# @xcode-project-renamer FaceTime Messages@
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require "xcode-project-renamer/version"
|
2
|
+
|
3
|
+
module Xcode
|
4
|
+
module Project
|
5
|
+
module Renamer
|
6
|
+
|
7
|
+
class Rename
|
8
|
+
|
9
|
+
# Initialize renamer with the oldname and the new name as arguments
|
10
|
+
def initialize
|
11
|
+
@from, @to = ARGV
|
12
|
+
@files, @allFiles = [], []
|
13
|
+
check_arguments
|
14
|
+
end
|
15
|
+
|
16
|
+
# Check weather both arguments are given, otherways we can't do nothing
|
17
|
+
def check_arguments
|
18
|
+
if @from.nil? or @to.nil?
|
19
|
+
puts ""
|
20
|
+
puts "Sorry, missing the names!"
|
21
|
+
puts "-> Usage: xcodeprojectrenamer oldname newname"
|
22
|
+
puts ""
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Start the actual renaming consisting of two tasks:
|
28
|
+
# * Rename the files in the directories
|
29
|
+
# * Rename the files contents to reflect the new files names
|
30
|
+
def rename!
|
31
|
+
puts ""
|
32
|
+
puts "Renaming from #{@from} to #{@to}"
|
33
|
+
|
34
|
+
rename_files
|
35
|
+
rename_contents
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def rename_files
|
40
|
+
|
41
|
+
# Collect files
|
42
|
+
Dir.glob("#{@from}/**/*.*").each { |file| @files << file }
|
43
|
+
Dir.glob("#{@from}.xcodeproj/**/*.*").each { |file| @files << file }
|
44
|
+
@files << @from if File.exists? @from
|
45
|
+
@files << "#{@from}.xcodeproj" if File.exists? @from
|
46
|
+
|
47
|
+
# Rename
|
48
|
+
@files.each { |file| rename(file) }
|
49
|
+
|
50
|
+
# Done
|
51
|
+
puts @files.empty? ? "-> Nothing to rename" : "Done."
|
52
|
+
puts ""
|
53
|
+
end
|
54
|
+
|
55
|
+
def rename_contents
|
56
|
+
|
57
|
+
# Collect all files
|
58
|
+
Dir.glob("#{@to}/**/*.*").each { |file| @allFiles << file }
|
59
|
+
Dir.glob("#{@to}.xcodeproj/**/*.*").each { |file| @allFiles << file }
|
60
|
+
|
61
|
+
# Replace @from with @to
|
62
|
+
@allFiles.each do |file|
|
63
|
+
next if File.directory? file
|
64
|
+
content = File.read file
|
65
|
+
puts "Replacing #{@from} -> #{@to} in: #{file}"
|
66
|
+
new_content = content.gsub @from, @to rescue next
|
67
|
+
File.open(file, "w") { |new_file| new_file.puts new_content}
|
68
|
+
end
|
69
|
+
|
70
|
+
# Done
|
71
|
+
puts "Done."
|
72
|
+
puts ""
|
73
|
+
end
|
74
|
+
|
75
|
+
def rename old_name
|
76
|
+
dirname = File.dirname old_name
|
77
|
+
basename = File.basename old_name
|
78
|
+
new_basename = basename.gsub @from, @to
|
79
|
+
new_name = "#{dirname}/#{new_basename}"
|
80
|
+
|
81
|
+
puts "Renaming -> #{old_name} -> #{new_name}"
|
82
|
+
File.rename old_name, new_name
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "xcode-project-renamer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "xcode-project-renamer"
|
7
|
+
s.version = Xcode::Project::Renamer::VERSION
|
8
|
+
s.authors = ["Thomas Fankhauser"]
|
9
|
+
s.email = ["tommylefunk@googlemail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Deep rename your whole XCode project with a single command}
|
12
|
+
s.description = %q{Project renaming is a pain with XCode. Use this gem to rename any XCode project in a very simple way}
|
13
|
+
|
14
|
+
s.rubyforge_project = "xcode-project-renamer"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xcode-project-renamer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Fankhauser
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Project renaming is a pain with XCode. Use this gem to rename any XCode
|
15
|
+
project in a very simple way
|
16
|
+
email:
|
17
|
+
- tommylefunk@googlemail.com
|
18
|
+
executables:
|
19
|
+
- xcode-project-renamer
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- README.textile
|
26
|
+
- Rakefile
|
27
|
+
- bin/xcode-project-renamer
|
28
|
+
- lib/xcode-project-renamer.rb
|
29
|
+
- lib/xcode-project-renamer/version.rb
|
30
|
+
- xcode-project-renamer.gemspec
|
31
|
+
homepage: ''
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project: xcode-project-renamer
|
51
|
+
rubygems_version: 1.8.15
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: Deep rename your whole XCode project with a single command
|
55
|
+
test_files: []
|