-
Notifications
You must be signed in to change notification settings - Fork 349
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
Add podspec script_phases
DSL
#413
Conversation
278a9a3
to
45fa351
Compare
First run and green. |
@@ -585,12 +585,6 @@ def store_podspec(options = nil) | |||
|
|||
#--------------------------------------# | |||
|
|||
SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze |
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.
Thosed moved to specification.rb
, no logical changes here.
# @return [Array<Hash{String=>String}>] the normalized script phases array. | ||
# | ||
def _prepare_script_phases(value) | ||
if value |
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.
return unless value
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.
was cargo culting from the other methods :)
|
||
SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :show_env_vars_in_log].freeze | ||
|
||
ALL_SCRIPT_PHASE_KEYS = (SCRIPT_PHASE_REQUIRED_KEYS + SCRIPT_PHASE_OPTIONAL_KEYS).freeze |
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.
spec linter should validate this
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.
yeap working on that as we speak.
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.
tests added
6906c4b
to
4287d59
Compare
This needs a bit more time which I will spend some tomorrow and the next few days to flesh out. I basically want the container of the attribute to be an array of hashes as I want to preserve the order. Will update with a comment once its ready again. |
4287d59
to
90c9055
Compare
@@ -324,7 +329,11 @@ def merge_values(attr, existing_value, new_value) | |||
# | |||
def prepare_value(attr, value) | |||
if attr.container == Array | |||
value = [*value].compact | |||
value = if value.is_a?(Hash) |
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.
@segiddins this is the primary fix that helps me accomplish this. Basically I want to the container to be an "Array" for this attribute since I want to preserve the order in which the script phases are added.
However, without this change the Hash becomes an array and then I lose the ability to recreate the hashes from the arrays.
This is the first attribute that requires an array of hashes so this is probably why I hit this.
60abf96
to
88b1346
Compare
Alright, this is now ready again. I decided to format the DSL the same way it is in the Podfile DSL. In other words, users are required to specify |
88b1346
to
ec23ebf
Compare
@@ -376,11 +382,6 @@ def local? | |||
# | |||
# @overload supported_on_platform?(symbolic_name, deployment_target) | |||
# | |||
# @param [Symbol] symbolic_name |
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.
unused params, deleted the doc
30e9ac4
to
3b55e1e
Compare
# Converts the keys of the given hash to a string. | ||
# | ||
# @param [Object] value | ||
# the value that needs to be stripped from the Symbols. | ||
# | ||
# @return [Hash] the hash with the strings instead of the keys. | ||
# | ||
def convert_keys_to_string(value) | ||
def self.convert_keys_to_string(value) |
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.
for symmetry, decided to make this a class method as well as it maintains no state.
86edeaa
to
b3d7c0b
Compare
Alright this is set! I verified that passing wrong type to script phases fails at the linter level as well. Also JSON looks like: {
"name": "CannonPodder",
"version": "1.0.0",
"summary": "Small library that can be used to test CocoaPod stuff (new features, CI, building etc.)",
"homepage": "https://www.cannonpodder.com",
"license": {
"type": "Proprietary",
"text": "© 2017 Something, Inc."
},
"authors": {
"Someone": "someone@something.com"
},
"source": {
"git": "somewhere/in/git.git",
"tag": "1.0.0"
},
"platforms": {
"ios": "9.0",
"osx": "10.10"
},
"source_files": "Sources/**/*.{h,m}",
"private_header_files": "Sources/Internal/**/*.h",
"script_phases": [
{
"name": "Hello World",
"script": "echo \"Hello World\""
},
{
"name": "Hello Ruby World",
"script": "puts \"Hello World\"",
"shell_path": "/usr/bin/ruby"
}
],
"resource_bundles": {
"CannonPodderResources": [
"Resources/**/*"
]
},
"testspecs": [
{
"name": "Tests",
"test_type": "unit",
"source_files": "Tests/**/*.{h,m}",
"resource_bundles": {
"CannonPodderResourcesTests": [
"Tests/Resources/**/*"
]
}
}
]
} |
@paulb777 I believe you can now review and approve stuff :) Want to take a stab at this? |
b3d7c0b
to
ca6f465
Compare
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.
Awesome! Looking forward to using script_phases.
Thank you! I got one more PR after this that extends script phase DSL to add |
No description provided.