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

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

Constant Summary

Constants inherited from Model

Model::ALLOWED_OPTIONS

Instance Attribute Summary

Attributes inherited from Model

#mutable, #skip_validations

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



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

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



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

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



94
95
96
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 94

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.



90
91
92
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 90

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

#gem_nameObject



36
37
38
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 36

def gem_name
  kebab_case_full_project_name
end

#github_urlObject



132
133
134
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 132

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

#homepage_urlObject



128
129
130
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 128

def homepage_url
  github_url
end

#kebab_case_full_project_nameObject



32
33
34
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 32

def kebab_case_full_project_name
  Util.kebab_case(full_project_path.join)
end

#kebab_case_project_nameObject



28
29
30
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 28

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



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

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



51
52
53
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 51

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

#organization_module_nameObject



85
86
87
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 85

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

#organization_module_pathObject



81
82
83
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 81

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

#organization_nameObject



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

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



55
56
57
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 55

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

#project_module_nameObject



77
78
79
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 77

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

#project_module_pathObject



73
74
75
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 73

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

#project_nameObject



69
70
71
# File 'foobara-empty-ruby-project-generator-0.0.22/src/manifests/project_config.rb', line 69

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