prefix_with 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86581875bae6499527ef4ac7ef6a986193edb521
4
+ data.tar.gz: 7f34d725f9dbfac56577e91d1d97ef7536244a68
5
+ SHA512:
6
+ metadata.gz: 7524468742099a02fbceccb53262d7c23ba2a4ce2b11f648e58899a44821d3652ec7261cbf29a109dd8f76120e533d167aa8dd4b18746b4f190709497fcf3652
7
+ data.tar.gz: 5ec7839e2364f2aa9ad791102910ca079ba4161b0bd8ed8ee80cb4170b8df817666967fb6aa0b056ff2e7e4afd39e7621d92deb7d11eb40d73b6ae6b402ddc79
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *pkg
2
+ Gemfile.lock
3
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
File without changes
data/README.markdown ADDED
@@ -0,0 +1,22 @@
1
+ # prefix_with
2
+
3
+ A CLI utility to prefix lines fed through the STDIN with its arguments.
4
+
5
+ # Installation
6
+
7
+ $ gem install prefix_with
8
+
9
+ # Use case
10
+
11
+ Imagine deleting all *.txt files from a deeply nested folder structure. `xargs` may be the tool that comes to mind - to prefix with the `rm` command infront of a filtered list of files, like:
12
+
13
+ $ find . | grep "*.txt" | xargs rm
14
+
15
+ The problem I find with this is that, mostly the command breaks because there are spaces in the file names or that there might be a few files that we may require. May be it was better to see the command thats going to get executed prior to execution. If that makes sense, this is the tool that will help in it. I know space issue can be handled, but didn't feel it as an elegant solution.
16
+
17
+ $ find . | grep "*.txt" | prefix_with rm | sh
18
+
19
+
20
+ # Credits
21
+
22
+ I saw this as a small script that one of my friends - [Nikhil Mohan](https://www.facebook.com/cavoo1101) was using. Packaging as a gem hoping it would be useful for someone.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/prefix_with ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require_relative '../lib/prefix_with'
4
+
5
+ puts PrefixWith::Prefixer.output(stdin: STDIN.readlines, prefix: ARGV)
@@ -0,0 +1,13 @@
1
+ module PrefixWith
2
+
3
+ class Prefixer
4
+
5
+ def self.output( stdin: '', prefix: '' )
6
+ stdin.collect do |line|
7
+ "#{prefix.first} '#{line.chomp}'"
8
+ end
9
+ end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,19 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "prefix_with"
6
+ s.version = "0.0.5"
7
+ s.authors = ["Jikku Jose"]
8
+ s.email = ["jikkujose@gmail.com"]
9
+ s.summary = "CLI utility to prefix lines fed through the STDIN with an argument"
10
+ s.description = "CLI utility to prefix lines fed through the STDIN with an argument"
11
+ s.license = "MIT"
12
+
13
+ s.files = `git ls-files -z`.split("\x0")
14
+ s.require_paths = ["lib"]
15
+ s.executables = ["prefix_with"]
16
+
17
+ s.add_development_dependency "bundler", "~> 1.6"
18
+ s.add_development_dependency "rake", "~> 10.3"
19
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prefix_with
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Jikku Jose
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.3'
41
+ description: CLI utility to prefix lines fed through the STDIN with an argument
42
+ email:
43
+ - jikkujose@gmail.com
44
+ executables:
45
+ - prefix_with
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.markdown
53
+ - Rakefile
54
+ - bin/prefix_with
55
+ - lib/prefix_with.rb
56
+ - prefix_with.gemspec
57
+ homepage:
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: CLI utility to prefix lines fed through the STDIN with an argument
81
+ test_files: []