dotopts 0.1.1 → 0.1.2

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.
data/.index CHANGED
@@ -49,7 +49,7 @@ paths:
49
49
  created: '2013-01-23'
50
50
  summary: Automatic Arguments for Ruby
51
51
  title: DotOpts
52
- version: 0.1.1
52
+ version: 0.1.2
53
53
  name: dotopts
54
54
  description: DotOpts is an automatic commandline argument augmenter for Ruby tools.
55
55
  date: '2013-01-29'
data/README.md CHANGED
@@ -30,17 +30,23 @@ arguments when a matching command is invoked.
30
30
 
31
31
  ## Install
32
32
 
33
- DotOpts can be install via Rubygems:
33
+ DotOpts can be install via RubyGems:
34
34
 
35
35
  gem install dotopts
36
36
 
37
- If you would like to use DotOpts with all Ruby tools, regardless of
38
- whether they have built-in support for DotOpts, then add `-rdotopts`
39
- to you `RUBYOPT` environment variable.
37
+ There are two wasy to setup DotOpts for use by all Ruby tools (regardless
38
+ of whether they have built-in support for DotOpts or not). The most
39
+ univeral approach is to add `-rdotopts` to you `RUBYOPT` environment
40
+ variable.
40
41
 
41
42
  export RUBYOPT="-rdotopts"
42
43
 
43
- This ensures DotOpts is required whenever Ruby is used.
44
+ This ensures DotOpts is required whenever Ruby is used. The other
45
+ approach is to use Bundler by adding DotOpts to your project's Gemfile.
46
+
47
+ gem 'dotopts'
48
+
49
+ This will allow dotopts to run whenever using `bundle exec`.
44
50
 
45
51
 
46
52
  ## Usage
@@ -116,7 +122,7 @@ using regular expressions.
116
122
  -r simplecov
117
123
  ```
118
124
 
119
- ## Third Party Support
125
+ ### Tool Support
120
126
 
121
127
  Ruby tool developers can support dotopts out-of-the-box simple by running
122
128
  `require 'dotopts'` in their program before parsing the commandline. DotOpts
@@ -126,6 +132,15 @@ option parser.
126
132
 
127
133
  ## Development
128
134
 
135
+ ### Suggestions & Contributions
136
+
137
+ DotOpts is a brand new application, and still rather wet behind the years, so to
138
+ speak. So your input is critical to making it better. Any and all suggestions and
139
+ contributions are much appreciated. If you have any ideas on how to improve DotOpts,
140
+ or find any flaws in its design that need address, please drop a comment on the
141
+ [Issues](http://github.com/rubyworks/dotopts/issues) page. Or even better, be proactive!
142
+ Fork the project submit a pull request. Thanks.
143
+
129
144
  ### Universal Solution?
130
145
 
131
146
  It would be awesome if it were possible to have DotOpts apply to *all* executables,
data/lib/dotopts/api.rb CHANGED
@@ -15,7 +15,7 @@ module DotOpts
15
15
  if file
16
16
  text = File.read(file)
17
17
  parser = Parser.parse(text)
18
- ARGV.concat parser.arguments
18
+ apply(parser.arguments, parser.environment)
19
19
  end
20
20
  end
21
21
 
@@ -44,4 +44,14 @@ module DotOpts
44
44
  nil
45
45
  end
46
46
 
47
+ # Apply arguments and environment options.
48
+ #
49
+ # TODO: Support argument prepending in future version?
50
+ #
51
+ def self.apply(argv, env={})
52
+ puts argv.join(' ') if ENV['dotopts_debug']
53
+ env.each{ |k,v| ENV[k.to_s] = v.to_s }
54
+ ARGV.concat(argv)
55
+ end
56
+
47
57
  end
@@ -23,6 +23,7 @@ module DotOpts
23
23
  def initialize(text)
24
24
  @text = text
25
25
  @arguments = []
26
+ @environment = {}
26
27
  end
27
28
 
28
29
  #
@@ -31,6 +32,9 @@ module DotOpts
31
32
  #
32
33
  attr :arguments
33
34
 
35
+ #
36
+ attr :environment
37
+
34
38
  #
35
39
  def parse
36
40
  lines = @text.lines.to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotopts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: