Class: ShopifyCLI::ProjectType

Inherits:
Object
  • Object
show all
Extended by:
Feature::Set
Defined in:
lib/shopify_cli/project_type.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Feature::Set

hidden?, hidden_feature

Class Attribute Details

.project_load_shallowObject

Returns the value of attribute project_load_shallow.



6
7
8
# File 'lib/shopify_cli/project_type.rb', line 6

def project_load_shallow
  @project_load_shallow
end

.project_nameObject

Returns the value of attribute project_name.



6
7
8
# File 'lib/shopify_cli/project_type.rb', line 6

def project_name
  @project_name
end

.project_typeObject

Returns the value of attribute project_type.



6
7
8
# File 'lib/shopify_cli/project_type.rb', line 6

def project_type
  @project_type
end

Class Method Details

.for_app_type(type) ⇒ Object



39
40
41
# File 'lib/shopify_cli/project_type.rb', line 39

def for_app_type(type)
  repository.find { |k| k.project_type.to_s == type.to_s }
end

.inherited(klass) ⇒ Object



15
16
17
18
19
20
# File 'lib/shopify_cli/project_type.rb', line 15

def inherited(klass)
  super
  repository << klass
  klass.project_type = @current_type
  klass.project_load_shallow = @shallow_load
end

.load_allObject



33
34
35
36
37
# File 'lib/shopify_cli/project_type.rb', line 33

def load_all
  Dir.glob(File.join(ShopifyCLI::ROOT, "lib", "project_types", "*", "cli.rb")).map do |filepath|
    load_type(filepath.split(File::Separator)[-2].to_sym, true)
  end
end

.load_type(current_type, shallow = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/shopify_cli/project_type.rb', line 22

def load_type(current_type, shallow = false)
  filepath = File.join(ShopifyCLI::ROOT, "lib", "project_types", current_type.to_s, "cli.rb")
  return unless File.exist?(filepath)
  @shallow_load = shallow
  @current_type = current_type
  load(filepath)
  @current_type = nil
  @shallow_load = false
  for_app_type(current_type)
end

.project_filepath(path) ⇒ Object



43
44
45
# File 'lib/shopify_cli/project_type.rb', line 43

def project_filepath(path)
  File.join(ShopifyCLI::PROJECT_TYPES_DIR, project_type.to_s, path)
end

.register_messages(messages) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/shopify_cli/project_type.rb', line 56

def register_messages(messages)
  # Make sure we don't attempt to register a file more than once as that will fail
  @registered_message_files ||= {}
  return if @registered_message_files.key?(@project_type)
  @registered_message_files[@project_type] = true

  Context.load_messages(messages)
end

.register_task(task, name) ⇒ Object



51
52
53
54
# File 'lib/shopify_cli/project_type.rb', line 51

def register_task(task, name)
  return if project_load_shallow
  ShopifyCLI::Tasks.register(task, name)
end

.repositoryObject Also known as: all_loaded



10
11
12
# File 'lib/shopify_cli/project_type.rb', line 10

def repository
  @repository ||= []
end

.title(name) ⇒ Object



47
48
49
# File 'lib/shopify_cli/project_type.rb', line 47

def title(name)
  @project_name = name
end