clamp 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/CHANGES.md +4 -0
- data/Gemfile +6 -1
- data/Guardfile +43 -0
- data/examples/defaulted +31 -0
- data/lib/clamp/option/definition.rb +4 -1
- data/lib/clamp/subcommand/execution.rb +2 -2
- data/lib/clamp/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea677c27d0df2e7b29b4423234f6095c1aafb8b
|
4
|
+
data.tar.gz: a98836b37b03bd4d72e3fe77ac292be2dda6bb14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f39366b518b4705bf367f7403ff1b5837c7eb984325b96029bb14737b9c02cbcea754abe39c934fc0967de2b4e6cc46516fba66ff5ab4da9493f3627d0bb939b
|
7
|
+
data.tar.gz: b75b6fcda33eb33fec53153c255d8166b3ca131afc7fae36b1a8ecf172633f8bef03583ff55d4a58913ee779f01d03e497572f6528a40410169329f3eef9814a
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
@@ -2,8 +2,13 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :
|
5
|
+
group :development do
|
6
|
+
gem "guard-rspec", "~> 4.6.5", :require => false
|
7
|
+
gem "listen", "~> 3.0.2"
|
6
8
|
gem "rake", "~> 10.4"
|
9
|
+
end
|
10
|
+
|
11
|
+
group :test do
|
7
12
|
gem "rspec", "~> 3.1.0"
|
8
13
|
gem "rr", "~> 1.1.2"
|
9
14
|
end
|
data/Guardfile
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
end
|
data/examples/defaulted
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
# An example of default values and methods
|
4
|
+
|
5
|
+
require "clamp"
|
6
|
+
require "highline"
|
7
|
+
|
8
|
+
Clamp do
|
9
|
+
|
10
|
+
option ["-U", "--user"], "USER", "user name",
|
11
|
+
:environment_variable => "THE_USER",
|
12
|
+
:default => "bob"
|
13
|
+
option ["-P", "--password"], "PASSWORD", "password",
|
14
|
+
:environment_variable => "THE_PASSWORD"
|
15
|
+
|
16
|
+
def execute
|
17
|
+
puts "User: #{user}, Password: #{password}"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def default_password
|
23
|
+
terminal.ask("Password [#{user}]: ") { |q| q.echo = '*' }
|
24
|
+
end
|
25
|
+
|
26
|
+
def terminal
|
27
|
+
tty = open("/dev/tty", "w+")
|
28
|
+
HighLine.new(tty, tty)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -16,7 +16,7 @@ module Clamp
|
|
16
16
|
@required = options[:required]
|
17
17
|
# Do some light validation for conflicting settings.
|
18
18
|
if options.has_key?(:default)
|
19
|
-
raise ArgumentError, "Specifying a :default value
|
19
|
+
raise ArgumentError, "Specifying a :default value with :required doesn't make sense"
|
20
20
|
end
|
21
21
|
if type == :flag
|
22
22
|
raise ArgumentError, "A required flag (boolean) doesn't make sense."
|
@@ -83,6 +83,9 @@ module Clamp
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def infer_attribute_name
|
86
|
+
unless long_switch
|
87
|
+
raise Clamp::DeclarationError, "You must specify either a long-switch or an :attribute_value"
|
88
|
+
end
|
86
89
|
inferred_name = long_switch.sub(/^--(\[no-\])?/, '').tr('-', '_')
|
87
90
|
inferred_name += "_list" if multivalued?
|
88
91
|
inferred_name
|
@@ -7,13 +7,13 @@ module Clamp
|
|
7
7
|
|
8
8
|
def execute
|
9
9
|
# delegate to subcommand
|
10
|
-
subcommand =
|
10
|
+
subcommand = instantiate_subcommand(subcommand_name)
|
11
11
|
subcommand.run(subcommand_arguments)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
16
|
+
def instantiate_subcommand(name)
|
17
17
|
subcommand_class = find_subcommand_class(name)
|
18
18
|
parent_attribute_values = {}
|
19
19
|
self.class.inheritable_attributes.each do |attribute|
|
data/lib/clamp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Clamp provides an object-model for command-line utilities.
|
@@ -24,11 +24,13 @@ files:
|
|
24
24
|
- ".travis.yml"
|
25
25
|
- CHANGES.md
|
26
26
|
- Gemfile
|
27
|
+
- Guardfile
|
27
28
|
- LICENSE
|
28
29
|
- README.md
|
29
30
|
- Rakefile
|
30
31
|
- clamp.gemspec
|
31
32
|
- examples/admin
|
33
|
+
- examples/defaulted
|
32
34
|
- examples/flipflop
|
33
35
|
- examples/fubar
|
34
36
|
- examples/gitdown
|
@@ -81,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
83
|
version: '0'
|
82
84
|
requirements: []
|
83
85
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.5.1
|
85
87
|
signing_key:
|
86
88
|
specification_version: 4
|
87
89
|
summary: a minimal framework for command-line utilities
|