Class: Pindo::Command::Utils::Renewproj
Constant Summary
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
#args_help_flag
Class Method Summary
collapse
Instance Method Summary
collapse
command_name, #initialize_options, run, use_cache?
#pindo_log_instance
#pindo_single_config
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, popen3, reader, which, which!
Constructor Details
#initialize(argv) ⇒ Renewproj
Returns a new instance of Renewproj.
59
60
61
62
63
|
# File 'lib/pindo/command/utils/renewproj.rb', line 59
def initialize(argv)
@project_name = argv.option('n')
@args_nocreate_flag = argv.flag?('nocreate')
super
end
|
Class Method Details
.options ⇒ Object
52
53
54
55
56
57
|
# File 'lib/pindo/command/utils/renewproj.rb', line 52
def self.options
[
['--n=', 'input project name'],
['--nocreate', 'no create xcode project'],
].concat(super)
end
|
Instance Method Details
#create_project(new_proj_name: nil, new_proj_path: nil, old_proj_name: nil, old_proj_path: nil) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/pindo/command/utils/renewproj.rb', line 84
def create_project(new_proj_name:nil, new_proj_path:nil, old_proj_name:nil, old_proj_path:nil)
new_proj_fullname = File.join(new_proj_path, new_proj_name) + ".xcodeproj"
Xcodeproj::Project.new(new_proj_fullname).save
new_proj_obj = Xcodeproj::Project.open(new_proj_fullname)
old_proj_fullname = File.join(old_proj_path, old_proj_name) + ".xcodeproj"
old_proj_obj = Xcodeproj::Project.open(old_proj_fullname)
Pindo::XcodeProjectHelper.copy_to_newproject(new_proj_path:new_proj_path, new_proj_name:new_proj_name, old_proj_path:old_proj_path, old_proj_name:old_proj_name)
Pindo::XcodeProjectHelper.create_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
Pindo::XcodeProjectHelper.add_file_to_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
Pindo::XcodeProjectHelper.config_project_target(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
Pindo::XcodeProjectHelper.setting_new_project(new_proj_name:new_proj_name, new_proj_path:new_proj_path, new_proj_obj:new_proj_obj, old_proj_name:old_proj_name, old_proj_path:old_proj_path, old_proj_obj:old_proj_obj)
end
|
#get_new_proj_path ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/pindo/command/utils/renewproj.rb', line 137
def get_new_proj_path
current_dir = Dir.pwd
temp_dir_name = @project_name + '_' +Time.now.strftime('%y%m%d_%H%M%S')
new_project_dir = File.join(File::expand_path(current_dir + "/../") , temp_dir_name)
if File.exist?(new_project_dir)
system 'sh rm -rf ' + new_project_dir
FileUtils.rm_rf(new_project_dir)
end
FileUtils.mkdir(new_project_dir)
return new_project_dir
end
|
#get_old_proj_name(old_proj_path: nil) ⇒ Object
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/pindo/command/utils/renewproj.rb', line 153
def get_old_proj_name(old_proj_path:nil)
old_project_fullname = ""
Dir.foreach(old_proj_path) do |file|
if file =~ /(.*).xcodeproj/
old_project_fullname = file
break;
end
end
old_proj_name = File.basename(old_project_fullname, ".xcodeproj")
return old_proj_name
end
|
#run ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/pindo/command/utils/renewproj.rb', line 106
def run
system 'pod deintegrate'
current_dir = Dir.pwd
old_project_dir = current_dir
old_proj_name = get_old_proj_name(old_proj_path:current_dir)
if @args_nocreate_flag
puts "2=================="
new_proj_name = old_proj_name
new_project_dir = old_project_dir
ENV['pindo_new_project_dir'] = old_project_dir
else
new_proj_name = @project_name
if new_proj_name.nil?
puts "Please input a new project name."
return
end
new_project_dir = get_new_proj_path
ENV['pindo_new_project_dir'] = new_project_dir
create_project(new_proj_name:new_proj_name, new_proj_path:new_project_dir, old_proj_name:old_proj_name, old_proj_path:old_project_dir)
end
if File.exist?(File.join(new_project_dir, 'Podfile.lock'))
FileUtils.rm_rf(File.join(new_project_dir, 'Podfile.lock'))
end
system "open #{new_project_dir}"
puts "New Project Dir: #{new_project_dir}"
puts "Done !"
end
|
#validate! ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/pindo/command/utils/renewproj.rb', line 65
def validate!
super
if @project_name.nil? || @project_name.empty?
if @config_json['project_info'] && @config_json['project_info']['project_name']
@project_name = @config_json['project_info']['project_name']
end
end
if @project_name.nil?
@project_name = ask('Project Name: ')
end
@project_name = "Example" if @project_name.nil? || @project_name.empty?
@project_name = @project_name.gsub(/ /, '');
@project_name = @project_name.gsub(/\'/, '');
puts "project_name = #{@project_name}"
end
|