Class: PlatformosCheck::App
- Inherits:
-
Object
- Object
- PlatformosCheck::App
- Defined in:
- lib/platformos_check/app.rb
Constant Summary collapse
- API_CALLS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/api_call_notifications|api_calls)/(.+)\.liquid\z}
- ASSETS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)assets/}
- EMAILS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/email_notifications|emails)/(.+)\.liquid\z}
- GRAPHQL_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(graph_queries|graphql)s?/(.+)\.graphql\z}
- MIGRATIONS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)migrations/(.+)\.liquid\z}
- PAGES_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(pages|views/pages)/(.+).liquid\z}
- PARTIALS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)\.liquid\z}
- FORMS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(form_configurations|forms)/(.+)\.liquid\z}
- LAYOUTS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(views/layouts)/(.+).liquid\z}
- SCHEMA_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(custom_model_types|model_schemas|schema)/(.+)\.yml\z}
- SMSES_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/sms_notifications|smses)/(.+)\.liquid\z}
- USER_SCHEMA_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/)?)user.yml}
- TRANSLATIONS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|(app/)?modules/(.+)(private|public|marketplace_builder|app)/)?)translations/(.+)\.yml}
- CONFIG_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/)?)config.yml}
- REGEXP_MAP =
{ API_CALLS_REGEX => ApiCallFile, ASSETS_REGEX => AssetFile, EMAILS_REGEX => EmailFile, GRAPHQL_REGEX => GraphqlFile, MIGRATIONS_REGEX => MigrationFile, PAGES_REGEX => PageFile, PARTIALS_REGEX => PartialFile, FORMS_REGEX => FormFile, LAYOUTS_REGEX => LayoutFile, SCHEMA_REGEX => SchemaFile, SMSES_REGEX => SmsFile, USER_SCHEMA_REGEX => UserSchemaFile, TRANSLATIONS_REGEX => TranslationFile, CONFIG_REGEX => ConfigFile }
- DEFAULT_LANGUAGE =
'en'
Instance Attribute Summary collapse
-
#grouped_files ⇒ Object
readonly
Returns the value of attribute grouped_files.
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #[](name_or_relative_path) ⇒ Object
- #all ⇒ Object
- #api_calls ⇒ Object
- #app_config ⇒ Object
- #assets ⇒ Object
- #default_language ⇒ Object
- #emails ⇒ Object
- #forms ⇒ Object
- #graphqls ⇒ Object
-
#initialize(storage) ⇒ App
constructor
A new instance of App.
- #layouts ⇒ Object
- #liquid ⇒ Object
- #notifications ⇒ Object
- #pages ⇒ Object
- #partials ⇒ Object
- #process_files(files, remove: false) ⇒ Object
- #schema ⇒ Object
- #smses ⇒ Object
- #translations ⇒ Object
- #translations_hash ⇒ Object
- #update(files, remove: false) ⇒ Object
- #yaml ⇒ Object
Constructor Details
#initialize(storage) ⇒ App
Returns a new instance of App.
46 47 48 49 50 51 |
# File 'lib/platformos_check/app.rb', line 46 def initialize(storage) @storage = storage @grouped_files = {} REGEXP_MAP.each_value { |v| @grouped_files[v] ||= {} } process_files(storage.files) end |
Instance Attribute Details
#grouped_files ⇒ Object (readonly)
Returns the value of attribute grouped_files.
44 45 46 |
# File 'lib/platformos_check/app.rb', line 44 def grouped_files @grouped_files end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
44 45 46 |
# File 'lib/platformos_check/app.rb', line 44 def storage @storage end |
Instance Method Details
#[](name_or_relative_path) ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/platformos_check/app.rb', line 145 def [](name_or_relative_path) case name_or_relative_path when Pathname all.find { |t| t.relative_path == name_or_relative_path } else all.find { |t| t.relative_path.to_s == name_or_relative_path } end end |
#all ⇒ Object
141 142 143 |
# File 'lib/platformos_check/app.rb', line 141 def all grouped_files.values.map(&:values).flatten end |
#api_calls ⇒ Object
129 130 131 |
# File 'lib/platformos_check/app.rb', line 129 def api_calls grouped_files[ApiCallFile]&.values || [] end |
#app_config ⇒ Object
137 138 139 |
# File 'lib/platformos_check/app.rb', line 137 def app_config grouped_files[ConfigFile]&.values&.first end |
#assets ⇒ Object
81 82 83 |
# File 'lib/platformos_check/app.rb', line 81 def assets grouped_files[AssetFile]&.values end |
#default_language ⇒ Object
154 155 156 |
# File 'lib/platformos_check/app.rb', line 154 def default_language DEFAULT_LANGUAGE end |
#emails ⇒ Object
117 118 119 |
# File 'lib/platformos_check/app.rb', line 117 def emails grouped_files[EmailFile]&.values || [] end |
#forms ⇒ Object
105 106 107 |
# File 'lib/platformos_check/app.rb', line 105 def forms grouped_files[FormFile]&.values || [] end |
#graphqls ⇒ Object
121 122 123 |
# File 'lib/platformos_check/app.rb', line 121 def graphqls grouped_files[GraphqlFile]&.values || [] end |
#layouts ⇒ Object
109 110 111 |
# File 'lib/platformos_check/app.rb', line 109 def layouts grouped_files[LayoutFile]&.values || [] end |
#liquid ⇒ Object
85 86 87 |
# File 'lib/platformos_check/app.rb', line 85 def liquid layouts + partials + forms + pages + notifications end |
#notifications ⇒ Object
113 114 115 |
# File 'lib/platformos_check/app.rb', line 113 def notifications emails + smses + api_calls end |
#pages ⇒ Object
133 134 135 |
# File 'lib/platformos_check/app.rb', line 133 def pages grouped_files[PageFile]&.values || [] end |
#partials ⇒ Object
101 102 103 |
# File 'lib/platformos_check/app.rb', line 101 def partials grouped_files[PartialFile]&.values || [] end |
#process_files(files, remove: false) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/platformos_check/app.rb', line 57 def process_files(files, remove: false) files.each do |path| regexp, klass = REGEXP_MAP.detect { |k, _v| k.match?(path) } next unless regexp f = klass.new(path, storage) if remove @grouped_files[klass].delete(f.name) if f.module_overwrite_file? && storage.files.include?(f.module_original_file_path) original_file = klass.new(f.module_original_file_path, storage) @grouped_files[klass][original_file.name] = original_file elsif f.module_original_file? && storage.files.include?(f.module_overwrite_file_path) overwrite_file = klass.new(f.module_overwrite_file_path, storage) @grouped_files[klass][overwrite_file.name] = overwrite_file end else # we want to keep the reference to a module overwrite, if exists @grouped_files[klass][f.name] = f unless f.module_original_file? && @grouped_files[klass][f.name] && @grouped_files[klass][f.name].module_overwrite_file? end end @grouped_files end |
#schema ⇒ Object
93 94 95 |
# File 'lib/platformos_check/app.rb', line 93 def schema grouped_files[SchemaFile]&.values || [] end |
#smses ⇒ Object
125 126 127 |
# File 'lib/platformos_check/app.rb', line 125 def smses grouped_files[SmsFile]&.values || [] end |
#translations ⇒ Object
97 98 99 |
# File 'lib/platformos_check/app.rb', line 97 def translations grouped_files[TranslationFile]&.values || [] end |
#translations_hash ⇒ Object
158 159 160 161 162 163 |
# File 'lib/platformos_check/app.rb', line 158 def translations_hash @translations_hash ||= translations.each_with_object({}) do |translation_file, hash| hash.deep_merge!(translation_file.content) hash end end |
#update(files, remove: false) ⇒ Object
53 54 55 |
# File 'lib/platformos_check/app.rb', line 53 def update(files, remove: false) process_files(files, remove:) end |
#yaml ⇒ Object
89 90 91 |
# File 'lib/platformos_check/app.rb', line 89 def yaml schema + translations end |