redipress 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7e665f99ad7e65f8e7a770bb89bac107f18f4e6
4
- data.tar.gz: 5cc3cd1b8e45d9d2e9695dc2aa830ae712d789b9
3
+ metadata.gz: 5c2e37489ceb11c694ea9f30235bd11ea7851606
4
+ data.tar.gz: 3cab0d8cff4698e51f41404e608cd4b14ad12fd2
5
5
  SHA512:
6
- metadata.gz: bab2878d07607c672a8965d10214bd3db1b886dd8e88ed9a4704560ba80b4cc8d992ac265d8329edaca343f898aba93eee0c73f30ba842a4f9821a04c5aab2e5
7
- data.tar.gz: ad7b794fbcf2a16fe31c29a3b2fa2b9f5371a2d23ee0d7dd73abfc9bc4f199a62302b3a1259124cf48a5bdf31e591c92185045b599e4429e67e4b933734217d5
6
+ metadata.gz: a4ee018f270c481ef65b7b41caa97aafd7e40c160919c96a49619ce1466bbb6120f4dedb563625098727257568abe7f7a8c756024e593cbfd46c5abdde3cb18b
7
+ data.tar.gz: 2f0a25992565743ae1bf9f05d4221fecf1d153a8a607ad5bf920c6e0edfc2a2c0bbfa6966f08446d4e84407d7fd4c04c436ea227dae7ef4ded31bc32a59aafee
@@ -174,6 +174,9 @@ module RediPress
174
174
  if password
175
175
  # Set the password on the host
176
176
  host.password = password
177
+ else
178
+ # Load all ssh keys
179
+ RediPress::SSHKeys.load_ssh_keys
177
180
  end
178
181
 
179
182
  host
@@ -232,7 +235,7 @@ module RediPress
232
235
  configuration.parameters.each do |parameter|
233
236
  if :text == parameter.type
234
237
  options[parameter.slug] = prompt.ask(" #{parameter.name}:") do |q|
235
- q.required(true)
238
+ q.required(parameter.required)
236
239
  q.validate(parameter.validation) if parameter.validation
237
240
  q.default(parameter.default) if parameter.default
238
241
  end
@@ -12,9 +12,6 @@ module RediPress
12
12
  # => nil
13
13
  #
14
14
  def prepare
15
- # Load all ssh keys
16
- RediPress::SSHKeys.load_ssh_keys
17
-
18
15
  # Set the SSH Kit output verbosity to debug if verbose is enabled
19
16
  SSHKit.config.output_verbosity = Logger::DEBUG if options[:verbose]
20
17
 
@@ -23,11 +23,21 @@ module RediPress
23
23
  # >> name "Test"
24
24
  # >> end
25
25
  #
26
- def name(name = nil)
27
- name.nil? ? @name : @name = name
26
+ def name(name)
27
+ @name = name
28
28
  end
29
29
 
30
- # Add a parameter
30
+ # Get the name of the configuration
31
+ #
32
+ # Example:
33
+ # >> configuration.class._name
34
+ # => "Test"
35
+ #
36
+ def _name
37
+ @name
38
+ end
39
+
40
+ # Add a parameter to the configuration
31
41
  #
32
42
  # Arguments:
33
43
  # slug: (String)
@@ -40,16 +50,28 @@ module RediPress
40
50
  # >> end
41
51
  # >> end
42
52
  #
43
- def parameter(slug = nil, &block)
53
+ def parameter(slug, &block)
54
+ return nil if slug.nil?
55
+
44
56
  @parameters ||= []
45
57
 
46
- return @parameters if slug.nil?
58
+ return @parameters if @parameters.map { |p| p.slug }.include?(slug)
47
59
 
48
60
  parameter = RediPress::Parameter.new(slug)
49
61
  parameter.instance_eval(&block) if block_given?
50
62
 
51
63
  @parameters << parameter
52
64
  end
65
+
66
+ # Get the array of parameters for the configuration
67
+ #
68
+ # Example:
69
+ # >> configuration.class._parameters
70
+ # => [#<RediPress::Configuration::Parameter:0x00000000000000>]
71
+ #
72
+ def _parameters
73
+ @parameters
74
+ end
53
75
  end
54
76
 
55
77
  # Get the slug of the configuration
@@ -69,17 +91,17 @@ module RediPress
69
91
  # => "Test"
70
92
  #
71
93
  def name
72
- self.class.name
94
+ self.class._name
73
95
  end
74
96
 
75
97
  # Get the parameters for the configuration
76
98
  #
77
99
  # Example:
78
100
  # >> configuration.parameters
79
- # => nil
101
+ # => [#<RediPress::Configuration::Parameter:0x00000000000000>]
80
102
  #
81
103
  def parameters
82
- self.class.parameter
104
+ self.class._parameters
83
105
  end
84
106
 
85
107
  # Convert the class to a string
@@ -117,10 +139,13 @@ module RediPress
117
139
  #
118
140
  # Example:
119
141
  # >> configuration.configure(host, options)
120
- # => {}
142
+ # => nil
143
+ #
144
+ # Raises:
145
+ # RediPress::ConfigurationNotImplemented: If this method is not overriden
121
146
  #
122
147
  def configure(host, options)
123
- raise RediPress::SetupNotImplemented
148
+ raise RediPress::ConfigurationNotImplemented
124
149
  end
125
150
 
126
151
  # Fail with an error
@@ -133,7 +158,7 @@ module RediPress
133
158
  # => nil
134
159
  #
135
160
  # Raises:
136
- # RediPress::ConfigurationFailed: When this function is called
161
+ # RediPress::ConfigurationFailed: When this method is called
137
162
  #
138
163
  def fail(error)
139
164
  raise RediPress::ConfigurationFailed.new(self, error)
@@ -25,11 +25,11 @@ module RediPress
25
25
  end
26
26
  end
27
27
 
28
- # A RuntimeError subclass for when the setup function has not been implemented.
28
+ # A NotImplementedError subclass for when the 'configure' method has not been implemented by a Configuration.
29
29
  #
30
- class SetupNotImplemented < RuntimeError
30
+ class ConfigurationNotImplemented < NotImplementedError
31
31
  def to_s
32
- "The setup function has not been implemented by the configuration."
32
+ "The 'configure' method has not been implemented by the configuration."
33
33
  end
34
34
  end
35
35
 
@@ -6,22 +6,29 @@ module RediPress
6
6
  # This class holds all paramaters required by a configuration.
7
7
  #
8
8
  class Parameter
9
- attr_reader :slug, :options
9
+ attr_reader :slug, :required, :options
10
10
 
11
11
  # Setup an instance of the parameters class.
12
12
  #
13
+ # Arguments:
14
+ # slug: (String|Symbol)
15
+ #
13
16
  # Example:
14
17
  # >> RediPress::Parameter.new(:username)
15
- # => #<RediPress::Parameter:0x00000000000000 @slug=:username, @name="username">
18
+ # => #<RediPress::Parameter:0x00000000000000>
16
19
  #
17
20
  def initialize(slug)
18
21
  @slug = slug
19
22
  @name = slug.to_s
23
+ @required = true
20
24
  @type = :text
21
25
  end
22
26
 
23
27
  # Set the name of the parameter
24
28
  #
29
+ # Arguments:
30
+ # name: (String)
31
+ #
25
32
  # Example:
26
33
  # >> parameter.name("Username")
27
34
  # => "Username"
@@ -30,8 +37,27 @@ module RediPress
30
37
  name.nil? ? @name : @name = name
31
38
  end
32
39
 
40
+ # Set the parameter to required
41
+ #
42
+ # Available With Types:
43
+ # :text
44
+ #
45
+ # Arguments:
46
+ # required: (Boolean)
47
+ #
48
+ # Example:
49
+ # >> parameter.required(true)
50
+ # => true
51
+ #
52
+ def required(required = nil)
53
+ required.nil? ? @required : @required = required
54
+ end
55
+
33
56
  # Set the type of the parameter
34
57
  #
58
+ # Arguments:
59
+ # type: (Symbol)
60
+ #
35
61
  # Example:
36
62
  # >> parameter.type(:text)
37
63
  # => :text
@@ -45,6 +71,9 @@ module RediPress
45
71
  # Available With types:
46
72
  # :text
47
73
  #
74
+ # Arguments:
75
+ # default: (String)
76
+ #
48
77
  # Example:
49
78
  # >> parameter.default('rediwebhosting')
50
79
  # => "rediwebhosting"
@@ -58,6 +87,9 @@ module RediPress
58
87
  # Available With types:
59
88
  # :text
60
89
  #
90
+ # Arguments:
91
+ # validation: (Regex)
92
+ #
61
93
  # Example:
62
94
  # >> parameter.validation(/^[a-z]{4,}$/)
63
95
  # => /^[a-z]{4,}$/
@@ -72,6 +104,9 @@ module RediPress
72
104
  # :select
73
105
  # :multi_select
74
106
  #
107
+ # Arguments:
108
+ # option: (String)
109
+ #
75
110
  # Example:
76
111
  # >> parameter.option('rediweb')
77
112
  # => nil
data/lib/redipress/ssh.rb CHANGED
@@ -32,7 +32,7 @@ module RediPress
32
32
  keys: ssh_keys,
33
33
 
34
34
  # Set the authentication methods
35
- auth_methods: %w(publickey password)
35
+ auth_methods: %w(publickey)
36
36
  }
37
37
  end
38
38
 
@@ -1,5 +1,5 @@
1
1
  module RediPress
2
2
  # The current version of the gem.
3
3
  #
4
- VERSION = '0.0.4'
4
+ VERSION = '0.0.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redipress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rediweb Hosting
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-07 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor