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.



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

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



47
48
49
# File 'lib/gemsmith/configuration.rb', line 47

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

#author_nameObject



43
44
45
# File 'lib/gemsmith/configuration.rb', line 43

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

#author_urlObject



51
52
53
# File 'lib/gemsmith/configuration.rb', line 51

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.



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

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.



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

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.



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

def create_gemnasium=(value)
  @create_gemnasium = value
end

#create_guard=(value) ⇒ Object (writeonly)

Sets the attribute create_guard

Parameters:

  • value

    the value to set the attribute create_guard to.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

def create_travis=(value)
  @create_travis = value
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



4
5
6
# File 'lib/gemsmith/configuration.rb', line 4

def file_path
  @file_path
end

#gem_classObject (readonly)

Returns the value of attribute gem_class.



4
5
6
# File 'lib/gemsmith/configuration.rb', line 4

def gem_class
  @gem_class
end

#gem_home_urlObject



27
28
29
# File 'lib/gemsmith/configuration.rb', line 27

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

#gem_licenseObject



31
32
33
# File 'lib/gemsmith/configuration.rb', line 31

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

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



4
5
6
# File 'lib/gemsmith/configuration.rb', line 4

def gem_name
  @gem_name
end

#gem_platformObject



23
24
25
# File 'lib/gemsmith/configuration.rb', line 23

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

#gem_private_keyObject



35
36
37
# File 'lib/gemsmith/configuration.rb', line 35

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

#gem_public_keyObject



39
40
41
# File 'lib/gemsmith/configuration.rb', line 39

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

#github_userObject



115
116
117
# File 'lib/gemsmith/configuration.rb', line 115

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.



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

def organization_email=(value)
  @organization_email = value
end

#organization_nameObject



55
56
57
# File 'lib/gemsmith/configuration.rb', line 55

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

#organization_urlObject



59
60
61
# File 'lib/gemsmith/configuration.rb', line 59

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

#rails_versionObject



67
68
69
# File 'lib/gemsmith/configuration.rb', line 67

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

#ruby_versionObject



63
64
65
# File 'lib/gemsmith/configuration.rb', line 63

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

#yearObject



119
120
121
# File 'lib/gemsmith/configuration.rb', line 119

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

Instance Method Details

#create_cli?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/gemsmith/configuration.rb', line 71

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

#create_code_climate?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/gemsmith/configuration.rb', line 99

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

#create_gemnasium?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/gemsmith/configuration.rb', line 103

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

#create_guard?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/gemsmith/configuration.rb', line 87

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

#create_patreon?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/gemsmith/configuration.rb', line 111

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

#create_pry?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/gemsmith/configuration.rb', line 83

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

#create_rails?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/gemsmith/configuration.rb', line 75

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

#create_rspec?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/gemsmith/configuration.rb', line 91

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

#create_rubocop?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/gemsmith/configuration.rb', line 95

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

#create_security?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/gemsmith/configuration.rb', line 79

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

#create_travis?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/gemsmith/configuration.rb', line 107

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

#to_hObject



123
124
125
126
127
128
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
# File 'lib/gemsmith/configuration.rb', line 123

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?,
      code_climate: create_code_climate?,
      gemnasium: create_gemnasium?,
      travis: create_travis?,
      patreon: create_patreon?
    }
  }
end