componentr 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/README.md +4 -1
- data/bin/componentr +5 -1
- data/lib/componentr.rb +72 -0
- data/lib/componentr/inputr.rb +16 -0
- data/lib/componentr/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c746eab4f60bd2232a69cd645233e4dd4fd68548
|
4
|
+
data.tar.gz: 02f269d2231d41850306a51bab12050e6232b85a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c89cad47650c9daee24e97d8300b1a32c1ccf983bffb106a1a1a10c1db604bf0792ba96c3e41ff528f0c6b7660a056570c86fad095d640f22994633568c77ec9
|
7
|
+
data.tar.gz: 2e33e1dbb113b621116ca377d663a9ee0e40f6df69c06035164f8ebfb6843620891dcd7b026bb7779ae66ce4a2ed08c308461aebe610bd1caa2e05bd931abf8e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,10 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
run local
|
24
|
+
|
25
|
+
$ ruby -Ilib ./bin/componentr -v -p -a '{"arg1" : "value1"}'
|
26
|
+
$ ruby -Ilib ./bin/componentr -v -p -w '{"arg1" : "value1"}' 'foo' '{"wargs" : "true", "tango" : "cash" }' junk > stdout 2> stderr
|
24
27
|
|
25
28
|
## Contributing
|
26
29
|
|
data/bin/componentr
CHANGED
data/lib/componentr.rb
CHANGED
@@ -1,9 +1,81 @@
|
|
1
1
|
require "componentr/version"
|
2
2
|
require 'componentr/translator'
|
3
|
+
require 'json'
|
4
|
+
require 'optparse'
|
3
5
|
|
4
6
|
module Componentr
|
5
7
|
def self.hi(language)
|
6
8
|
translator = Translator.new(language)
|
7
9
|
translator.hi
|
8
10
|
end
|
11
|
+
def self.process(options, wargs, input)
|
12
|
+
$stderr.puts "#{options.to_s} and #{wargs} and #{input}" if options[:passthru] == true
|
13
|
+
wargs['status'] = 'success'
|
14
|
+
return wargs, input
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
def self.inputr
|
19
|
+
options = {}
|
20
|
+
OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: coomponentr [options]"
|
22
|
+
|
23
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
24
|
+
options[:verbose] = v
|
25
|
+
end
|
26
|
+
opts.on("-p", "--[no-]passthru", "Passthru Arguments") do |p|
|
27
|
+
options[:passthru] = p
|
28
|
+
end
|
29
|
+
|
30
|
+
options[:wargs] = nil
|
31
|
+
opts.on( '-a', '--wargs JSON', 'Write log to FILE' ) do |json|
|
32
|
+
options[:wargs] = json
|
33
|
+
end
|
34
|
+
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
# if any commnand line args are actually prpoper named wargs, emobody themm
|
38
|
+
$stderr.puts "RAWR : optionss #{options}"
|
39
|
+
wargs = options[:wargs] rescue nil
|
40
|
+
options.delete(:wargs)
|
41
|
+
|
42
|
+
wargs = JSON.parse(wargs) if wargs
|
43
|
+
$stderr.puts "RAWR: bJSONIc goodies are #{wargs}, right"
|
44
|
+
|
45
|
+
# probe input to see if any wargs are in there
|
46
|
+
|
47
|
+
#p ARGV
|
48
|
+
input = ARGV
|
49
|
+
|
50
|
+
net_input = input.map { |i|
|
51
|
+
begin
|
52
|
+
candidate = JSON.parse(i)
|
53
|
+
$stderr.puts "candidate #{candidate} "
|
54
|
+
$stderr.puts "subcandidate #{candidate['wargs']} " rescue nil
|
55
|
+
if candidate && candidate['wargs']
|
56
|
+
$stderr.puts "got one #{candidate}"
|
57
|
+
# merge into wargs
|
58
|
+
|
59
|
+
wargs.merge!(candidate)
|
60
|
+
# if merged, we don't need this in stdin
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
i
|
65
|
+
end
|
66
|
+
|
67
|
+
}.compact # get rid of nils
|
68
|
+
|
69
|
+
return options, wargs, net_input
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.outputr(wargs, output)
|
73
|
+
puts wargs
|
74
|
+
output.map {|o| puts o }
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.read_eval_print
|
78
|
+
outputr(*process(*inputr))
|
79
|
+
end
|
80
|
+
|
9
81
|
end
|
data/lib/componentr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: componentr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Miley
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- bin/componentr
|
55
55
|
- componentr.gemspec
|
56
56
|
- lib/componentr.rb
|
57
|
+
- lib/componentr/inputr.rb
|
57
58
|
- lib/componentr/translator.rb
|
58
59
|
- lib/componentr/version.rb
|
59
60
|
- test/test_componentr.rb
|