Skip to content

Commit

Permalink
Moving UI into one class.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Campbell committed Jul 3, 2016
1 parent 8db8d37 commit 4b40faf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
3 changes: 1 addition & 2 deletions lib/xcake/command/make.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ def run
file_path = "#{Dir.pwd}/Cakefile"

unless File.exist?(file_path)
#TODO: Make exception class for this
raise Xcake::Informative "Couldn't find Cakefile"
raise Xcake::Informative, "Couldn't find Cakefile"
end

EventHooks.run_hook :before_cakefile_read
Expand Down
7 changes: 1 addition & 6 deletions lib/xcake/context/xcodeproj_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,26 @@ def create_object_for(dsl_object)
when Node
create_object_for_node(dsl_object)
else
abort 'DSL Object not recognized!'
nil
end
end

def create_object_for_project(project)
UI.puts 'Creating Project...'

# TODO: Make setup of project testable
@project = Xcode::Project.new("./#{project.name}.xcodeproj", true)
@project.setup_for_xcake
@project
end

def create_object_for_target(target)
UI.puts 'Creating Target...'
@project.new_target(target)
end

def create_object_for_configuration(configuration)
UI.puts 'Creating Configuration...'
@project.new_configuration(configuration)
end

def create_object_for_node(node)
UI.puts 'Creating Group...'
@project.new_group(node)
end

Expand Down
8 changes: 8 additions & 0 deletions lib/xcake/event_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ class EventHooks
# Defines hook which is ran before we start reading the cakefile
#
define_hooks :before_cakefile_read

# Defines hook which is ran before we start creating the Xcode Project
#
define_hooks :before_creating_xcode_project

# Defines hook which is ran before we start creating a Target
#
define_hooks :before_creating_target
end
end
2 changes: 1 addition & 1 deletion lib/xcake/generator/project_metadata_generator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Xcake
class ProjectMetadataGenerator < Generator
def visit_project(project)
UI.puts 'Creating Project...'
EventHooks.run_hook :before_creating_xcode_project

native_project = @context.native_object_for(project)
native_project.class_prefix = project.class_prefix if project.class_prefix
Expand Down
2 changes: 1 addition & 1 deletion lib/xcake/generator/target_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def self.dependencies
end

def visit_target(target)
UI.puts "Creating target #{target.name}..."
EventHooks.run_hook :before_creating_target, target
@context.native_object_for(target)
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/xcake/informative.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
module Xcake
class Informative < StandardError
include CLAide::InformativeError

def message
"[!] #{super}".red
end
end
end
12 changes: 10 additions & 2 deletions lib/xcake/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ def self.register_ui_hooks

board = Cork::Board.new()

Xcake::EventHooks.after_cakefile_init do
EventHooks.after_cakefile_init do
board.notice('Open Cakefile to edit and run xcake make to get your xcode project')
end

Xcake::EventHooks.before_cakefile_read do
EventHooks.before_cakefile_read do
board.puts('Reading Cakefile...')
end

EventHooks.before_creating_xcode_project do
board.title('Creating Project')
end

EventHooks::before_creating_target do |target|
board.title("Creating target #{target.name}...")
end
end
end
end

0 comments on commit 4b40faf

Please sign in to comment.