Skip to content

Commit 89655e8

Browse files
committed
move cli functions to its own class
1 parent 5a100f5 commit 89655e8

File tree

5 files changed

+28
-46
lines changed

5 files changed

+28
-46
lines changed

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/bundled_cli_path.rb renamed to tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/bugsnag_cli.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
require 'os'
22
require 'rbconfig'
33

4-
class BundledCli
5-
def self.get_path
4+
class BugsnagCli
5+
def self.get_bugsnag_cli_path(params)
6+
bundled_bugsnag_cli_path = self.get_bundled_path
7+
bundled_bugsnag_cli_version = Gem::Version.new(`#{bundled_bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
8+
9+
if params[:bugsnag_cli_path]
10+
bugsnag_cli_path = params[:bugsnag_cli_path] || bundled_bugsnag_cli_path
11+
12+
bugsnag_cli_version = Gem::Version.new(`#{bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
13+
14+
if bugsnag_cli_version < bundled_bugsnag_cli_version
15+
UI.warning("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
16+
end
17+
bugsnag_cli_path
18+
else
19+
bundled_bugsnag_cli_path
20+
end
21+
end
22+
23+
def self.get_bundled_path
624
host_cpu = RbConfig::CONFIG['host_cpu']
725
if OS.mac?
826
if host_cpu =~ /arm|aarch64/

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/send_build_to_bugsnag.rb

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
require "xmlsimple"
22
require "json"
33
require_relative "find_info_plist_path"
4-
require_relative "bundled_cli_path"
4+
require_relative "bugsnag_cli"
55

66
module Fastlane
77
module Actions
88
class SendBuildToBugsnagAction < Action
9-
def self.get_bugsnag_cli_path(params)
10-
bundled_bugsnag_cli_path = BundledCli.get_path
11-
bundled_bugsnag_cli_version = Gem::Version.new(`#{bundled_bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
12-
13-
if params[:bugsnag_cli_path]
14-
bugsnag_cli_path = params[:bugsnag_cli_path] || bundled_bugsnag_cli_path
15-
16-
bugsnag_cli_version = Gem::Version.new(`#{bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
17-
18-
if bugsnag_cli_version < bundled_bugsnag_cli_version
19-
UI.warning("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
20-
end
21-
bugsnag_cli_path
22-
else
23-
bundled_bugsnag_cli_path
24-
end
25-
end
26-
279
def self.run(params)
28-
bugsnag_cli_path = get_bugsnag_cli_path(params)
10+
bugsnag_cli_path = BugsnagCli.get_bugsnag_cli_path(params)
2911
UI.verbose("Using bugsnag-cli from path: #{bugsnag_cli_path}")
3012

3113
payload = {}

tools/fastlane-plugin/lib/fastlane/plugin/bugsnag/actions/upload_symbols_to_bugsnag.rb

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
11
require_relative "find_info_plist_path"
2-
require_relative "bundled_cli_path"
2+
require_relative "bugsnag_cli"
33

44

55
module Fastlane
66
module Actions
77
class UploadSymbolsToBugsnagAction < Action
8-
def self.get_bugsnag_cli_path(params)
9-
bundled_bugsnag_cli_path = BundledCli.get_path
10-
bundled_bugsnag_cli_version = Gem::Version.new(`#{bundled_bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
11-
12-
if params[:bugsnag_cli_path]
13-
bugsnag_cli_path = params[:bugsnag_cli_path] || bundled_bugsnag_cli_path
14-
15-
bugsnag_cli_version = Gem::Version.new(`#{bugsnag_cli_path} --version`.scan(/(?:\d+\.?){3}/).first)
16-
17-
if bugsnag_cli_version < bundled_bugsnag_cli_version
18-
UI.warning("Your bugsnag-cli is outdated. The current bugsnag-cli version is: #{bundled_bugsnag_cli_version}")
19-
end
20-
bugsnag_cli_path
21-
else
22-
bundled_bugsnag_cli_path
23-
end
24-
end
25-
268
def self.run(params)
27-
bugsnag_cli_path = get_bugsnag_cli_path(params)
9+
bugsnag_cli_path = BugsnagCli.get_bugsnag_cli_path(params)
2810
UI.verbose("Using bugsnag-cli from path: #{bugsnag_cli_path}")
2911

3012
# If we have not explicitly set an API key through env, or parameter

tools/fastlane-plugin/spec/bugsnag_upload_dsym_action_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require 'spec_helper'
2-
require_relative '../lib/fastlane/plugin/bugsnag/actions/bundled_cli_path'
2+
require_relative '../lib/fastlane/plugin/bugsnag/actions/bugsnag_cli'
33

44
Action = Fastlane::Actions::UploadSymbolsToBugsnagAction
5-
BUGSNAG_CLI_PATH = BundledCli.get_path
5+
BUGSNAG_CLI_PATH = BugsnagCli.get_bundled_path
66

77
describe Action do
88
def run_with args

tools/fastlane-plugin/spec/send_build_to_bugsnag_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'spec_helper'
22
require 'json'
33
require 'fastlane/actions/get_info_plist_value'
4-
require_relative '../lib/fastlane/plugin/bugsnag/actions/bundled_cli_path'
4+
require_relative '../lib/fastlane/plugin/bugsnag/actions/bugsnag_cli'
55

66

77
BuildAction = Fastlane::Actions::SendBuildToBugsnagAction
8-
BUGSNAG_CLI_PATH = BundledCli.get_path
8+
BUGSNAG_CLI_PATH = BugsnagCli.get_bundled_path
99

1010

1111
describe BuildAction do

0 commit comments

Comments
 (0)