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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90b47a7b37970c0ab2d1c6dd5d7195e369f56592
4
- data.tar.gz: a0b73c34114d39497d5c347cf9387de05447a3bc
3
+ metadata.gz: c746eab4f60bd2232a69cd645233e4dd4fd68548
4
+ data.tar.gz: 02f269d2231d41850306a51bab12050e6232b85a
5
5
  SHA512:
6
- metadata.gz: 6dc6ac92a27cd9f510f78532bbea0a770d37af0799e5e7a9289af80a6be9168fb240ed039b8d06013271c4391794845266abb3e8ec91b335afae5cfda5372e38
7
- data.tar.gz: 494c916b9c3a1c1f41ad0e5ee45910de5c722f89284a60b4740b9dd5d2e4e450e60cad126cf6fc06058617ad78b547c49d9e282833a6acf0f8206ae0985b0eaa
6
+ metadata.gz: c89cad47650c9daee24e97d8300b1a32c1ccf983bffb106a1a1a10c1db604bf0792ba96c3e41ff528f0c6b7660a056570c86fad095d640f22994633568c77ec9
7
+ data.tar.gz: 2e33e1dbb113b621116ca377d663a9ee0e40f6df69c06035164f8ebfb6843620891dcd7b026bb7779ae66ce4a2ed08c308461aebe610bd1caa2e05bd931abf8e
data/.gitignore CHANGED
@@ -12,3 +12,7 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ stderr
16
+ stdout
17
+ .#README.md
18
+ #*.*
data/README.md CHANGED
@@ -20,7 +20,10 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
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
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'componentr'
4
- puts Componentr.hi(ARGV[0])
4
+
5
+ Componentr.read_eval_print
6
+
7
+
8
+
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
@@ -0,0 +1,16 @@
1
+ class Componentr::Inputr
2
+ def initialize(inputs)
3
+ @inputs = inputs
4
+ end
5
+
6
+ def hi
7
+ case @inputs
8
+ when "spanish"
9
+ "hola mundo"
10
+ when "korean"
11
+ "anyoung ha se yo"
12
+ else
13
+ "hello world"
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module Componentr
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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