Class: RXCode::Commands::Init
- Inherits:
-
RXCode::Command
- Object
- RXCode::Command
- RXCode::Commands::Init
- Defined in:
- lib/rxcode/commands/init.rb
Overview
Displays information about the current XCode environment
Constant Summary collapse
- TEMPLATE_FILES =
[ 'Gemfile', 'Rakefile', 'spec/spec_helper.rb', 'spec/support/.gitkeep' ]
Instance Attribute Summary
Attributes inherited from RXCode::Command
#arguments, #err, #input, #options, #output
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from RXCode::Command
command_class_for_name, command_names, commands, display_name, #env, inherited, #initialize, new_global_option_parser, run!, run_command
Constructor Details
This class inherits a constructor from RXCode::Command
Class Method Details
.new_command_option_parser ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rxcode/commands/init.rb', line 58 def self.new_command_option_parser Trollop::Parser.new do <<-TEXT Initializes the current project or workspace with RXCode. Usage: #{$0} [global options] init Options: TEXT end end |
Instance Method Details
#projects ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/rxcode/commands/init.rb', line 9 def projects if arguments.empty? [ '.' ] else arguments end end |
#run! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rxcode/commands/init.rb', line 24 def run! templates_path = File.("../../templates", __FILE__) projects.each do |project_path| if RXCode::Project.is_project_at_path?(project_path) || RXCode::Workspace.is_workspace_at_path?(project_path) project_path = File.dirname(project_path) end TEMPLATE_FILES.each do |template_name| template_path = File.join(templates_path, template_name) instance_path = File.join(project_path, template_name) if File.exist?(instance_path) output.puts "#{project_path.inspect} already exists" else # create any intermediate directories... FileUtils.mkdir_p(File.dirname(instance_path)) # ...and copy the file contents FileUtils.cp(template_path, instance_path) end end end end |