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)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/api_call_notifications|api_calls)/(.+)\.liquid\z}- ASSETS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)assets/}- EMAILS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(notifications/email_notifications|emails)/(.+)\.liquid\z}- GRAPHQL_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(graph_queries|graphql)s?/(.+)\.graphql\z}- MIGRATIONS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)migrations/(.+)\.liquid\z}- PAGES_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(pages|views/pages)/(.+).liquid\z}- PARTIALS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)\.liquid\z}- FORMS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(form_configurations|forms)/(.+)\.liquid\z}- LAYOUTS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/layouts)/(.+).liquid\z}- SCHEMA_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(custom_model_types|model_schemas|schema)/(.+)\.yml\z}- SMSES_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|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)/|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 }
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
- #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
- #update(files, remove: false) ⇒ Object
- #yaml ⇒ Object
Constructor Details
#initialize(storage) ⇒ App
Returns a new instance of App.
44 45 46 47 48 49 |
# File 'lib/platformos_check/app.rb', line 44 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.
42 43 44 |
# File 'lib/platformos_check/app.rb', line 42 def grouped_files @grouped_files end |
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
42 43 44 |
# File 'lib/platformos_check/app.rb', line 42 def storage @storage end |
Instance Method Details
#[](name_or_relative_path) ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/platformos_check/app.rb', line 134 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
130 131 132 |
# File 'lib/platformos_check/app.rb', line 130 def all grouped_files.values.map(&:values).flatten end |
#api_calls ⇒ Object
118 119 120 |
# File 'lib/platformos_check/app.rb', line 118 def api_calls grouped_files[ApiCallFile]&.values || [] end |
#app_config ⇒ Object
126 127 128 |
# File 'lib/platformos_check/app.rb', line 126 def app_config grouped_files[ConfigFile]&.values&.first end |
#assets ⇒ Object
70 71 72 |
# File 'lib/platformos_check/app.rb', line 70 def assets grouped_files[AssetFile]&.values end |
#emails ⇒ Object
106 107 108 |
# File 'lib/platformos_check/app.rb', line 106 def emails grouped_files[EmailFile]&.values || [] end |
#forms ⇒ Object
94 95 96 |
# File 'lib/platformos_check/app.rb', line 94 def forms grouped_files[FormFile]&.values || [] end |
#graphqls ⇒ Object
110 111 112 |
# File 'lib/platformos_check/app.rb', line 110 def graphqls grouped_files[GraphqlFile]&.values || [] end |
#layouts ⇒ Object
98 99 100 |
# File 'lib/platformos_check/app.rb', line 98 def layouts grouped_files[LayoutFile]&.values || [] end |
#liquid ⇒ Object
74 75 76 |
# File 'lib/platformos_check/app.rb', line 74 def liquid layouts + partials + forms + pages + notifications end |
#notifications ⇒ Object
102 103 104 |
# File 'lib/platformos_check/app.rb', line 102 def notifications emails + smses + api_calls end |
#pages ⇒ Object
122 123 124 |
# File 'lib/platformos_check/app.rb', line 122 def pages grouped_files[PageFile]&.values || [] end |
#partials ⇒ Object
90 91 92 |
# File 'lib/platformos_check/app.rb', line 90 def partials grouped_files[PartialFile]&.values || [] end |
#process_files(files, remove: false) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/platformos_check/app.rb', line 55 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) else @grouped_files[klass][f.name] = f end end @grouped_files end |
#schema ⇒ Object
82 83 84 |
# File 'lib/platformos_check/app.rb', line 82 def schema grouped_files[SchemaFile]&.values || [] end |
#smses ⇒ Object
114 115 116 |
# File 'lib/platformos_check/app.rb', line 114 def smses grouped_files[SmsFile]&.values || [] end |
#translations ⇒ Object
86 87 88 |
# File 'lib/platformos_check/app.rb', line 86 def translations grouped_files[TranslationFile]&.values || [] end |
#update(files, remove: false) ⇒ Object
51 52 53 |
# File 'lib/platformos_check/app.rb', line 51 def update(files, remove: false) process_files(files, remove:) end |
#yaml ⇒ Object
78 79 80 |
# File 'lib/platformos_check/app.rb', line 78 def yaml schema + translations end |