rubyc 0.0.10 → 0.0.11
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.
- data/README.rdoc +19 -1
- data/bin/rubyc +6 -4
- data/lib/rubyc/version.rb +1 -1
- data/rubyc.gemspec +1 -1
- metadata +12 -14
data/README.rdoc
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
= Description
|
|
2
2
|
Adds Ruby's powers to the command line.
|
|
3
|
-
Supports many enumerator methods applied to STDIN. The current line is represented by the line variable.
|
|
3
|
+
Supports many enumerator methods applied to STDIN. The current line is represented by the "line" variable name or it's shorter alias 'l'.
|
|
4
|
+
|
|
5
|
+
To get help:
|
|
6
|
+
rubyc help
|
|
7
|
+
|
|
4
8
|
== Example
|
|
5
9
|
$ ls | rubyc map 'line.upcase'
|
|
6
10
|
GEMFILE
|
|
@@ -10,3 +14,17 @@ Supports many enumerator methods applied to STDIN. The current line is represent
|
|
|
10
14
|
ACTIONMAILER
|
|
11
15
|
ACTIONPACK
|
|
12
16
|
...
|
|
17
|
+
|
|
18
|
+
Here are the currently supported methods:
|
|
19
|
+
compact # Remove empty lines
|
|
20
|
+
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.
|
|
21
|
+
grep # Enumerable#grep
|
|
22
|
+
help [TASK] # Describe available tasks or one specific task
|
|
23
|
+
map # Apply Enumerable#map on each line
|
|
24
|
+
merge # Merge consecutive lines
|
|
25
|
+
scan # String#scan
|
|
26
|
+
select # Enumerable#select
|
|
27
|
+
sort_by # Emumerable#sort_by
|
|
28
|
+
sum # Rails Enumerable#sum
|
|
29
|
+
uniq # uniq
|
|
30
|
+
|
data/bin/rubyc
CHANGED
|
@@ -11,6 +11,7 @@ module ::Enumerable
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
# This method was borrowed from ActiveSupport code
|
|
14
15
|
def group_by
|
|
15
16
|
self.inject({}) do |memo, elem|
|
|
16
17
|
key = yield elem
|
|
@@ -19,7 +20,8 @@ module ::Enumerable
|
|
|
19
20
|
memo
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
|
-
|
|
23
|
+
|
|
24
|
+
# File activesupport/lib/active_support/core_ext/enumerable.rb, line 57
|
|
23
25
|
def sum(identity = 0, &block)
|
|
24
26
|
if block_given?
|
|
25
27
|
map(&block).sum(identity)
|
|
@@ -51,12 +53,12 @@ class Rubyc < Thor
|
|
|
51
53
|
desc :select, "Apply Enumerable#select on each line"
|
|
52
54
|
def select(code)
|
|
53
55
|
proc = eval( "Proc.new{|line| l = line; #{code}}" )
|
|
54
|
-
STDIN.
|
|
56
|
+
STDIN.each do |line|
|
|
55
57
|
puts line if proc.call(line.chomp)
|
|
56
58
|
end
|
|
57
59
|
end
|
|
58
60
|
|
|
59
|
-
desc :count_by, "Count by"
|
|
61
|
+
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"
|
|
60
62
|
def count_by(code = nil)
|
|
61
63
|
code ||= "line"
|
|
62
64
|
proc = eval( "Proc.new{|line| l = line; #{code}}" )
|
|
@@ -98,7 +100,7 @@ class Rubyc < Thor
|
|
|
98
100
|
|
|
99
101
|
desc :compact, "Remove empty lines"
|
|
100
102
|
def compact
|
|
101
|
-
|
|
103
|
+
STDIN.each{|line| puts line if line.strip != ""}
|
|
102
104
|
end
|
|
103
105
|
|
|
104
106
|
desc :merge, "Merge consecutive lines"
|
data/lib/rubyc/version.rb
CHANGED
data/rubyc.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
|
9
9
|
s.authors = ["Martin Chabot"]
|
|
10
10
|
s.email = ["chabotm@gmail.com"]
|
|
11
|
-
s.homepage = ""
|
|
11
|
+
s.homepage = "https://github.com/martinos/rubyc"
|
|
12
12
|
s.summary = %q{Adds Ruby's powers to the command line}
|
|
13
13
|
s.description = %q{Adds Ruby's powers to the command line}
|
|
14
14
|
s.rubyforge_project = "rubyc"
|
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:
|
|
4
|
+
hash: 9
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 11
|
|
10
|
+
version: 0.0.11
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Martin Chabot
|
|
@@ -15,10 +15,10 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
19
|
-
default_executable:
|
|
18
|
+
date: 2012-01-06 00:00:00 Z
|
|
20
19
|
dependencies:
|
|
21
20
|
- !ruby/object:Gem::Dependency
|
|
21
|
+
prerelease: false
|
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
|
23
23
|
none: false
|
|
24
24
|
requirements:
|
|
@@ -28,11 +28,11 @@ dependencies:
|
|
|
28
28
|
segments:
|
|
29
29
|
- 0
|
|
30
30
|
version: "0"
|
|
31
|
-
prerelease: false
|
|
32
|
-
type: :runtime
|
|
33
31
|
requirement: *id001
|
|
32
|
+
type: :runtime
|
|
34
33
|
name: thor
|
|
35
34
|
- !ruby/object:Gem::Dependency
|
|
35
|
+
prerelease: false
|
|
36
36
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
|
37
37
|
none: false
|
|
38
38
|
requirements:
|
|
@@ -42,11 +42,11 @@ dependencies:
|
|
|
42
42
|
segments:
|
|
43
43
|
- 0
|
|
44
44
|
version: "0"
|
|
45
|
-
prerelease: false
|
|
46
|
-
type: :development
|
|
47
45
|
requirement: *id002
|
|
46
|
+
type: :development
|
|
48
47
|
name: rake
|
|
49
48
|
- !ruby/object:Gem::Dependency
|
|
49
|
+
prerelease: false
|
|
50
50
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
|
51
51
|
none: false
|
|
52
52
|
requirements:
|
|
@@ -57,9 +57,8 @@ dependencies:
|
|
|
57
57
|
- 1
|
|
58
58
|
- 0
|
|
59
59
|
version: "1.0"
|
|
60
|
-
prerelease: false
|
|
61
|
-
type: :development
|
|
62
60
|
requirement: *id003
|
|
61
|
+
type: :development
|
|
63
62
|
name: bundler
|
|
64
63
|
description: Adds Ruby's powers to the command line
|
|
65
64
|
email:
|
|
@@ -79,8 +78,7 @@ files:
|
|
|
79
78
|
- lib/rubyc.rb
|
|
80
79
|
- lib/rubyc/version.rb
|
|
81
80
|
- rubyc.gemspec
|
|
82
|
-
|
|
83
|
-
homepage: ""
|
|
81
|
+
homepage: https://github.com/martinos/rubyc
|
|
84
82
|
licenses: []
|
|
85
83
|
|
|
86
84
|
post_install_message:
|
|
@@ -109,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
107
|
requirements: []
|
|
110
108
|
|
|
111
109
|
rubyforge_project: rubyc
|
|
112
|
-
rubygems_version: 1.
|
|
110
|
+
rubygems_version: 1.8.11
|
|
113
111
|
signing_key:
|
|
114
112
|
specification_version: 3
|
|
115
113
|
summary: Adds Ruby's powers to the command line
|