Class: Fastlane::Helper::NordalpAppPublishHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::NordalpAppPublishHelper
- Defined in:
- lib/fastlane/plugin/nordalp_app_publish/helper/nordalp_app_publish_helper.rb
Class Method Summary collapse
- .post_app(url_string, token_string, data_hash) ⇒ Object
- .read_first_changelog_entry(filename) ⇒ Object
Class Method Details
.post_app(url_string, token_string, data_hash) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fastlane/plugin/nordalp_app_publish/helper/nordalp_app_publish_helper.rb', line 35 def self.post_app(url_string, token_string, data_hash) response = HTTParty.post( url_string, { # HTTParty automatically converts the body (a Hash) to JSON # and sets the Content-Type header to application/json body: data_hash.to_json, headers: { 'Authenticate' => token_string, 'Content-Type' => 'application/json', 'Accept' => 'application/json' } } ) # HTTParty can optionally parse the response body if it's JSON { code: response.code, body: response.parsed_response # Accesses the parsed JSON response body } rescue StandardError => e { error: "An error occurred: #{e.message}" } end |
.read_first_changelog_entry(filename) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fastlane/plugin/nordalp_app_publish/helper/nordalp_app_publish_helper.rb', line 9 def self.read_first_changelog_entry(filename) return { error: "File not found: #{filename}" } unless File.exist?(filename) # Read the entire file content content = File.read(filename) # Regular expression to match the first H2 version entry version_regex = /^##\s+(\[([^\]]+)\]\(([^)]+)\)|[^(\r?\n]+)\s*\(([^)]+)\)\s*\r?\n(.*?)(?=\r?\n## |\z)/im match = content.match(version_regex) unless match return { error: 'No version entries found matching the expected format (## [version](link) (date))' } end # The version name is captured in Group 2 if it's a link, or Group 1 if it's plain text. version_name = match[2] || match[1]&.strip date = match[4] text = match[5].strip { version: version_name, date: date, text: text } end |