-
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 all commits
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 | ||
end | ||
|
||
def pre_setup(&block) | ||
config_without_setup.pre_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 |
---|---|---|
|
@@ -78,7 +78,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')] | ||
|
@@ -106,16 +107,51 @@ def variables | |
map | ||
end | ||
|
||
def pre_setup_blocks | ||
@pre_setup_blocks ||= [] | ||
end | ||
|
||
def setup_blocks | ||
@setup_blocks ||= [] | ||
end | ||
|
||
def post_setup_blocks | ||
@post_setup_blocks ||= [] | ||
end | ||
|
||
def setup | ||
should_validate = false | ||
|
||
if @pre_setup_blocks | ||
@pre_setup_blocks.each { |b| b.call(self) } | ||
should_validate = true | ||
@pre_setup_blocks = nil | ||
end | ||
|
||
if @app_dir | ||
Dir.glob(File.join(project_dir, "#{@app_dir}/**/*.rb")).each do |app_file| | ||
@files << app_file unless @files.include?(app_file) | ||
end | ||
should_validate = true | ||
@app_dir = nil | ||
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. Ok, ignore the "controversial" stuff above, this restores the previous behavior, where |
||
|
||
if @setup_blocks | ||
@setup_blocks.each { |b| b.call(self) } | ||
should_validate = true | ||
@setup_blocks = nil | ||
end | ||
|
||
if @post_setup_blocks | ||
@post_setup_blocks.each { |b| b.call(self) } | ||
should_validate = true | ||
@post_setup_blocks = nil | ||
end | ||
|
||
if should_validate | ||
validate | ||
end | ||
|
||
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.