Class: PodBuilder::Info
- Inherits:
-
Object
- Object
- PodBuilder::Info
- Defined in:
- lib/pod_builder/info.rb
Class Method Summary collapse
- .generate_info ⇒ Object
- .pod_name_from_entry(line) ⇒ Object
- .prebuilt_info(path) ⇒ Object
- .version_info_from_entry(line) ⇒ Object
Class Method Details
.generate_info ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pod_builder/info.rb', line 5 def self.generate_info swift_version = PodBuilder::system_swift_version result = {} name = nil Dir.glob(PodBuilder::prebuiltpath("**/#{Configuration.prebuilt_info_filename}")).each do |json_path| name, prebuilt_info = prebuilt_info(json_path) result[name] = prebuilt_info end return result end |
.pod_name_from_entry(line) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/pod_builder/info.rb', line 20 def self.pod_name_from_entry(line) if (matches = line&.match(/pod '(.*?)'/)) && matches.size == 2 pod_name = matches[1] return pod_name end return "unknown_podname" end |
.prebuilt_info(path) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pod_builder/info.rb', line 67 def self.prebuilt_info(path) unless File.exist?(path) return {} end data = JSON.load(File.read(path)) result = {} if swift_version = data["swift_version"] result.merge!({ "swift_version": swift_version }) end pod_version = version_info_from_entry(data["entry"]) pod_name = pod_name_from_entry(data["entry"]) result.merge!({ "version": pod_version }) result.merge!({ "specs": (data["specs"] || []) }) result.merge!({ "is_static": (data["is_static"] || false) }) result.merge!({ "pb_version": (data["pb_version"] || "0.0.0") }) result.merge!({ "original_compile_path": (data["original_compile_path"] || "") }) return pod_name, result end |
.version_info_from_entry(line) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pod_builder/info.rb', line 30 def self.version_info_from_entry(line) if (matches = line&.match(/pod '(.*)', '=(.*)'/)) && matches.size == 3 pod_name = matches[1] tag = matches[2] return { "tag": tag } elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :commit => '(.*)'/)) && matches.size == 4 pod_name = matches[1] repo = matches[2] hash = matches[3] return { "repo": repo, "hash": hash } elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :branch => '(.*)'/)) && matches.size == 4 pod_name = matches[1] repo = matches[2] branch = matches[3] return { "repo": repo, "branch": branch } elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :tag => '(.*)'/)) && matches.size == 4 pod_name = matches[1] repo = matches[2] tag = matches[3] return { "repo": repo, "tag": tag } elsif (matches = line&.match(/pod '(.*)', :path => '(.*)'/)) && matches.size == 3 pod_name = matches[1] return { "repo": "local" } elsif (matches = line&.match(/pod '(.*)', :podspec => '(.*)'/)) && matches.size == 3 pod_name = matches[1] return { "repo": "local" } else raise "\n\nFailed extracting version from line:\n#{line}\n".red end end |