Class: Crep::AppController
- Inherits:
-
Object
- Object
- Crep::AppController
- Defined in:
- lib/crep/app_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #app_versions_as_string_list(app_identifier) ⇒ Object
- #apps ⇒ Object
-
#initialize(app_source, identifier, version, build, versions_limit) ⇒ AppController
constructor
A new instance of AppController.
- #report_app(identifier, title) ⇒ Object
Constructor Details
#initialize(app_source, identifier, version, build, versions_limit) ⇒ AppController
Returns a new instance of AppController.
5 6 7 8 9 10 11 12 13 |
# File 'lib/crep/app_controller.rb', line 5 def initialize(app_source, identifier, version, build, versions_limit) @identifier = identifier&.downcase @version = version @build = build @versions_limit = versions_limit @app_source = app_source @app_source.configure end |
Class Method Details
.versions_as_string_list(versions, limit) ⇒ Object
43 44 45 46 47 |
# File 'lib/crep/app_controller.rb', line 43 def self.versions_as_string_list(versions, limit) versions.first(limit).map do |v| "#{v.version} (#{v.build})" end end |
Instance Method Details
#app_versions_as_string_list(app_identifier) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/crep/app_controller.rb', line 31 def app_versions_as_string_list(app_identifier) versions = @app_source.versions(app_identifier) filtered_versions = versions.select do |v| version_match = @version ? v.version == @version : true build_match = @build ? v.build == @build : true version_match && build_match end AppController.versions_as_string_list(filtered_versions, @versions_limit) end |
#apps ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/crep/app_controller.rb', line 15 def apps filtered_apps = @app_source.apps.select do |app| @identifier ? app.bundle_identifier.downcase == @identifier : true end filtered_apps.each do |app| report_app(app.public_identifier, app.title) end end |
#report_app(identifier, title) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/crep/app_controller.rb', line 24 def report_app(identifier, title) puts "\n\t\t" + title app_versions_as_string_list(identifier).each do |version_string| puts "\t\t#{version_string}" end end |