-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added 'pre' and 'post' setup blocks #174
base: master
Are you sure you want to change the base?
Changes from 1 commit
2c6db30
ae4579e
936b9fe
176f291
7f766b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,16 @@ def builder | |
end | ||
|
||
def setup(&block) | ||
config.setup_blocks << block | ||
config_without_setup.setup_blocks << block | ||
config.setup | ||
end | ||
|
||
def pre_setup(&block) | ||
config_without_setup.setup_blocks << block | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
def post_setup(&block) | ||
config_without_setup.post_setup_blocks << block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ok, so all that said, it wouldn't be any trouble to use a more explicit |
||
end | ||
|
||
def build(platform, opts={}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,8 @@ def self.make(template, project_dir, build_mode) | |
|
||
def initialize(project_dir, build_mode) | ||
@project_dir = project_dir | ||
@files = Dir.glob(File.join(project_dir, 'app/**/*.rb')) | ||
@files = [] | ||
@app_dir = 'app' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is, to me, the most controversial change. Previously in the The reason for the change is so that gems, using Oh, shoot, I just realized that using |
||
@build_mode = build_mode | ||
@name = 'Untitled' | ||
@resources_dirs = [File.join(project_dir, 'resources')] | ||
|
@@ -105,12 +106,32 @@ def setup_blocks | |
@setup_blocks ||= [] | ||
end | ||
|
||
def post_setup_blocks | ||
@post_setup_blocks ||= [] | ||
end | ||
|
||
def setup | ||
if @setup_blocks | ||
@setup_blocks.each { |b| b.call(self) } | ||
@setup_blocks = nil | ||
end | ||
|
||
if @post_setup_blocks | ||
@post_setup_blocks.each { |b| b.call(self) } | ||
end | ||
|
||
# should we include a check here for "already included app/ files"? it's | ||
# not necessary since this operation is idempotent. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m unclear as to why not to check it, especially since you do it after all :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh shoot, I just realized I refactored this in /Library/RubyMotion, and didn't copy that in. I'm gonna push that up (with comments to hopefully answer some of these questions) |
||
Dir.glob(File.join(project_dir, "#{@app_dir}/**/*.rb")).each do |app_file| | ||
@files << app_file unless @files.include?(app_file) | ||
end | ||
|
||
if @setup_blocks || @post_setup_blocks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you leave a comment as to why this is not needed with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
validate | ||
end | ||
|
||
@setup_blocks = nil | ||
@post_setup_blocks = nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Existing gems will be calling Also, this is a carryover - see line 111 of previous version. |
||
|
||
self | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calling
config
here is what causes some troubles, becauseconfig
ends up determining sdk and api versions. For instance, on android, I need to setapp.api_version = '19'
, otherwise I get an error about the "L" SDK not being installed.Which is fine until I include a gem, which calls
setup
, which callsconfig
, and goes looking for theapi_version
. My Rakefile'ssetup
hasn't been called, so it detects the wrong one, and errors out.