Class: MPaaSPodfile
- Inherits:
-
Object
- Object
- MPaaSPodfile
- Defined in:
- lib/cocoapods-mPaaS/mPaaSPodfile.rb
Instance Attribute Summary collapse
-
#localComponentJsonPath ⇒ Object
Returns the value of attribute localComponentJsonPath.
-
#localContentJsonFallback ⇒ Object
Returns the value of attribute localContentJsonFallback.
-
#localContentJsonPath ⇒ Object
Returns the value of attribute localContentJsonPath.
-
#mPaaSBaseline ⇒ Object
Returns the value of attribute mPaaSBaseline.
-
#mPaaSPodNames ⇒ Object
Returns the value of attribute mPaaSPodNames.
-
#mPaaSPodVersion ⇒ Object
Returns the value of attribute mPaaSPodVersion.
-
#mpaasRepoUrl ⇒ Object
Returns the value of attribute mpaasRepoUrl.
-
#mPaaSVersionCode ⇒ Object
Returns the value of attribute mPaaSVersionCode.
Instance Method Summary collapse
-
#initialize ⇒ MPaaSPodfile
constructor
A new instance of MPaaSPodfile.
- #mPaaS_baseline(baseline) ⇒ Object
- #mPaaS_local_component_json(path) ⇒ Object
- #mPaaS_local_content_json(path, fallback = false) ⇒ Object
- #mPaaS_pod(name, version_str = nil) ⇒ Object
- #mPaaS_repo_url(url) ⇒ Object
- #mPaaS_version_code(version_code) ⇒ Object
- #run(path) ⇒ Object
Constructor Details
#initialize ⇒ MPaaSPodfile
Returns a new instance of MPaaSPodfile.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 12 def initialize self.mPaaSPodNames = [] self.mPaaSBaseline = nil self.mPaaSPodVersion = nil self.mPaaSVersionCode = nil self.localComponentJsonPath = nil self.localContentJsonPath = nil self.localContentJsonFallback = false self.mpaasRepoUrl = nil end |
Instance Attribute Details
#localComponentJsonPath ⇒ Object
Returns the value of attribute localComponentJsonPath.
7 8 9 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 7 def localComponentJsonPath @localComponentJsonPath end |
#localContentJsonFallback ⇒ Object
Returns the value of attribute localContentJsonFallback.
9 10 11 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 9 def localContentJsonFallback @localContentJsonFallback end |
#localContentJsonPath ⇒ Object
Returns the value of attribute localContentJsonPath.
8 9 10 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 8 def localContentJsonPath @localContentJsonPath end |
#mPaaSBaseline ⇒ Object
Returns the value of attribute mPaaSBaseline.
4 5 6 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 4 def mPaaSBaseline @mPaaSBaseline end |
#mPaaSPodNames ⇒ Object
Returns the value of attribute mPaaSPodNames.
3 4 5 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 3 def mPaaSPodNames @mPaaSPodNames end |
#mPaaSPodVersion ⇒ Object
Returns the value of attribute mPaaSPodVersion.
5 6 7 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 5 def mPaaSPodVersion @mPaaSPodVersion end |
#mpaasRepoUrl ⇒ Object
Returns the value of attribute mpaasRepoUrl.
10 11 12 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 10 def mpaasRepoUrl @mpaasRepoUrl end |
#mPaaSVersionCode ⇒ Object
Returns the value of attribute mPaaSVersionCode.
6 7 8 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 6 def mPaaSVersionCode @mPaaSVersionCode end |
Instance Method Details
#mPaaS_baseline(baseline) ⇒ Object
28 29 30 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 28 def mPaaS_baseline(baseline) self.mPaaSBaseline = baseline end |
#mPaaS_local_component_json(path) ⇒ Object
36 37 38 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 36 def mPaaS_local_component_json(path) self.localComponentJsonPath = path end |
#mPaaS_local_content_json(path, fallback = false) ⇒ Object
40 41 42 43 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 40 def mPaaS_local_content_json(path, fallback = false) self.localContentJsonPath = path self.localContentJsonFallback = fallback end |
#mPaaS_pod(name, version_str = nil) ⇒ Object
23 24 25 26 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 23 def mPaaS_pod(name, version_str = nil) self.mPaaSPodNames << name self.mPaaSPodVersion ||= version_str if version_str end |
#mPaaS_repo_url(url) ⇒ Object
45 46 47 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 45 def mPaaS_repo_url(url) self.mpaasRepoUrl = url end |
#mPaaS_version_code(version_code) ⇒ Object
32 33 34 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 32 def mPaaS_version_code(version_code) self.mPaaSVersionCode = version_code end |
#run(path) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/cocoapods-mPaaS/mPaaSPodfile.rb', line 49 def run(path) LogTools.v "MPaaSPodfile Parsing (Regex mode): #{path}" proxy_evaluator = Object.new proxy_evaluator.instance_variable_set(:@mpaas_parser_instance, self) proxy_evaluator.define_singleton_method(:mPaaS_pod) do |name, *version| @mpaas_parser_instance.mPaaS_pod(name, version.first) end proxy_evaluator.define_singleton_method(:mPaaS_baseline) do |baseline| @mpaas_parser_instance.mPaaS_baseline(baseline) end proxy_evaluator.define_singleton_method(:mPaaS_version_code) do |version_code| @mpaas_parser_instance.mPaaS_version_code(version_code) end proxy_evaluator.define_singleton_method(:mPaaS_local_component_json) do |path| @mpaas_parser_instance.mPaaS_local_component_json(path) end proxy_evaluator.define_singleton_method(:mPaaS_local_content_json) do |path, fallback = false| @mpaas_parser_instance.mPaaS_local_content_json(path, fallback) end proxy_evaluator.define_singleton_method(:mPaaS_repo_url) do |url| @mpaas_parser_instance.mPaaS_repo_url(url) end mpaas_pod_regex = /^\s*mPaaS_pod\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*(?:#.*)?\s*$/ mpaas_baseline_regex = /^\s*mPaaS_baseline\s+['"]([^'"]+)['"]\s*(?:#.*)?\s*$/ mpaas_version_code_regex = /^\s*mPaaS_version_code\s+(\d+)\s*(?:#.*)?\s*$/ mpaas_local_component_regex = /^\s*mPaaS_local_component_json\s+['"]([^'"]+)['"]\s*(?:#.*)?\s*$/ mpaas_local_content_regex = /^\s*mPaaS_local_content_json\s+['"]([^'"]+)['"](?:\s*,\s*(true|false))?\s*(?:#.*)?\s*$/ mpaas_repo_url_regex = /^\s*mPaaS_repo_url\s+['"]([^'"]+)['"]\s*(?:#.*)?\s*$/ File.foreach(path) do |line| if (match = line.match(mpaas_pod_regex)) pod_name = match[1] pod_version = match[2] proxy_evaluator.mPaaS_pod(pod_name, pod_version) LogTools.v "Extracted mPaaS_pod: #{pod_name}, version: #{pod_version}" elsif (match = line.match(mpaas_baseline_regex)) baseline = match[1] proxy_evaluator.mPaaS_baseline(baseline) LogTools.v "Extracted mPaaS_baseline: #{baseline}" elsif (match = line.match(mpaas_version_code_regex)) version_code = match[1].to_i proxy_evaluator.mPaaS_version_code(version_code) LogTools.v "Extracted mPaaS_version_code: #{version_code}" elsif (match = line.match(mpaas_local_component_regex)) proxy_evaluator.mPaaS_local_component_json(match[1]) LogTools.v "Extracted mPaaS_local_component_json: #{match[1]}" elsif (match = line.match(mpaas_local_content_regex)) fallback = match[2] == 'true' proxy_evaluator.mPaaS_local_content_json(match[1], fallback) LogTools.v "Extracted mPaaS_local_content_json: #{match[1]}, fallback: #{fallback}" elsif (match = line.match(mpaas_repo_url_regex)) proxy_evaluator.mPaaS_repo_url(match[1]) LogTools.v "Extracted mPaaS_repo_url: #{match[1]}" end end LogTools.v "Final mPaaSPodNames: #{self.mPaaSPodNames.inspect}" LogTools.v "Final mPaaSBaseline: #{self.mPaaSBaseline}" LogTools.v "Final mPaaSPodVersion: #{self.mPaaSPodVersion}" LogTools.v "Final mPaaSVersionCode: #{self.mPaaSVersionCode}" rescue Exception => e LogTools.p_yellow Pod::MPAAS::Localization.t('mpaas.podfile.execute_error', message: e.) LogTools.p_yellow Pod::MPAAS::Localization.t('mpaas.podfile.error_stack_trace', backtrace: e.backtrace.join("\n")) end |