Skip to content

Commit

Permalink
Merge pull request #4 from jdee/target
Browse files Browse the repository at this point in the history
Target parameter
  • Loading branch information
jdee authored Apr 20, 2017
2 parents 3939dbe + e74325b commit b9b6edf
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 80 deletions.
32 changes: 24 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ Style/VariableNumber:
Style/MethodMissing:
Enabled: false

#
#
# File.chmod(0777, f)
#
#
# is easier to read than
#
#
# File.chmod(0o777, f)
#
#
Style/NumericLiteralPrefix:
Enabled: false

#
#
# command = (!clean_expired.nil? || !clean_pattern.nil?) ? CLEANUP : LIST
#
#
# is easier to read than
#
#
# command = !clean_expired.nil? || !clean_pattern.nil? ? CLEANUP : LIST
#
#
Style/TernaryParentheses:
Enabled: false

Expand Down Expand Up @@ -200,3 +200,19 @@ Style/IfInsideElse:
# Sometimes we just want to 'collect'
Style/CollectionMethods:
Enabled: false

# They have not to be snake_case
Style/FileName:
Exclude:
- '*.gemspec'
- '**/Dangerfile'
- '**/Brewfile'
- '**/Gemfile'
- '**/Podfile'
- '**/Rakefile'
- '**/Fastfile'
- '**/Deliverfile'
- '**/Snapfile'

Eval:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ source 'https://rubygems.org'

gemspec

gem 'simplecov'
gem 'rspec-simplecov'
gem 'simplecov'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval(File.read(plugins_path), binding) if File.exist?(plugins_path)
82 changes: 36 additions & 46 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,61 +1,54 @@
PATH
remote: .
specs:
fastlane-plugin-settings_bundle (1.0.1)
fastlane-plugin-settings_bundle (1.1.0)
plist
xcodeproj (>= 1.4.0)

GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.4)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.5.0)
CFPropertyList (2.3.5)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
ast (2.3.0)
babosa (1.0.2)
claide (1.0.1)
coderay (1.1.1)
colored (1.2)
commander (4.4.3)
colored2 (3.1.2)
commander-fastlane (4.4.4)
highline (~> 1.7.2)
diff-lcs (1.2.5)
diff-lcs (1.3)
docile (1.1.5)
domain_name (0.5.20161129)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.1.1)
excon (0.54.0)
faraday (0.10.0)
dotenv (2.2.0)
excon (0.55.0)
faraday (0.12.0.1)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.10.1)
faraday_middleware (0.11.0.1)
faraday (>= 0.7.4, < 1.0)
fastimage (2.0.1)
addressable (~> 2)
fastlane (2.3.1)
activesupport (< 5)
fastimage (2.1.0)
fastlane (2.27.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (~> 1.12)
bundler (>= 1.12.0, < 2.0.0)
colored
commander (>= 4.4.0, < 5.0.0)
commander-fastlane (>= 4.4.0, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
excon (>= 0.45.0, < 1.0.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (>= 1.6)
gh_inspector (>= 1.0.1, < 2.0.0)
google-api-client (~> 0.9.1)
google-api-client (~> 0.9.2)
highline (>= 1.7.2, < 2.0.0)
json (>= 2.0.1, < 3.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
multi_json
multi_xml (~> 0.5)
Expand All @@ -66,12 +59,13 @@ GEM
slack-notifier (>= 1.3, < 2.0.0)
terminal-notifier (>= 1.6.2, < 2.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (~> 0.5.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 0.20, < 2.0.0)
xcodeproj (>= 1.4.4, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.0.2)
google-api-client (0.9.20)
gh_inspector (1.0.3)
google-api-client (0.9.28)
addressable (~> 2.3)
googleauth (~> 0.5)
httpclient (~> 2.7)
Expand All @@ -93,11 +87,10 @@ GEM
domain_name (~> 0.5)
httpclient (2.8.3)
hurley (0.2)
i18n (0.7.0)
json (2.0.2)
json (2.1.0)
jwt (1.5.6)
little-plugger (1.1.4)
logging (2.1.0)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memoist (0.15.0)
Expand All @@ -106,21 +99,20 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
minitest (4.7.5)
multi_json (1.12.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nanaimo (0.2.3)
os (0.9.6)
parser (2.3.3.1)
parser (2.4.0.0)
ast (~> 2.2)
plist (3.2.0)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
public_suffix (2.0.4)
public_suffix (2.0.5)
rainbow (2.2.1)
rake (12.0.0)
representable (2.3.0)
Expand All @@ -141,21 +133,21 @@ GEM
rspec-support (~> 3.5.0)
rspec-simplecov (0.2.2)
rspec-support (3.5.0)
rubocop (0.46.0)
parser (>= 2.3.1.1, < 3.0)
rubocop (0.48.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rubyzip (1.2.0)
rubyzip (1.2.1)
security (0.1.3)
signet (0.7.3)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (~> 1.5)
multi_json (~> 1.10)
simplecov (0.12.0)
simplecov (0.14.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
Expand All @@ -165,21 +157,19 @@ GEM
terminal-notifier (1.7.1)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.5)
tzinfo (0.3.52)
tty-screen (0.5.0)
uber (0.0.15)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicode-display_width (1.1.2)
unf_ext (0.0.7.4)
unicode-display_width (1.1.3)
word_wrap (1.0.0)
xcodeproj (1.4.2)
xcodeproj (1.4.4)
CFPropertyList (~> 2.3.3)
activesupport (>= 3)
claide (>= 1.0.1, < 2.0)
colored (~> 1.2)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.4)
xcpretty (0.2.6)
rouge (~> 1.8)
xcpretty-travis-formatter (0.0.4)
xcpretty (~> 0.2, >= 0.0.7)
Expand All @@ -199,4 +189,4 @@ DEPENDENCIES
simplecov

BUNDLED WITH
1.13.7
1.14.6
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ update_settings_bundle(
)
```

#### Target parameter

By default, this action takes the settings from the first non-test, non-extension target in
the project. Use the optional :target parameter to specify a target by name.
```ruby
update_settings_bundle(
xcodeproj: "MyProject.xcodeproj",
key: "CurrentAppVersion",
value: ":version (:build)",
target: "MyAppTarget"
)
```

## Example

See the SettingsBundleExample subdirectory for a sample project that
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ RSpec::Core::RakeTask.new
require 'rubocop/rake_task'
RuboCop::RakeTask.new(:rubocop)

task default: [:spec, :rubocop]
task default: %i[spec rubocop]
5 changes: 1 addition & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ test:
- bundle exec rake
machine:
ruby:
version: 2.3.2
# Enable xcode below if you need macOS
# xcode:
# version: "7.3"
version: 2.4.0
9 changes: 5 additions & 4 deletions fastlane-plugin-settings_bundle.gemspec
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# coding: utf-8

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fastlane/plugin/settings_bundle/version'

Gem::Specification.new do |spec|
spec.name = 'fastlane-plugin-settings_bundle'
spec.version = Fastlane::SettingsBundle::VERSION
spec.author = %q{Jimmy Dee}
spec.email = %q{jgvdthree@gmail.com}
spec.author = 'Jimmy Dee'
spec.email = 'jgvdthree@gmail.com'

spec.summary = %q{Fastlane plugin to update static settings in an iOS settings bundle}
spec.summary = 'Fastlane plugin to update static settings in an iOS settings bundle'
spec.homepage = "https://github.com/jdee/settings-bundle"
spec.license = "MIT"

spec.files = Dir["lib/**/*"] + %w(README.md LICENSE)
spec.files = Dir["lib/**/*"] + %w[README.md LICENSE]
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ['lib']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UpdateSettingsBundleAction < Action
def self.run(params)
key = params[:key]
configuration = params[:configuration]
target_name = params[:target]
file = params[:file]
value = params[:value]

Expand All @@ -32,7 +33,7 @@ def self.run(params)

helper = Helper::SettingsBundleHelper

settings = helper.settings_from_project project, configuration
settings = helper.settings_from_project project, configuration, target_name

formatted_value = helper.formatted_value value, settings

Expand Down Expand Up @@ -89,6 +90,11 @@ def self.available_options
description: "The plist file in the Settings.bundle to update",
optional: true,
default_value: "Root.plist",
type: String),
FastlaneCore::ConfigItem.new(key: :file,
env_name: "SETTINGS_BUNDLE_TARGET",
description: "An optional target name from the project",
optional: true,
type: String)
]
end
Expand Down Expand Up @@ -124,6 +130,14 @@ def self.example_code
value: ":version (:build)",
configuration: "Debug"
)
EOF,
<<-EOF
update_settings_bundle(
xcodeproj: "MyProject.xcodeproj",
key: "CurrentAppVersion",
value: ":version (:build)",
target: "MyAppTarget"
)
EOF
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,17 @@ def formatted_value(value, settings)
#
# :project: An open Xcodeproj::Project via Xcodeproj::Project.open, e.g.
# :configuration: A valid build configuration in the project
def settings_from_project(project, configuration)
# find the first non-test, non-extension target
# TODO: Make this a :target parameter
target = project.targets.find { |t| !t.test_target_type? && !t.extension_target_type? }
raise "No application target found" if target.nil?
# :target_name: A valid target name in the project or nil to use the first application target
def settings_from_project(project, configuration, target_name)
if target_name
target = project.targets.find { |t| t.name == target_name }
raise "Target named \"#{target_name}\" not found" if target.nil?
else
# find the first non-test, non-extension target
# TODO: Make this a :target parameter
target = project.targets.find { |t| !t.test_target_type? && !t.extension_target_type? }
raise "No application target found" if target.nil?
end

# find the Info.plist paths for all configurations
info_plist_paths = target.resolved_build_setting "INFOPLIST_FILE"
Expand Down
2 changes: 1 addition & 1 deletion lib/fastlane/plugin/settings_bundle/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Fastlane
module SettingsBundle
VERSION = "1.0.1"
VERSION = "1.1.0"
end
end
Loading

0 comments on commit b9b6edf

Please sign in to comment.