Class: Foobara::Generators::EmptyRubyProjectGenerator::ProjectConfig

Inherits:
Model
  • Object
show all
Defined in:
foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb

Instance Attribute Summary

Attributes inherited from Model

#mutable

Instance Method Summary collapse

Methods inherited from Model

#==, abstract, abstract?, attribute_names, #attributes, #attributes_with_delegates, #cast_attribute, #cast_attribute!, closest_namespace_module, description, domain, domain_name, #eql?, foobara_model_name, foobara_name, full_model_name, #hash, #initialize, install!, organization_name, possible_errors, #read_attribute, #read_attribute!, reset_all, subclass, #to_h, #to_json, #valid?, valid_attribute_name?, #validate!, validate_attribute_name!, #validation_errors, #write_attribute, #write_attribute!, #write_attributes, #write_attributes!

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Constructor Details

This class inherits a constructor from Foobara::Model

Instance Method Details

#author_emailsObject



112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 112

def author_emails
  @author_emails ||= read_attribute(:author_emails) || begin
    # :nocov:
    email = `git config --get user.email`

    if $CHILD_STATUS.exitstatus == 0
      [email.strip]
    else
      raise "Must set author_emails because we can't get it from git for some reason"
    end
    # :nocov:
  end
end

#author_namesObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 96

def author_names
  # TODO: implement #[] or move it up to Model from Entity if it exists there.
  @author_names ||= read_attribute(:author_names) || begin
    # TODO: dump a git config file in CI so we don't have to skip this
    # :nocov:
    name = `git config --get user.name`

    if $CHILD_STATUS.exitstatus == 0
      [name.strip]
    else
      raise "Must set author_names because we can't get it from git for some reason"
    end
    # :nocov:
  end
end

#full_project_nameObject



92
93
94
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 92

def full_project_name
  @full_project_name ||= [organization_module_name, project_module_name].compact.join("::")
end

#full_project_pathObject

TODO: These two are not great names. Should have the word “module” in them.



88
89
90
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 88

def full_project_path
  @full_project_path ||= full_module_name&.split("::") || [*organization_module_path, *project_module_path]
end

#gem_nameObject



34
35
36
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 34

def gem_name
  kebab_case_full_project_name
end

#github_urlObject



130
131
132
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 130

def github_url
  @github_url ||= "https://github.com/#{org_slash_project_kebab(organization_name, project_module_name)}"
end

#homepage_urlObject



126
127
128
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 126

def homepage_url
  github_url
end

#kebab_case_full_project_nameObject



30
31
32
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 30

def kebab_case_full_project_name
  Util.kebab_case(full_project_path.join)
end

#kebab_case_project_nameObject



26
27
28
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 26

def kebab_case_project_name
  Util.kebab_case(project_module_path.join)
end

#org_slash_project_kebab(organization_name = self.organization_name, project_name = self.project_name) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 38

def org_slash_project_kebab(organization_name = self.organization_name, project_name = self.project_name)
  org_part = Util.kebab_case(organization_name)&.gsub("::", "-")
  project_part = Util.kebab_case(project_name).gsub("::", "-")

  if org_part.nil? || org_part.empty?
    project_part
  else
    "#{org_part}/#{project_part}"
  end
end

#org_slash_project_underscoreObject



49
50
51
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 49

def org_slash_project_underscore
  org_slash_project_kebab.gsub("-", "_")
end

#organization_module_nameObject



83
84
85
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 83

def organization_module_name
  @organization_module_name ||= organization_module_path.join("::")
end

#organization_module_pathObject



79
80
81
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 79

def organization_module_path
  @organization_module_path ||= kebab_to_module_path(organization_name)
end

#organization_nameObject



57
58
59
60
61
62
63
64
65
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 57

def organization_name
  @organization_name ||= begin
    org_and_project = name.split("/")

    if org_and_project.size == 2
      org_and_project.first
    end
  end
end

#project_lib_file_pathObject



53
54
55
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 53

def project_lib_file_path
  full_project_path.map { |part| Util.underscore(part) }.join("/")
end

#project_module_nameObject



75
76
77
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 75

def project_module_name
  @project_module_name ||= project_module_path.join("::")
end

#project_module_pathObject



71
72
73
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 71

def project_module_path
  @project_module_path ||= kebab_to_module_path(project_name)
end

#project_nameObject



67
68
69
# File 'foobara-empty-ruby-project-generator-0.0.18/src/manifests/project_config.rb', line 67

def project_name
  @project_name ||= name.split("/").last
end