componentr 0.0.2 → 0.0.3
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/componentr.gemspec +0 -1
- data/lib/componentr.rb +37 -17
- data/lib/componentr/jobr.rb +16 -0
- data/lib/componentr/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa67cfe5288572edf9903eeb5554e44fd7c2cec2
|
4
|
+
data.tar.gz: 0aaedd600966b420e84ea868a3eb72868109f801
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ebdbb272eb3f2a45feaa4fc3ea7bbdf4bfeb97aa55bc234f4e3f1b0ef9a08e04999842b60a2834e49d547b1a87653395f7abcbffcb7bca0eb05de72204480a
|
7
|
+
data.tar.gz: 2a0a1d208369f1a50233e1cccd9a9ef09b899932b9efa379b6476be3a6dd7ea88646dc8ddc5b6dc282f9b3cbdad4bce632b7f693eb4a3df877c5717c34d87cc4
|
data/componentr.gemspec
CHANGED
@@ -8,7 +8,6 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Componentr::VERSION
|
9
9
|
spec.authors = ["Dan Miley"]
|
10
10
|
spec.email = ["dan.miley@gmail.com"]
|
11
|
-
# spec.files = ["Rakefile", "lib/componentr.rb", "lib/componentr/translator.rb", "bin/componentr"]
|
12
11
|
spec.summary = %q{componentized gem}
|
13
12
|
spec.description = %q{componentized gem}
|
14
13
|
spec.homepage = ""
|
data/lib/componentr.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "componentr/version"
|
2
2
|
require 'componentr/translator'
|
3
|
+
require 'componentr/jobr'
|
3
4
|
require 'json'
|
4
5
|
require 'optparse'
|
5
6
|
|
@@ -8,13 +9,24 @@ module Componentr
|
|
8
9
|
translator = Translator.new(language)
|
9
10
|
translator.hi
|
10
11
|
end
|
12
|
+
|
11
13
|
def self.process(options, wargs, input)
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
begin
|
15
|
+
# do something smart with passthru
|
16
|
+
# return wargs, input if wargs && wargs['status'] == 'error'
|
17
|
+
|
18
|
+
raise Exception if wargs && wargs['status'] == 'error'
|
19
|
+
job = Jobr.new
|
20
|
+
wargs = job.process(options, wargs, input)
|
21
|
+
return wargs, input
|
22
|
+
rescue Exception => e
|
23
|
+
wargs['history'] = {} if ! wargs['history']
|
24
|
+
wargs['history']["#{Time.now.to_i}#{rand}"] = "wargs error by #{self.class}"
|
25
|
+
|
26
|
+
return wargs, input
|
27
|
+
end
|
15
28
|
end
|
16
29
|
|
17
|
-
|
18
30
|
def self.inputr
|
19
31
|
options = {}
|
20
32
|
OptionParser.new do |opts|
|
@@ -28,34 +40,27 @@ module Componentr
|
|
28
40
|
end
|
29
41
|
|
30
42
|
options[:wargs] = nil
|
31
|
-
opts.on( '-a', '--wargs JSON', '
|
43
|
+
opts.on( '-a', '--wargs JSON', 'workflow arguments to be passed along (JSON.to_s arg)' ) do |json|
|
32
44
|
options[:wargs] = json
|
33
45
|
end
|
34
46
|
|
35
47
|
end.parse!
|
36
48
|
|
37
49
|
# if any commnand line args are actually prpoper named wargs, emobody themm
|
38
|
-
$stderr.puts "RAWR : optionss #{options}"
|
39
50
|
wargs = options[:wargs] rescue nil
|
40
51
|
options.delete(:wargs)
|
41
52
|
|
42
53
|
wargs = JSON.parse(wargs) if wargs
|
43
|
-
$stderr.puts "RAWR: bJSONIc goodies are #{wargs}, right"
|
44
54
|
|
45
55
|
# probe input to see if any wargs are in there
|
46
56
|
|
47
|
-
#p ARGV
|
48
57
|
input = ARGV
|
49
58
|
|
50
|
-
|
59
|
+
inputs = input.map { |i|
|
51
60
|
begin
|
52
61
|
candidate = JSON.parse(i)
|
53
|
-
$stderr.puts "candidate #{candidate} "
|
54
|
-
$stderr.puts "subcandidate #{candidate['wargs']} " rescue nil
|
55
62
|
if candidate && candidate['wargs']
|
56
|
-
$stderr.puts "got one #{candidate}"
|
57
63
|
# merge into wargs
|
58
|
-
|
59
64
|
wargs.merge!(candidate)
|
60
65
|
# if merged, we don't need this in stdin
|
61
66
|
nil
|
@@ -63,19 +68,34 @@ module Componentr
|
|
63
68
|
rescue Exception => e
|
64
69
|
i
|
65
70
|
end
|
66
|
-
|
67
71
|
}.compact # get rid of nils
|
68
72
|
|
69
|
-
|
73
|
+
|
74
|
+
# we check to see if its a wargs array, thats it
|
75
|
+
if ! wargs
|
76
|
+
# if we didn't get args on the command line, try file i/o,
|
77
|
+
# this is encountered when a proc gets a pipeline input from stdout
|
78
|
+
# ARGF.each do |line|
|
79
|
+
# $stderr.puts line
|
80
|
+
# end
|
81
|
+
candidate_args = ARGF.read rescue ''
|
82
|
+
whatever = ARGF.read rescue ''
|
83
|
+
candidate_json = JSON.parse(candidate_args) rescue {}
|
84
|
+
wargs = candidate_json
|
85
|
+
end
|
86
|
+
|
87
|
+
return options, wargs, inputs
|
70
88
|
end
|
71
89
|
|
72
90
|
def self.outputr(wargs, output)
|
73
|
-
puts wargs
|
74
|
-
output.map {|o|
|
91
|
+
$stdout.puts wargs.to_json.to_s if wargs
|
92
|
+
output.map {|o| $stdout.puts o }
|
75
93
|
end
|
76
94
|
|
77
95
|
def self.read_eval_print
|
78
96
|
outputr(*process(*inputr))
|
97
|
+
rescue Exception => e
|
98
|
+
$stderr.puts e.message
|
79
99
|
end
|
80
100
|
|
81
101
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Componentr::Jobr
|
2
|
+
def initialize
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
def process(options, wargs, input)
|
7
|
+
begin
|
8
|
+
wargs['history'] = {} if ! wargs['history']
|
9
|
+
wargs['history']["#{Time.now.to_i}#{rand}"] = "processed by #{self.class}"
|
10
|
+
wargs['status'] = 'success' if wargs
|
11
|
+
wargs
|
12
|
+
rescue Exception => e
|
13
|
+
$stderr.puts "run.process" + e.inspect
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/componentr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Miley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- componentr.gemspec
|
56
56
|
- lib/componentr.rb
|
57
57
|
- lib/componentr/inputr.rb
|
58
|
+
- lib/componentr/jobr.rb
|
58
59
|
- lib/componentr/translator.rb
|
59
60
|
- lib/componentr/version.rb
|
60
61
|
- test/test_componentr.rb
|