baze 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +15 -0
  2. data/bin/cols +75 -0
  3. data/bin/randmac +1 -1
  4. data/bin/suc +1 -7
  5. metadata +7 -7
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmE1OTEwZTM2OTBiMWI5ODY5YzlmN2JhN2Q2YzU5N2Y3YzYwYjA2Nw==
5
+ data.tar.gz: !binary |-
6
+ M2IwNDM4OTZhYTFhNTQzZmRhNDRjYmE3NjJiYTMwYjM1Mzk3Y2E4NQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODU0NjI5NDIwOTZmOThkODU0N2I2ODE5MTExOTZiMzUyNGJkMDFmODAwODgy
10
+ NDMzMDBmNjdjZTIyM2Q5OTA2YTZjMDNjMWE1ZDVhZDhjZDRjNmRkZGJlYTZk
11
+ NTk5OWFkOGZhOWExN2EzNjA4MmI4NTQ0NWNkNGUxNjE3OTI3MWY=
12
+ data.tar.gz: !binary |-
13
+ YzU1YWI3ZGQyNzgyNGU5YzViYjgyYjI1MmEzODZjYjEyZGYxYWEzNDVjMjNi
14
+ YWJjZTZiOGM1MDE4NDlmYTY1ODdlNzM2MzYzMDE5MWIxOTVmZDA4YTZlZDY0
15
+ NjczZWVmZDNlMzYxZGExODJhYTAzNDQ1NmMwN2FmMmZkNjFmYWI=
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+
5
+ fs = nil
6
+ sep = ' '
7
+ show_only = false
8
+
9
+ optparse = OptionParser.new do |opts|
10
+ opts.banner = "Usage: randmac [-l]\n" \
11
+ " Filter a set of columns with awk (takes a list of i|a-|-b|a-b specs)"
12
+
13
+ opts.on '-c', '--command', 'Print the awk command instead of executing' do
14
+ show_only = true
15
+ end
16
+
17
+ opts.on '-s', '--separator=', 'Change the separator' do |s|
18
+ sep = s
19
+ end
20
+
21
+ opts.on '-F', '--field-separator=', 'Specify an awk field separator' do |f|
22
+ fs = f
23
+ end
24
+ end
25
+ optparse.parse!
26
+
27
+ def parse_spec spec
28
+ case spec
29
+ when /(\d*)-(\d*)/
30
+ lower = $1.empty? ? 1 : $1.to_i
31
+ upper = $2.empty? ? 1.0/0.0 : $2.to_i
32
+ lower..upper
33
+ else
34
+ spec.to_i
35
+ end
36
+ end
37
+
38
+ specd = ARGV.collect {|arg| parse_spec arg}
39
+
40
+ grouped = specd.inject([[], nil]) do |acc, cur|
41
+ res, last = acc
42
+ if cur.class == last.class
43
+ res[-1] << cur
44
+ next [res, last]
45
+ else
46
+ res << [cur]
47
+ next [res, cur]
48
+ end
49
+ end[0]
50
+
51
+ if grouped.size == 1 and not Range === grouped[0][0]
52
+ # We only have integers!
53
+ block = %[print #{grouped[0].collect{|i|"$#{i}"}.join %[ "#{sep}" ]}]
54
+ else
55
+ inner = grouped.collect do |group|
56
+ if Integer === group[0]
57
+ 'printf ' + group.collect{|i| "$#{i}"}.join(%[ "#{sep}" ])
58
+ else
59
+ group.collect do |range|
60
+ r_start, r_end = range.begin, range.end
61
+ right, last = (r_end == 1.0/0.0) ? ['NF-1', 'NF'] : [r_end - 1, r_end]
62
+ %[for(i=#{r_start}; i <= #{right}; ++i) printf $i "#{sep}"; printf $#{last}]
63
+ end.join %[ "#{sep}"; ]
64
+ end
65
+ end.join %[ "#{sep}"; ]
66
+ block = %[#{inner}; printf "\\n"]
67
+ end
68
+
69
+ command = fs.nil? ? "awk '{#{block}}'" : "awk -F'#{fs}' '{#{block}}'"
70
+
71
+ if show_only
72
+ puts command
73
+ else
74
+ exec command
75
+ end
@@ -15,4 +15,4 @@ end
15
15
 
16
16
  optparse.parse!
17
17
 
18
- printf "#{format}\n", *(6.times.map{rand(256)})
18
+ printf "#{format}\n", 0x52, *(5.times.map{rand(256)})
data/bin/suc CHANGED
@@ -15,15 +15,9 @@ end
15
15
 
16
16
  optparse.parse!
17
17
 
18
- if ARGV.empty?
19
- io = STDIN
20
- else
21
- io = File.open ARGV[0]
22
- end
23
-
24
18
  counts = Hash.new 0
25
19
 
26
- io.each_line do |line|
20
+ ARGF.each_line do |line|
27
21
  counts[line] += 1
28
22
  end
29
23
 
metadata CHANGED
@@ -1,20 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pierre Carrier
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
11
+ date: 2013-05-07 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description:
15
14
  email:
16
15
  - pierre@spotify.com
17
16
  executables:
17
+ - cols
18
18
  - fixperms
19
19
  - hex2ip
20
20
  - ip2hex
@@ -30,6 +30,7 @@ executables:
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - bin/cols
33
34
  - bin/fixperms
34
35
  - bin/hex2ip
35
36
  - bin/ip2hex
@@ -46,26 +47,25 @@ files:
46
47
  homepage: https://github.com/pcarrier/baze
47
48
  licenses:
48
49
  - ISC
50
+ metadata: {}
49
51
  post_install_message:
50
52
  rdoc_options: []
51
53
  require_paths:
52
54
  - lib
53
55
  required_ruby_version: !ruby/object:Gem::Requirement
54
- none: false
55
56
  requirements:
56
57
  - - ! '>='
57
58
  - !ruby/object:Gem::Version
58
59
  version: '0'
59
60
  required_rubygems_version: !ruby/object:Gem::Requirement
60
- none: false
61
61
  requirements:
62
62
  - - ! '>='
63
63
  - !ruby/object:Gem::Version
64
64
  version: 1.2.0
65
65
  requirements: []
66
66
  rubyforge_project: baze
67
- rubygems_version: 1.8.23
67
+ rubygems_version: 2.0.3
68
68
  signing_key:
69
- specification_version: 3
69
+ specification_version: 4
70
70
  summary: Base utilities for POSIX system
71
71
  test_files: []