rubyc 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/rubyc +14 -14
  2. data/lib/rubyc/version.rb +1 -1
  3. metadata +3 -3
data/bin/rubyc CHANGED
@@ -32,11 +32,11 @@ module ::Enumerable
32
32
  end
33
33
 
34
34
  class Rubyc < Thor
35
- STDOUT.sync
35
+ $stdout.sync = true
36
36
  desc :map, "Apply Enumerable#map on each line"
37
37
  def map(code)
38
38
  proc = eval( "Proc.new{|line| l = line; #{code}}" )
39
- STDIN.map do |line|
39
+ $stdin.each do |line|
40
40
  puts proc.call(line.chomp).to_s
41
41
  end
42
42
  end
@@ -45,7 +45,7 @@ class Rubyc < Thor
45
45
  def sum(code = nil)
46
46
  code ||= "line"
47
47
  proc = eval("Proc.new{|line| l = line; #{code}}")
48
- sum = STDIN.sum do |line|
48
+ sum = $stdin.sum do |line|
49
49
  proc.call(line.chomp).to_f
50
50
  end
51
51
  puts sum
@@ -53,8 +53,8 @@ class Rubyc < Thor
53
53
 
54
54
  desc :select, "Apply Enumerable#select on each line"
55
55
  def select(code)
56
- proc = eval( "Proc.new{|line| l = line; #{code}}" )
57
- STDIN.each do |line|
56
+ proc = eval("Proc.new{|line| l = line; #{code}}")
57
+ $stdin.each do |line|
58
58
  puts line if proc.call(line.chomp)
59
59
  end
60
60
  end
@@ -62,8 +62,8 @@ class Rubyc < Thor
62
62
  desc :count_by, "Count the number of lines that have the same property. The property is defined by the return value of the given the block"
63
63
  def count_by(code = nil)
64
64
  code ||= "line"
65
- proc = eval( "Proc.new{|line| l = line; #{code}}" )
66
- counts = STDIN.count_by do |line|
65
+ proc = eval("Proc.new{|line| l = line; #{code}}")
66
+ counts = $stdin.count_by do |line|
67
67
  proc.call(line.chomp)
68
68
  end
69
69
  puts counts.to_yaml
@@ -72,8 +72,8 @@ class Rubyc < Thor
72
72
  desc :sort_by, "Sort by"
73
73
  def sort_by(code = nil)
74
74
  code ||= "line"
75
- proc = eval( "Proc.new{|line| l = line; #{code}}" )
76
- counts = STDIN.sort_by do |line|
75
+ proc = eval("Proc.new{|line| l = line; #{code}}")
76
+ counts = $stdin.sort_by do |line|
77
77
  proc.call(line.chomp)
78
78
  end
79
79
  puts counts
@@ -82,15 +82,15 @@ class Rubyc < Thor
82
82
  desc :grep, "Grep"
83
83
  def grep(pattern, code = nil)
84
84
  pattern = eval(pattern)
85
- proc = code ? eval( "Proc.new{|line| l = line; #{code}}" ) : nil
86
- puts STDIN.grep(pattern, &proc)
85
+ proc = code ? eval("Proc.new{|line| l = line; #{code}}") : nil
86
+ puts $stdin.grep(pattern, &proc)
87
87
  end
88
88
 
89
89
  desc :scan, "Scan"
90
90
  def scan(pattern, code = nil)
91
91
  pattern = eval(pattern)
92
- proc = code ? eval( "Proc.new{|*match| m = match; #{code}}" ) : nil
93
- str = STDIN.read
92
+ proc = code ? eval("Proc.new{|*match| m = match; #{code}}") : nil
93
+ str = $stdin.read
94
94
  str.scan(pattern, &proc)
95
95
  end
96
96
 
@@ -106,7 +106,7 @@ class Rubyc < Thor
106
106
 
107
107
  desc :merge, "Merge consecutive lines"
108
108
  def merge(nb_lines, sep = ",")
109
- STDIN.each_slice(nb_lines.to_i){|chunk| puts chunk.map{|elem| elem.strip}.join(sep) }
109
+ STDIN.each_slice(nb_lines.to_i){|chunk| puts chunk.map{|elem| elem.strip}.join(sep)}
110
110
  end
111
111
  end
112
112
 
data/lib/rubyc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rubyc
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 13
10
- version: 0.0.13
9
+ - 14
10
+ version: 0.0.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Martin Chabot