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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fb0beef002d49c64a0b25483def9f7f462e8798
4
- data.tar.gz: f559b2abacf6f5323b7d168760516eb8a44145df
3
+ metadata.gz: 9ea677c27d0df2e7b29b4423234f6095c1aafb8b
4
+ data.tar.gz: a98836b37b03bd4d72e3fe77ac292be2dda6bb14
5
5
  SHA512:
6
- metadata.gz: 69b29bbdac7c60a424600633a20fe753bd0fe65d872d07e19bcfb482b9218107ec1bba2912d8daf2778604bdaa36b361a107d895fd45b3d69e0b0686c71f6d88
7
- data.tar.gz: 946e33f41aa952bcb9ae955621018f0d91843a2771151ba3d4b38661e107c88a0ee857e81d75f565efa6eced4bac8b29d3a7ceab7de93e9010f097e3b84d31ab
6
+ metadata.gz: f39366b518b4705bf367f7403ff1b5837c7eb984325b96029bb14737b9c02cbcea754abe39c934fc0967de2b4e6cc46516fba66ff5ab4da9493f3627d0bb939b
7
+ data.tar.gz: b75b6fcda33eb33fec53153c255d8166b3ca131afc7fae36b1a8ecf172633f8bef03583ff55d4a58913ee779f01d03e497572f6528a40410169329f3eef9814a
@@ -1,8 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
3
  - 1.9.3
6
4
  - 2.0.0
7
5
  - 2.1.5
8
6
  - 2.2.0
7
+ - 2.3.0
8
+ before_install:
9
+ - gem update --system
10
+ - gem install bundler
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.1 (2016-10-01)
4
+
5
+ * Minor bug-fixes.
6
+
3
7
  ## 1.0.0 (2015-06-08)
4
8
 
5
9
  * Allow options to be `:hidden`.
data/Gemfile CHANGED
@@ -2,8 +2,13 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :test do
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
@@ -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
@@ -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 also :required doesn't make sense"
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 = instatiate_subcommand(subcommand_name)
10
+ subcommand = instantiate_subcommand(subcommand_name)
11
11
  subcommand.run(subcommand_arguments)
12
12
  end
13
13
 
14
14
  private
15
15
 
16
- def instatiate_subcommand(name)
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|
@@ -1,3 +1,3 @@
1
1
  module Clamp
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
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.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: 2015-06-08 00:00:00.000000000 Z
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.4.5
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