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)/(.+)}- PARTIALS_REGEX =
%r{\A(?-mix:^/?((marketplace_builder|app)/|modules/(.+)(private|public|marketplace_builder|app)/)?)(views/partials|lib)/(.+)}- 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)/(.+)}- 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{(?-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
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #[](name_or_relative_path) ⇒ Object
- #all ⇒ Object
- #api_calls ⇒ Object
- #assets ⇒ Object
- #emails ⇒ Object
- #forms ⇒ Object
- #graphqls ⇒ Object
- #grouped_files ⇒ Object
-
#initialize(storage) ⇒ App
constructor
A new instance of App.
- #layouts ⇒ Object
- #liquid ⇒ Object
- #notifications ⇒ Object
- #pages ⇒ Object
- #partials ⇒ Object
- #schema ⇒ Object
- #smses ⇒ Object
- #translations ⇒ Object
- #yaml ⇒ Object
Constructor Details
#initialize(storage) ⇒ App
Returns a new instance of App.
44 45 46 |
# File 'lib/platformos_check/app.rb', line 44 def initialize(storage) @storage = storage end |
Instance Attribute Details
#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
127 128 129 130 131 132 133 134 |
# File 'lib/platformos_check/app.rb', line 127 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.name == name_or_relative_path } end end |
#all ⇒ Object
123 124 125 |
# File 'lib/platformos_check/app.rb', line 123 def all @all ||= grouped_files.values.map(&:values).flatten end |
#api_calls ⇒ Object
115 116 117 |
# File 'lib/platformos_check/app.rb', line 115 def api_calls grouped_files[ApiCallFile]&.values || [] end |
#assets ⇒ Object
67 68 69 |
# File 'lib/platformos_check/app.rb', line 67 def assets grouped_files[AssetFile]&.values end |
#emails ⇒ Object
103 104 105 |
# File 'lib/platformos_check/app.rb', line 103 def emails grouped_files[EmailFile]&.values || [] end |
#forms ⇒ Object
91 92 93 |
# File 'lib/platformos_check/app.rb', line 91 def forms grouped_files[FormFile]&.values || [] end |
#graphqls ⇒ Object
107 108 109 |
# File 'lib/platformos_check/app.rb', line 107 def graphqls grouped_files[GraphqlFile]&.values || [] end |
#grouped_files ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/platformos_check/app.rb', line 48 def grouped_files @grouped_files ||= begin hash = {} REGEXP_MAP.each_value { |v| hash[v] = {} } storage.files.each do |path| regexp, klass = REGEXP_MAP.detect { |k, _v| k.match?(path) } if regexp f = klass.new(path, storage) hash[klass][f.name] = f elsif /\.liquid$/i.match?(path) hash[LiquidFile] ||= {} f = LiquidFile.new(path, storage) hash[LiquidFile][f.name] = f end end hash end end |
#layouts ⇒ Object
95 96 97 |
# File 'lib/platformos_check/app.rb', line 95 def layouts grouped_files[LayoutFile]&.values || [] end |
#liquid ⇒ Object
71 72 73 |
# File 'lib/platformos_check/app.rb', line 71 def liquid layouts + partials + forms + pages + notifications end |
#notifications ⇒ Object
99 100 101 |
# File 'lib/platformos_check/app.rb', line 99 def notifications emails + smses + api_calls end |
#pages ⇒ Object
119 120 121 |
# File 'lib/platformos_check/app.rb', line 119 def pages grouped_files[PageFile]&.values || [] end |
#partials ⇒ Object
87 88 89 |
# File 'lib/platformos_check/app.rb', line 87 def partials grouped_files[PartialFile]&.values || [] end |
#schema ⇒ Object
79 80 81 |
# File 'lib/platformos_check/app.rb', line 79 def schema grouped_files[SchemaFile]&.values || [] end |
#smses ⇒ Object
111 112 113 |
# File 'lib/platformos_check/app.rb', line 111 def smses grouped_files[SmsFile]&.values || [] end |
#translations ⇒ Object
83 84 85 |
# File 'lib/platformos_check/app.rb', line 83 def translations grouped_files[TranslationFile]&.values || [] end |
#yaml ⇒ Object
75 76 77 |
# File 'lib/platformos_check/app.rb', line 75 def yaml schema + translations end |