argv 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +17 -0
- data/LICENSE +21 -0
- data/README.md +19 -0
- data/Rakefile +1 -0
- data/VERSION +1 -0
- data/argv.gemspec +20 -0
- data/lib/argv.rb +32 -0
- data/sample/test.rb +9 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fea51db2a656fdcf77062c0255c79d79575ef76a
|
4
|
+
data.tar.gz: 1081c980988c52fe0c13cede7b26c6f5f7c66bbb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5dcb7d657bdf8a9fcc1ac1e27c44f3cd9a2f053ecdf129f15a6d8664da3061f087b34e238901873803f11333b74dabf0cea530fe598d43cf9579cb908ed902d6
|
7
|
+
data.tar.gz: 72a2a8d0c44f80529db5faf5badaad37d01da7ed67177f1736fcb58937c020333dba96347f93615b26fb314571e474742eea01dcfcdb9e125af84091a8cc81c1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Adam Luzsi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
ARGV
|
2
|
+
========
|
3
|
+
|
4
|
+
Extension for ARGV obj.
|
5
|
+
With this extension module, you can parse in an easy way the script input tags
|
6
|
+
|
7
|
+
### example
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
|
11
|
+
#> $ script.rb --test this --hello world --sup
|
12
|
+
|
13
|
+
puts ARGV.flag_tags
|
14
|
+
# {"--test"=>"this", "--hello"=>"world"}
|
15
|
+
|
16
|
+
puts ARGV.flags.inspect
|
17
|
+
# ["--test", "--hello", "--sup"]
|
18
|
+
|
19
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join"bundler","gem_tasks"
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/argv.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
|
5
|
+
spec.name = "argv"
|
6
|
+
spec.version = File.open(File.join(File.dirname(__FILE__),"VERSION")).read.split("\n")[0].chomp.gsub(' ','')
|
7
|
+
spec.authors = ["Adam Luzsi"]
|
8
|
+
spec.email = ["adam.luzsi@ppt-consulting.net"]
|
9
|
+
spec.description = %q{ ARGV object extension for parsing flags, inputs, so you can have easy hash objects that contain tag value, and so on :) }
|
10
|
+
spec.summary = %q{ argv object extension for parsing flags, inputs }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler"
|
18
|
+
spec.add_development_dependency "rake"
|
19
|
+
|
20
|
+
end
|
data/lib/argv.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module ARGVEXT
|
2
|
+
|
3
|
+
def flag_tags
|
4
|
+
|
5
|
+
return_obj= {}
|
6
|
+
self.count.times do |index|
|
7
|
+
|
8
|
+
begin
|
9
|
+
|
10
|
+
if self[index][0].include?('-') && !self[index+1][0].include?('-')
|
11
|
+
return_obj[self[index]]= self[index+1]
|
12
|
+
end
|
13
|
+
|
14
|
+
rescue
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
return return_obj
|
19
|
+
|
20
|
+
end
|
21
|
+
alias :flag_tag :flag_tags
|
22
|
+
alias :flagtag :flag_tags
|
23
|
+
alias :flagtags :flag_tags
|
24
|
+
|
25
|
+
def flags
|
26
|
+
self.select{ |e| e[0].include?('-') }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
ARGV.__send__ :extend,ARGVEXT
|
32
|
+
|
data/sample/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: argv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Luzsi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " ARGV object extension for parsing flags, inputs, so you can have easy
|
42
|
+
hash objects that contain tag value, and so on :) "
|
43
|
+
email:
|
44
|
+
- adam.luzsi@ppt-consulting.net
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- VERSION
|
56
|
+
- argv.gemspec
|
57
|
+
- lib/argv.rb
|
58
|
+
- sample/test.rb
|
59
|
+
homepage:
|
60
|
+
licenses: []
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: argv object extension for parsing flags, inputs
|
82
|
+
test_files: []
|