params 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/params/argument_parser.rb +24 -0
- data/lib/params.rb +13 -0
- metadata +47 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
class ReadArgs
|
2
|
+
def self.read_arguments(argv, parsed_arguments, commands = nil)
|
3
|
+
argv.each { |arg|
|
4
|
+
if arg.start_with?("--")
|
5
|
+
words = arg[2,arg.length-2].split('=')
|
6
|
+
parsed_arguments[words[0]]=words[1]
|
7
|
+
elsif commands != nil and not commands.key?(arg)
|
8
|
+
puts "Unknown command '%s'." % arg
|
9
|
+
return false
|
10
|
+
else
|
11
|
+
if parsed_arguments.key? arg
|
12
|
+
puts "Parse error, two commands found %s and %s" % parsed_arguments["command"], arg
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
parsed_arguments["command"] = arg
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
return false unless commands == nil or parsed_arguments["command"] != nil
|
20
|
+
return false unless commands == nil or parsed_arguments["command"] != ""
|
21
|
+
|
22
|
+
return true
|
23
|
+
end
|
24
|
+
end
|
data/lib/params.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
# A simple params module.
|
3
|
+
module BBFS
|
4
|
+
module PARAMS
|
5
|
+
def parameter(name, default_value, description)
|
6
|
+
self.instance_variable_set '@' + name, default_value
|
7
|
+
self.class.send('attr_reader', name)
|
8
|
+
end
|
9
|
+
module_function :parameter
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: params
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gena Petelko
|
9
|
+
- Kolman Vornovitsky
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-04-08 00:00:00.000000000Z
|
14
|
+
dependencies: []
|
15
|
+
description: Dynamically stores, parses and providers params. Uses module local readers.
|
16
|
+
email: kolmanv@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/params.rb
|
22
|
+
- lib/params/argument_parser.rb
|
23
|
+
homepage: http://github.com/kolmanv/bbfs
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.15
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Dynamically stores, parses and providers params.
|
47
|
+
test_files: []
|