cat-dog 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +18 -0
  5. data/Rakefile +1 -0
  6. data/bin/dog +30 -0
  7. data/cat-dog.gemspec +14 -0
  8. metadata +53 -0
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cat-dog.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jason Stillwell
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # Cat::Dog
2
+
3
+ Laughably simple script to partner with 'cat'
4
+
5
+ Where 'cat' takes a filename and sends its contents to stdout. 'dog' takes stdin and redirects it into a file. Providing the other encap to a unix io stream.
6
+
7
+ Completely unnecessary under usual circumstances as unix command line io redirection
8
+ is usually sufficient for any such needs. Yet I have found the rare circumstance where
9
+ such a command is handy. Usually in testing other command line scripts.
10
+
11
+ ## Installation
12
+
13
+ $ gem install cat-dog
14
+
15
+ ## Usage
16
+
17
+ cat file | dog otherfile
18
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/dog ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ BUFFER_LENGTH = 1024
4
+
5
+ def pipe(file1,file2)
6
+ buffer = ''
7
+ while file1.read(BUFFER_LENGTH, buffer)
8
+ file2.write(buffer)
9
+ end
10
+ end
11
+
12
+ def main
13
+
14
+ if ARGV.length == 0
15
+ # just like cat, simple pass-through
16
+ pipe($stdin,$stdout)
17
+ elsif ARGV.length == 1
18
+ # write the input stream to a file
19
+ filename = ARGV[0]
20
+ open(filename,'w') do |file|
21
+ pipe($stdin,file)
22
+ end
23
+ else
24
+ raise "no can do. dog can only take one filename on the command line."
25
+ end
26
+
27
+ end
28
+
29
+ main
30
+
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "cat-dog"
5
+ gem.version = '1.0.0'
6
+ gem.authors = ["Jason Stillwell"]
7
+ gem.email = ["dragonfax@gmail.com"]
8
+ gem.description = %q{contra-positive to unix's 'cat'}
9
+ gem.summary = %q{Take stdin and write it to a filename provided on the command line.}
10
+ gem.homepage = "https://github.com/dragonfax/cat-dog"
11
+
12
+ gem.files = `git ls-files`.split($/)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cat-dog
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Stillwell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: contra-positive to unix's 'cat'
15
+ email:
16
+ - dragonfax@gmail.com
17
+ executables:
18
+ - dog
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/dog
28
+ - cat-dog.gemspec
29
+ homepage: https://github.com/dragonfax/cat-dog
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.24
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Take stdin and write it to a filename provided on the command line.
53
+ test_files: []