xify 0.0.2 → 0.1.0

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
  SHA256:
3
- metadata.gz: 7887a75fe26b23e8914d2c644ab854b43f10962cba6098f6cef821cf1e331e4b
4
- data.tar.gz: 8e5d734727dbfb96767d1a96376f851c83095c2d6ebcfc0dbb3d932fcf100dbb
3
+ metadata.gz: 670138629af686c5ae8d7fe7bd773a6a24ab23e4a1cac1e43ec2c5b1d6a1d6d7
4
+ data.tar.gz: ba760cff71020f421c22ec7c100c9bad5193c439fa5af222aeb4f0467a335c35
5
5
  SHA512:
6
- metadata.gz: 51b09d9c1f0aaa42a03347ff6a1d6c7f462d305295719a965ee70f8068cc096ffc7e325dfb84cd1974c0fbc32695ebfcde9533bff0cbf8587d0bfc2bb3802db2
7
- data.tar.gz: eafcba6853de81298f3ea6d7c1966a79530684efefc4e78474b1c908e50898446feacb007793d3fd4284bd99229ba43829e0e5c805ed75361e864be56997de5a
6
+ metadata.gz: e8628de616941c4f2b450739af88d4d60eca6f393babd3f08261b9c178e5a983d332c4ddfa775f6da50f644df3c6a4727c4ea7442d08d70e04a769f7ab172beb
7
+ data.tar.gz: 27132224d15386e6e23be525e9e030461643643c2deccfedc3ec2f8a0c4d6f70ac2d5680ff6a2f17279ff3ed718afc3f1e063271576b4e2deacdbc2125cc5dff
@@ -0,0 +1,10 @@
1
+ class Pipe
2
+ def initialize(config)
3
+ @author = config['author']
4
+ end
5
+
6
+ def updates
7
+ out = ARGF.read.chomp
8
+ yield Event.new @author, out if out && out.length != 0
9
+ end
10
+ end
@@ -1,6 +1,6 @@
1
1
  require 'xify/event'
2
2
 
3
- class Stdin
3
+ class Prompt
4
4
  def initialize(config)
5
5
  @author = config['author']
6
6
  end
@@ -17,7 +17,7 @@ class Stdin
17
17
  end
18
18
 
19
19
  if input.length != 1
20
- yield Event.new @author, input
20
+ yield Event.new @author, input.chomp
21
21
  end
22
22
  rescue Interrupt
23
23
  # Stop on CTRL+C
@@ -0,0 +1,10 @@
1
+ class Shell
2
+ def initialize(config)
3
+ @config = config
4
+ end
5
+
6
+ def updates
7
+ out = `#{@config['shell']}`.chomp
8
+ yield Event.new @config['author'], out, parent: @config['shell'] if out && out.length != 0
9
+ end
10
+ end
@@ -5,6 +5,6 @@ class Stdout
5
5
  end
6
6
 
7
7
  def process(event)
8
- puts "[#{event.args[:time] || Time.now.iso8601}] #{event.author}: #{event.message}"
8
+ puts "[#{event.args[:time] || Time.now.iso8601}] #{event.author}:\n#{event.message}"
9
9
  end
10
10
  end
data/lib/xify.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'yaml'
2
2
 
3
- require 'xify/input/stdin'
3
+ require 'xify/input/pipe'
4
+ require 'xify/input/prompt'
5
+ require 'xify/input/shell'
4
6
  require 'xify/output/stdout'
5
7
  require 'xify/output/rocket_chat'
6
8
 
@@ -9,7 +11,12 @@ class Xify
9
11
  working_dir = "#{ENV['HOME']}/.xify"
10
12
  Dir.mkdir working_dir rescue Errno::EEXIST
11
13
 
12
- config_file = args.shift || "#{working_dir}/config.yml"
14
+ config_file = "#{working_dir}/config.yml"
15
+ if args.first == '-c'
16
+ args.shift
17
+ config_file = args.shift
18
+ end
19
+
13
20
  puts "Loading config from #{config_file}"
14
21
  config = YAML::load_file config_file
15
22
 
@@ -20,7 +27,6 @@ class Xify
20
27
  end.compact!
21
28
  end
22
29
 
23
- puts 'Looking for updates'
24
30
  config['inputs'].each do |i|
25
31
  i.updates do |u|
26
32
  config['outputs'].each do |o|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Finn Glöe
@@ -20,7 +20,9 @@ files:
20
20
  - bin/xify
21
21
  - lib/xify.rb
22
22
  - lib/xify/event.rb
23
- - lib/xify/input/stdin.rb
23
+ - lib/xify/input/pipe.rb
24
+ - lib/xify/input/prompt.rb
25
+ - lib/xify/input/shell.rb
24
26
  - lib/xify/output/rocket_chat.rb
25
27
  - lib/xify/output/stdout.rb
26
28
  homepage: