Class: Gemsmith::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsmith/configuration.rb

Overview

Default configuration for gem with support for custom settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_name: "unknown", gem_class: "Unknown", git: Aids::Git, file_path: File.join(ENV["HOME"], Identity.file_name)) ⇒ Configuration

Returns a new instance of Configuration.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gemsmith/configuration.rb', line 13

def initialize gem_name: "unknown",
               gem_class: "Unknown",
               git: Aids::Git,
               file_path: File.join(ENV["HOME"], Identity.file_name)

  @gem_name = gem_name
  @gem_class = gem_class
  @file_path = file_path
  @git = git
  @settings = load_settings
end

Instance Attribute Details

#author_emailObject



49
50
51
# File 'lib/gemsmith/configuration.rb', line 49

def author_email
  @author_email || settings_group(:author).fetch(:email, git.config_value("user.email"))
end

#author_nameObject



45
46
47
# File 'lib/gemsmith/configuration.rb', line 45

def author_name
  @author_name || settings_group(:author).fetch(:name, git.config_value("user.name"))
end

#author_urlObject



53
54
55
# File 'lib/gemsmith/configuration.rb', line 53

def author_url
  @author_url || settings_group(:author).fetch(:url, "")
end

#create_cli=(value) ⇒ Object (writeonly)

Sets the attribute create_cli

Parameters:

  • value

    the value to set the attribute create_cli to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_cli=(value)
  @create_cli = value
end

#create_code_climate=(value) ⇒ Object (writeonly)

Sets the attribute create_code_climate

Parameters:

  • value

    the value to set the attribute create_code_climate to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_code_climate=(value)
  @create_code_climate = value
end

#create_gemnasium=(value) ⇒ Object (writeonly)

Sets the attribute create_gemnasium

Parameters:

  • value

    the value to set the attribute create_gemnasium to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_gemnasium=(value)
  @create_gemnasium = value
end

#create_git_hub=(value) ⇒ Object (writeonly)

Sets the attribute create_git_hub

Parameters:

  • value

    the value to set the attribute create_git_hub to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_git_hub=(value)
  @create_git_hub = value
end

#create_guard=(value) ⇒ Object (writeonly)

Sets the attribute create_guard

Parameters:

  • value

    the value to set the attribute create_guard to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_guard=(value)
  @create_guard = value
end

#create_patreon=(value) ⇒ Object (writeonly)

Sets the attribute create_patreon

Parameters:

  • value

    the value to set the attribute create_patreon to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_patreon=(value)
  @create_patreon = value
end

#create_pry=(value) ⇒ Object (writeonly)

Sets the attribute create_pry

Parameters:

  • value

    the value to set the attribute create_pry to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_pry=(value)
  @create_pry = value
end

#create_rails=(value) ⇒ Object (writeonly)

Sets the attribute create_rails

Parameters:

  • value

    the value to set the attribute create_rails to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_rails=(value)
  @create_rails = value
end

#create_rspec=(value) ⇒ Object (writeonly)

Sets the attribute create_rspec

Parameters:

  • value

    the value to set the attribute create_rspec to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_rspec=(value)
  @create_rspec = value
end

#create_rubocop=(value) ⇒ Object (writeonly)

Sets the attribute create_rubocop

Parameters:

  • value

    the value to set the attribute create_rubocop to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_rubocop=(value)
  @create_rubocop = value
end

#create_security=(value) ⇒ Object (writeonly)

Sets the attribute create_security

Parameters:

  • value

    the value to set the attribute create_security to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_security=(value)
  @create_security = value
end

#create_travis=(value) ⇒ Object (writeonly)

Sets the attribute create_travis

Parameters:

  • value

    the value to set the attribute create_travis to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def create_travis=(value)
  @create_travis = value
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



6
7
8
# File 'lib/gemsmith/configuration.rb', line 6

def file_path
  @file_path
end

#gem_classObject (readonly)

Returns the value of attribute gem_class.



6
7
8
# File 'lib/gemsmith/configuration.rb', line 6

def gem_class
  @gem_class
end

#gem_home_urlObject



29
30
31
# File 'lib/gemsmith/configuration.rb', line 29

def gem_home_url
  @gem_home_url || settings_group(:gem).fetch(:home_url, github_gem_url)
end

#gem_licenseObject



33
34
35
# File 'lib/gemsmith/configuration.rb', line 33

def gem_license
  @gem_license || settings_group(:gem).fetch(:license, "MIT")
end

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



6
7
8
# File 'lib/gemsmith/configuration.rb', line 6

def gem_name
  @gem_name
end

#gem_platformObject



25
26
27
# File 'lib/gemsmith/configuration.rb', line 25

def gem_platform
  @gem_platform || settings_group(:gem).fetch(:platform, "Gem::Platform::RUBY")
end

#gem_private_keyObject



37
38
39
# File 'lib/gemsmith/configuration.rb', line 37

def gem_private_key
  @gem_private_key || settings_group(:gem).fetch(:private_key, "~/.ssh/gem-private.pem")
end

#gem_public_keyObject



41
42
43
# File 'lib/gemsmith/configuration.rb', line 41

def gem_public_key
  @gem_public_key || settings_group(:gem).fetch(:public_key, "~/.ssh/gem-public.pem")
end

#github_userObject



121
122
123
# File 'lib/gemsmith/configuration.rb', line 121

def github_user
  @github_user || settings.fetch(:github_user, git.config_value("github.user"))
end

#organization_email=(value) ⇒ Object (writeonly)

Sets the attribute organization_email

Parameters:

  • value

    the value to set the attribute organization_email to.



7
8
9
# File 'lib/gemsmith/configuration.rb', line 7

def organization_email=(value)
  @organization_email = value
end

#organization_nameObject



57
58
59
# File 'lib/gemsmith/configuration.rb', line 57

def organization_name
  @organization_name || settings_group(:organization).fetch(:name, "")
end

#organization_urlObject



61
62
63
# File 'lib/gemsmith/configuration.rb', line 61

def organization_url
  @organization_url || settings_group(:organization).fetch(:url, "")
end

#rails_versionObject



69
70
71
# File 'lib/gemsmith/configuration.rb', line 69

def rails_version
  @rails_version || settings_group(:versions).fetch(:rails, "4.2")
end

#ruby_versionObject



65
66
67
# File 'lib/gemsmith/configuration.rb', line 65

def ruby_version
  @ruby_version || settings_group(:versions).fetch(:ruby, RUBY_VERSION)
end

#yearObject



125
126
127
# File 'lib/gemsmith/configuration.rb', line 125

def year
  @year || settings.fetch(:year, Time.now.year)
end

Instance Method Details

#create_cli?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/gemsmith/configuration.rb', line 73

def create_cli?
  parse_boolean @create_cli, :create, :cli, false
end

#create_code_climate?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/gemsmith/configuration.rb', line 105

def create_code_climate?
  parse_boolean @create_code_climate, :create, :code_climate, true
end

#create_gemnasium?Boolean

Returns:

  • (Boolean)


109
110
111
# File 'lib/gemsmith/configuration.rb', line 109

def create_gemnasium?
  parse_boolean @create_gemnasium, :create, :gemnasium, true
end

#create_git_hub?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'lib/gemsmith/configuration.rb', line 97

def create_git_hub?
  parse_boolean @create_git_hub, :create, :git_hub, false
end

#create_guard?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/gemsmith/configuration.rb', line 89

def create_guard?
  parse_boolean @create_guard, :create, :guard, true
end

#create_patreon?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/gemsmith/configuration.rb', line 117

def create_patreon?
  parse_boolean @create_patreon, :create, :patreon, true
end

#create_pry?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/gemsmith/configuration.rb', line 85

def create_pry?
  parse_boolean @create_pry, :create, :pry, true
end

#create_rails?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/gemsmith/configuration.rb', line 77

def create_rails?
  parse_boolean @create_rails, :create, :rails, false
end

#create_rspec?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/gemsmith/configuration.rb', line 93

def create_rspec?
  parse_boolean @create_rspec, :create, :rspec, true
end

#create_rubocop?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/gemsmith/configuration.rb', line 101

def create_rubocop?
  parse_boolean @create_rubocop, :create, :rubocop, true
end

#create_security?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/gemsmith/configuration.rb', line 81

def create_security?
  parse_boolean @create_security, :create, :security, true
end

#create_travis?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/gemsmith/configuration.rb', line 113

def create_travis?
  parse_boolean @create_travis, :create, :travis, true
end

#to_hObject



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/gemsmith/configuration.rb', line 129

def to_h
  {
    year: year,
    github_user: github_user,
    gem: {
      name: gem_name,
      class: gem_class,
      platform: gem_platform,
      home_url: gem_home_url,
      license: gem_license,
      private_key: gem_private_key,
      public_key: gem_public_key
    },
    author: {
      name: author_name,
      email: author_email,
      url: author_url
    },
    organization: {
      name: organization_name,
      url: organization_url
    },
    versions: {
      ruby: ruby_version,
      rails: rails_version
    },
    create: {
      cli: create_cli?,
      rails: create_rails?,
      security: create_security?,
      pry: create_pry?,
      guard: create_guard?,
      rspec: create_rspec?,
      rubocop: create_rubocop?,
      git_hub: create_git_hub?,
      code_climate: create_code_climate?,
      gemnasium: create_gemnasium?,
      travis: create_travis?,
      patreon: create_patreon?
    }
  }
end