Class: ProjectInstaller
- Inherits:
-
Object
- Object
- ProjectInstaller
- Defined in:
- lib/project_temple_installer.rb
Instance Method Summary collapse
- #add_all_to_group(path, target_group) ⇒ Object
- #downloadFile ⇒ Object
-
#initialize(*args) ⇒ ProjectInstaller
constructor
A new instance of ProjectInstaller.
- #install ⇒ Object
Constructor Details
#initialize(*args) ⇒ ProjectInstaller
Returns a new instance of ProjectInstaller.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/project_temple_installer.rb', line 5 def initialize(*args) @current_dir = Pathname.pwd Dir.foreach(@current_dir) do |filename| if filename.include? 'xcodeproj' project_path = "#{@current_dir}/#{filename}" @project_name = File.basename(filename) @project = Xcodeproj::Project.open project_path break end end end |
Instance Method Details
#add_all_to_group(path, target_group) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/project_temple_installer.rb', line 31 def add_all_to_group(path ,target_group) new_group = target_group.new_group(File.basename(path), path) if Dir.exist? path Dir.foreach(path) do |filename| next if filename == "." # 忽略当前目录 next if filename == ".." # 忽略上级目录 next if filename.start_with? "." # 忽略隐藏文件 file_path = "#{path}/#{filename}" if File.directory? file_path add_all_to_group file_path ,new_group else new_group.new_reference file_path puts "add #{file_path}\n" end end end |
#downloadFile ⇒ Object
24 25 26 27 28 29 |
# File 'lib/project_temple_installer.rb', line 24 def downloadFile download_command = "svn export https://github.com/kaich/ProjectTemple/trunk/ProjectTemple/Source" download_podfile = "svn export https://github.com/kaich/ProjectTemple/trunk/podfile" system download_command system download_podfile end |
#install ⇒ Object
17 18 19 20 21 22 |
# File 'lib/project_temple_installer.rb', line 17 def install downloadFile source_group = @project.main_group.children[0] add_all_to_group "#{@current_dir}/Source", source_group @project.save end |