valet 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valet::Option::Flag do
4
+ it_behaves_like "a common option"
5
+
6
+ subject(:opt) { Option::Flag.new(:output) }
7
+
8
+ its(:type) { should be(String) }
9
+ its(:default) { should be_nil }
10
+ its(:value) { should be_nil }
11
+ its(:arg_name) { should eq('output')}
12
+
13
+ describe "attributes" do
14
+ it "can be given a custom type" do
15
+ opt.type = Integer
16
+ expect(opt.type).to be(Integer)
17
+ end
18
+
19
+ it "can be given a default" do
20
+ opt.default = '~/backups'
21
+ expect(opt.value).to eq('~/backups')
22
+ end
23
+
24
+ it "can be given a value" do
25
+ opt.value = '/var/backups'
26
+ expect(opt.value).to eq('/var/backups')
27
+ end
28
+
29
+ it "can be given a custom argument name" do
30
+ opt.arg_name = 'file'
31
+ expect(opt.arg_name).to eq('file')
32
+ end
33
+
34
+ context "raises an OptionError" do
35
+ it "if the given type is not allowed" do
36
+ expect { opt.type = Mutex }.to raise_error(TypeError)
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "#long_name_to_s" do
42
+ it "returns '--flag=<flag>' if the flag has no default" do
43
+ opt = Option::Flag.new(:suffix)
44
+ opt.default = nil
45
+ expect(opt.long_name_to_s).to eq('--suffix=<suffix>')
46
+ end
47
+
48
+ it "returns '--flag[=<flag>]' if the flag has a default" do
49
+ opt = Option::Flag.new(:chmod)
50
+ opt.default = 755
51
+ expect(opt.long_name_to_s).to eq('--chmod[=<chmod>]')
52
+ end
53
+
54
+ it "transforms underscores to dashes" do
55
+ opt = Option::Flag.new(:target_directory)
56
+ expect(opt.long_name_to_s).to eq('--target-directory=<target directory>')
57
+ end
58
+
59
+ it "prints the custom argument name if it has been set" do
60
+ opt = Option::Flag.new(:remote_host)
61
+ opt.arg_name = 'host'
62
+ expect(opt.long_name_to_s).to eq('--remote-host=<host>')
63
+ end
64
+ end
65
+
66
+ describe "#switch?" do
67
+ specify { expect(opt.switch?).to be_false }
68
+ end
69
+
70
+ describe "#flag?" do
71
+ specify { expect(opt.flag?).to be_true }
72
+ end
73
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valet::Option::Switch do
4
+ it_behaves_like "a common option"
5
+
6
+ subject(:opt) { Option::Switch.new(:verbose) }
7
+
8
+ its(:default) { should be_false }
9
+ its(:value) { should be_false }
10
+
11
+ describe "attributes" do
12
+ it "can be given a new default 'true'" do
13
+ opt.default = true
14
+ expect(opt.value).to be_true
15
+ end
16
+
17
+ it "can be given a new default 'false'" do
18
+ opt.default = false
19
+ expect(opt.value).to be_false
20
+ end
21
+ end
22
+
23
+ describe "#switch" do
24
+ it "changes the value from false to true" do
25
+ opt.default = false
26
+ expect(opt.switch).to be_true
27
+ end
28
+
29
+ it "changes the value from true to false" do
30
+ opt.default = true
31
+ expect(opt.switch).to be_false
32
+ end
33
+ end
34
+
35
+ describe "#long_name_to_s" do
36
+ it "returns '--switch' if the switch defaults to false" do
37
+ opt.default = false
38
+ expect(opt.long_name_to_s).to eq('--verbose')
39
+ end
40
+
41
+ it "returns '--no-switch' if the switch defaults to true" do
42
+ opt.default = true
43
+ expect(opt.long_name_to_s).to eq('--no-verbose')
44
+ end
45
+
46
+ it "transforms underscores to dashes" do
47
+ opt = Option::Switch.new(:ignore_errors)
48
+ expect(opt.long_name_to_s).to eq('--ignore-errors')
49
+ end
50
+ end
51
+
52
+ describe "#switch?" do
53
+ specify { expect(opt.switch?).to be_true }
54
+ end
55
+
56
+ describe "#flag?" do
57
+ specify { expect(opt.flag?).to be_false }
58
+ end
59
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Valet::Options do
4
+ subject(:opts) { Options.new }
5
+
6
+ let(:switch) { Option::Switch.new(:verbose) }
7
+ let(:flag) { Option::Flag.new(:output) }
8
+
9
+ before { opts << switch << flag }
10
+
11
+ describe "#[]" do
12
+ it "searches for a switch option by a given name and returns it" do
13
+ expect(opts[:verbose]).to equal(switch)
14
+ end
15
+
16
+ it "searches for a flag option by a given name and returns it" do
17
+ expect(opts[:output]).to equal(flag)
18
+ end
19
+
20
+ it "returns nil if nothing could be found" do
21
+ expect(opts[:clobber]).to be_nil
22
+ end
23
+ end
24
+
25
+ describe "#method_missing" do
26
+ context "access to switch options" do
27
+ it "returns the switch's value if #method_name matches its option name" do
28
+ switch.stub(value: true)
29
+ expect(opts.verbose?).to be_true
30
+ end
31
+
32
+ it "raises a NoMethodError if using no question mark in #method_name" do
33
+ expect { opts.verbose }.to raise_error(NoMethodError)
34
+ end
35
+
36
+ it "raises a NoMethodError if there's no switch matching #method_name" do
37
+ expect { opts.cache? }.to raise_error(NoMethodError)
38
+ end
39
+ end
40
+
41
+ context "access to flag options" do
42
+ it "returns the flag's value if #method_name matches its option name" do
43
+ flag.stub(value: '~/backups')
44
+ expect(opts.output).to eq('~/backups')
45
+ end
46
+
47
+ it "raises a NoMethodError is using a question mark in #method_name" do
48
+ expect { opts.output? }.to raise_error(NoMethodError)
49
+ end
50
+
51
+ it "raises a NoMethodError if there's no flag matching #method_name" do
52
+ expect { opts.dirs }.to raise_error(NoMethodError)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -2,18 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe Valet::VERSION do
4
4
  it "has a major version number" do
5
- Valet::VERSION::MAJOR.should be_an(Integer)
5
+ expect(Valet::VERSION::MAJOR).to be_an(Integer)
6
6
  end
7
7
 
8
8
  it "has a minor version number" do
9
- Valet::VERSION::MINOR.should be_an(Integer)
9
+ expect(Valet::VERSION::MINOR).to be_an(Integer)
10
10
  end
11
11
 
12
12
  it "has a build version number" do
13
- Valet::VERSION::BUILD.should be_an(Integer)
13
+ expect(Valet::VERSION::BUILD).to be_an(Integer)
14
14
  end
15
15
 
16
16
  it "has a RubyGems compliant version string" do
17
- Valet::VERSION::STRING.should match(/\A\d+\.\d+\.\d+(\.rc\d+)?\z/)
17
+ expect(Valet::VERSION::STRING).to match(/\A\d+\.\d+\.\d+(\.rc\d+)?\z/)
18
18
  end
19
19
  end
data/valet.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  require File.expand_path('../lib/valet/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.name = 'valet'
5
- gem.version = Valet::VERSION::STRING
6
- gem.license = 'MIT'
7
- gem.authors = ['Alexander Baumann']
8
- gem.email = ['alexander.baumann@arclight.ch']
9
- gem.homepage = 'http://gitkeeper.github.com/valet'
10
- gem.summary = 'A framework for creating GNU compliant command-line interfaces.'
11
- gem.description = <<-DESCRIPTION.gsub(/^ {4}/, '').gsub(/\n/, ' ').strip
4
+ gem.name = 'valet'
5
+ gem.version = Valet::VERSION::STRING
6
+ gem.license = 'MIT'
7
+ gem.authors = ['Alexander Baumann']
8
+ gem.email = ['alexander.baumann@arclight.ch']
9
+ gem.homepage = 'http://gitkeeper.github.com/valet'
10
+ gem.summary = 'A framework for creating GNU compliant command-line interfaces.'
11
+ gem.description = <<-DESCRIPTION.gsub(/^ {4}/, '').gsub(/\n/, ' ').strip
12
12
  Valet helps you write the sophisticated command-line interfaces you're so
13
13
  used to from GNU/Linux. It provides a beautiful API, rich template support,
14
14
  smart configuration, man page generator, and many other useful features.
@@ -33,10 +33,8 @@ Gem::Specification.new do |gem|
33
33
  gem.test_files = gem.files.grep(%r{^(spec|features)/})
34
34
  gem.require_paths = ['lib']
35
35
 
36
- gem.add_dependency 'mustache', '~> 0.99'
37
-
38
36
  gem.add_development_dependency 'rake', '~> 0.9'
39
- gem.add_development_dependency 'rspec', '~> 2.10'
37
+ gem.add_development_dependency 'rspec', '~> 2.11'
40
38
  gem.add_development_dependency 'cucumber', '~> 1.2'
41
39
  gem.add_development_dependency 'aruba', '~> 0.4'
42
40
  gem.add_development_dependency 'simplecov', '~> 0.6'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-08 00:00:00.000000000 Z
12
+ date: 2012-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: mustache
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '0.99'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: '0.99'
30
14
  - !ruby/object:Gem::Dependency
31
15
  name: rake
32
16
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +34,7 @@ dependencies:
50
34
  requirements:
51
35
  - - ~>
52
36
  - !ruby/object:Gem::Version
53
- version: '2.10'
37
+ version: '2.11'
54
38
  type: :development
55
39
  prerelease: false
56
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +42,7 @@ dependencies:
58
42
  requirements:
59
43
  - - ~>
60
44
  - !ruby/object:Gem::Version
61
- version: '2.10'
45
+ version: '2.11'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: cucumber
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -178,22 +162,29 @@ files:
178
162
  - Rakefile
179
163
  - bin/valet
180
164
  - features/help.feature
181
- - features/step_definitions/command_line_steps.rb
182
- - features/step_definitions/file_steps.rb
183
165
  - features/support/env.rb
184
- - features/support/helpers/cli_helper.rb
185
- - features/support/world_extensions.rb
186
166
  - features/version.feature
187
167
  - lib/valet.rb
188
168
  - lib/valet/application.rb
189
- - lib/valet/templates/version.mustache
169
+ - lib/valet/command.rb
170
+ - lib/valet/commands.rb
171
+ - lib/valet/helpers/type_cast.rb
172
+ - lib/valet/option/common.rb
173
+ - lib/valet/option/flag.rb
174
+ - lib/valet/option/switch.rb
175
+ - lib/valet/options.rb
190
176
  - lib/valet/version.rb
191
- - lib/valet/view.rb
192
- - lib/valet/views/version.rb
193
177
  - spec/spec_helper.rb
178
+ - spec/support/shared_examples.rb
179
+ - spec/support/terminal_helper.rb
194
180
  - spec/valet/application_spec.rb
181
+ - spec/valet/command_spec.rb
182
+ - spec/valet/commands_spec.rb
183
+ - spec/valet/helpers/type_cast_spec.rb
184
+ - spec/valet/option/flag_spec.rb
185
+ - spec/valet/option/switch_spec.rb
186
+ - spec/valet/options_spec.rb
195
187
  - spec/valet/version_spec.rb
196
- - spec/valet/view_spec.rb
197
188
  - tasks/clean.rake
198
189
  - tasks/cucumber.rake
199
190
  - tasks/spec.rake
@@ -203,7 +194,7 @@ homepage: http://gitkeeper.github.com/valet
203
194
  licenses:
204
195
  - MIT
205
196
  post_install_message: ! "\n# --------------------------------------------------------------------
206
- #\n\n Thank you for installing Valet 0.0.7!\n\n Valet is still in development
197
+ #\n\n Thank you for installing Valet 0.0.8!\n\n Valet is still in development
207
198
  and not yet intended to be used.\n\n# --------------------------------------------------------------------
208
199
  #\n\n"
209
200
  rdoc_options: []
@@ -217,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
208
  version: '0'
218
209
  segments:
219
210
  - 0
220
- hash: -2398269218911550169
211
+ hash: 272199638211078853
221
212
  required_rubygems_version: !ruby/object:Gem::Requirement
222
213
  none: false
223
214
  requirements:
@@ -226,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
217
  version: '0'
227
218
  segments:
228
219
  - 0
229
- hash: -2398269218911550169
220
+ hash: 272199638211078853
230
221
  requirements: []
231
222
  rubyforge_project:
232
223
  rubygems_version: 1.8.24
@@ -235,14 +226,17 @@ specification_version: 3
235
226
  summary: A framework for creating GNU compliant command-line interfaces.
236
227
  test_files:
237
228
  - features/help.feature
238
- - features/step_definitions/command_line_steps.rb
239
- - features/step_definitions/file_steps.rb
240
229
  - features/support/env.rb
241
- - features/support/helpers/cli_helper.rb
242
- - features/support/world_extensions.rb
243
230
  - features/version.feature
244
231
  - spec/spec_helper.rb
232
+ - spec/support/shared_examples.rb
233
+ - spec/support/terminal_helper.rb
245
234
  - spec/valet/application_spec.rb
235
+ - spec/valet/command_spec.rb
236
+ - spec/valet/commands_spec.rb
237
+ - spec/valet/helpers/type_cast_spec.rb
238
+ - spec/valet/option/flag_spec.rb
239
+ - spec/valet/option/switch_spec.rb
240
+ - spec/valet/options_spec.rb
246
241
  - spec/valet/version_spec.rb
247
- - spec/valet/view_spec.rb
248
242
  has_rdoc:
@@ -1,3 +0,0 @@
1
- When /^I successfully run the script `([^`]*)`$/ do |script|
2
- run_simple("ruby -S #{unescape(script)}")
3
- end
@@ -1,3 +0,0 @@
1
- Given /^a Valet application named "([^"]*)" with:$/ do |file_name, file_content|
2
- write_file(file_name, new_cli(file_content).source)
3
- end
@@ -1,23 +0,0 @@
1
- module CLIHelper
2
- class CLI
3
- def initialize(content = nil)
4
- @content = content
5
- end
6
-
7
- def source
8
- <<-CLI_FILE.gsub(/^ {8}/, '')
9
- require 'valet'
10
-
11
- class CLI < Valet::Application
12
- #{@content ? @content.gsub(/^/, ' ') : '# No content has been given'}
13
- end
14
-
15
- CLI.start
16
- CLI_FILE
17
- end
18
- end
19
-
20
- def new_cli(content = nil)
21
- CLI.new(content)
22
- end
23
- end
@@ -1 +0,0 @@
1
- World(CLIHelper)
@@ -1,5 +0,0 @@
1
- {{name}} {{version}}
2
- {{copyright}}
3
- {{license}}
4
-
5
- {{authors}}
data/lib/valet/view.rb DELETED
@@ -1,29 +0,0 @@
1
- module Valet
2
- class View < Mustache
3
- self.view_namespace = 'Valet::Views'
4
- self.template_path = 'templates'
5
-
6
- def render
7
- fall_back_to_valet unless template_exists?
8
- super
9
- end
10
-
11
- def escapeHTML(string)
12
- string
13
- end
14
-
15
- private
16
-
17
- def fall_back_to_valet
18
- self.template_path = valet_template_path
19
- end
20
-
21
- def valet_template_path
22
- File.expand_path('../templates', __FILE__)
23
- end
24
-
25
- def template_exists?
26
- File.exists?(template_file)
27
- end
28
- end
29
- end