rubyc 0.0.17 → 0.1.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ file1.txt first line
2
+ file1.txt second line
@@ -0,0 +1,2 @@
1
+ file2.txt first line
2
+ file2.txt second line
data/lib/rubyc/cli.rb CHANGED
@@ -34,9 +34,9 @@ module Rubyc
34
34
 
35
35
  desc :select, "Apply Enumerable#select on each line"
36
36
  def select(code)
37
- proc = eval("Proc.new{|line| l = line; #{code}}")
38
- $stdin.each do |line|
39
- puts line if proc.call(line.chomp)
37
+ proc = eval( "Proc.new{|line,index| l = line; lnum = index + 1;#{code}}" )
38
+ $stdin.each_line.each_with_index do |line, index|
39
+ puts line if proc.call(line.chomp, index)
40
40
  end
41
41
  end
42
42
 
@@ -0,0 +1,37 @@
1
+ module MiniTest
2
+ # http://blog.macromates.com/2007/the-textmate-url-scheme/
3
+ module ColorizeStack
4
+ def write(str = "")
5
+ str.each_line do |line|
6
+ super(colorize_line(line))
7
+ end
8
+ end
9
+
10
+ def colorize_line(line)
11
+ red = "\e[31m"
12
+ clear = "\e[0m"
13
+ green = "\e[32m"
14
+ blue = "\e[34m"
15
+ magenta = "\e[35m"
16
+ clear = "\e[0m"
17
+ # test_0001_should_map_stdin_to_stdout(A rubyc cli) [./spec/cli_spec.rb:16]:
18
+ # /Users/martinchabot/dev/my_gems/rubyc/spec/cli_spec.rb:16:in `test_0001_should_map_stdin_to_stdout'
19
+ url_regex = /(.*?)([.\w\/]*.rb):(\d+)(.*)/
20
+ if line =~ url_regex
21
+ prefix, file_name, line_number, suffix = $1, $2, $3, $4
22
+ if File.exist? file_name
23
+ full_path = File.expand_path(file_name)
24
+ app_trace = full_path.match(Dir.pwd) && full_path !~ /vendor/
25
+ new_line = "#{prefix}#{blue}txmt://open?url=file://#{File.dirname(full_path)}/#{clear}#{red if app_trace }#{File.basename(full_path)}#{clear if app_trace}&line=#{line_number}#{suffix}\n"
26
+ else
27
+ new_line = line
28
+ end
29
+ else
30
+ new_line = line
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+
data/lib/rubyc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rubyc
2
- VERSION = "0.0.17"
2
+ VERSION = "0.1.0.alpha"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -1,6 +1,4 @@
1
- ROOT_PATH = File.expand_path('../..', __FILE__)
2
- require File.expand_path('../spec_helper', __FILE__)
3
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
4
2
  require 'rubyc/cli'
5
3
 
6
4
  include SpecHelper
@@ -12,16 +10,16 @@ describe "A rubyc cli" do
12
10
 
13
11
  it "should map stdin to stdout" do
14
12
  out_str = local_io("first\nsecond") do
15
- @cli.map('lnum.to_s + " " + l.upcase')
13
+ @cli.map('"LineNum=#{lnum} Index=#{index}: #{l.upcase}"')
16
14
  end
17
- out_str.must_equal "1 FIRST\n2 SECOND\n"
15
+ out_str.must_equal "LineNum=1 Index=0: FIRST\nLineNum=2 Index=1: SECOND\n"
18
16
  end
19
17
 
20
18
  it "should select line from stdin and send it to stdout" do
21
- out_str = local_io("first\nsecond\nthird") do
22
- @cli.select('l =~ /third/')
19
+ out_str = local_io("John Doe\nBlack Jack\nDr Dolittle\nCracker Jack") do
20
+ @cli.select('l =~ /Jack/ && lnum == 2 && index == 1')
23
21
  end
24
- out_str.must_equal "third\n"
22
+ out_str.must_equal "Black Jack\n"
25
23
  end
26
24
 
27
25
  it "should sum line from stdin and send it to stdout" do
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'stringio'
3
+
4
+
5
+ describe MiniTest::ColorizeStack do
6
+ it 'shoud colorize IO' do
7
+ str = <<EOF
8
+ test_0003_should_return_the_value_from_on_key(AProductionBafFileSpec::AStructureSpec):
9
+ RuntimeError: THIS IS A STACKTRACE TEST
10
+ ./lib/rubyc/colorize_stack.rb:19:in `extract_data_from_raw'
11
+ ./lib/rubyc/colorize_stack.rb:9:in `initialize'
12
+ ./lib/rubyc/colorize_stack.rb:44:in `new'
13
+ ./lib/rubyc/colorize_stack.rb:44:in `parse'
14
+ ./lib/rubyc/core_extensions.rb:18:in `parse'
15
+ ./lib/rubyc/core_extensions.rb:17:in `map'
16
+ ./lib/rubyc/core_extensions.rb:17:in `parse'
17
+ ./lib/rubyc/core_extensions.rb:26:in `parse'
18
+ ./lib/rubyc/core_extensions.rb:39:in `scanned_string'
19
+ ./lib/rubyc/core_extensions.rb:16:in `parse'
20
+ ./lib/rubyc/core_extensions.rb:27:in `read'
21
+ ./spec/spec_helper.rb:8
22
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/spec.rb:118:in `instance_eval'
23
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/spec.rb:118:in `setup'
24
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:713:in `run'
25
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:675:in `run_test_suites'
26
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:669:in `each'
27
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:669:in `run_test_suites'
28
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:668:in `each'
29
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:668:in `run_test_suites'
30
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:632:in `run'
31
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352/gems/minitest-1.7.2/lib/minitest/unit.rb:524:in `autorun'
32
+ /Users/martinos/.rvm/gems/ruby-1.8.7-p352@global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
33
+
34
+ 5 tests, 0 assertions, 0 failures, 5 errors, 0 skips
35
+ EOF
36
+ out = StringIO.new
37
+ out.extend MiniTest::ColorizeStack
38
+ out.write(str)
39
+ str = out.string
40
+ red = "\e\\[31m"
41
+ clear = "\e\\[0m"
42
+ green = "\e\\[32m"
43
+ blue = "\e\\[34m"
44
+ magenta = "\e\\[35m"
45
+ str.must_match %r{txmt://open\?url=file:///(.*)rubyc/lib/rubyc/(.*)colorize_stack.rb(.*)line=19:in `extract_data_from_raw}
46
+ end
47
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  $:.unshift File.expand_path('..', __FILE__)
2
2
  $:.unshift File.expand_path('../../lib', __FILE__)
3
+ ROOT_PATH = File.expand_path('../..', __FILE__)
3
4
  require 'rubyc'
4
5
  require 'minitest/spec'
5
6
  require 'minitest/autorun'
7
+ require 'rubyc/colorize_stack'
6
8
 
7
9
  module SpecHelper
8
10
  def local_io(in_str)
@@ -15,38 +17,4 @@ module SpecHelper
15
17
  out_str
16
18
  end
17
19
  end
18
-
19
-
20
- # require 'colorize'
21
- #
22
- # module ColorizeIO
23
- # def puts(str = "")
24
- # red = "\\e[31m"
25
- # blank = "\\e[0m"
26
- # green = "\\e[32m"
27
- # blue = "\\e[34m"
28
- # magenta = "\\e[35m"
29
- # #
30
- # url_regex = %r{(\\S*.rb):(\\d+)(.*)}
31
- # str.each_line do |line|
32
- # if line =~ url_regex
33
- # file_name = $1
34
- # line_number = $2
35
- # complement = $3
36
- # if File.exist? file_name
37
- # full_path = File.expand_path(file_name)
38
- # app_trace = full_path.match(ROOT_PATH) && full_path !~ /vendor/
39
- # new_line = "#{blue}txmt://open?url=file://#{File.dirname(full_path)}/#{red if app_trace }#{File.basename(full_path)}#{blank}&line=#{line_number
40
- # }#{complement}"
41
- # else
42
- # new_line = line
43
- # end
44
- # else
45
- # new_line = line
46
- # end
47
- # super(new_line + "\\n")
48
- # end
49
- # end
50
- # end
51
- #
52
- # MiniTest::Unit.output.extend ColorizeIO
20
+ MiniTest::Unit.output.extend MiniTest::ColorizeStack
metadata CHANGED
@@ -1,173 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubyc
3
- version: !ruby/object:Gem::Version
4
- hash: 61
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 17
10
- version: 0.0.17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.alpha
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Martin Chabot
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-09-07 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- requirement: *id001
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
32
15
  name: thor
16
+ requirement: &70183398144720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- - !ruby/object:Gem::Dependency
35
23
  prerelease: false
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- requirement: *id002
24
+ version_requirements: *70183398144720
25
+ - !ruby/object:Gem::Dependency
46
26
  name: rake
27
+ requirement: &70183398144200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
47
33
  type: :development
48
- - !ruby/object:Gem::Dependency
49
34
  prerelease: false
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70183398144200
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: &70183398143680 !ruby/object:Gem::Requirement
51
39
  none: false
52
- requirements:
40
+ requirements:
53
41
  - - ~>
54
- - !ruby/object:Gem::Version
55
- hash: 15
56
- segments:
57
- - 1
58
- - 0
59
- version: "1.0"
60
- requirement: *id003
61
- name: bundler
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
62
44
  type: :development
63
- - !ruby/object:Gem::Dependency
64
45
  prerelease: false
65
- version_requirements: &id004 !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
74
- requirement: *id004
46
+ version_requirements: *70183398143680
47
+ - !ruby/object:Gem::Dependency
75
48
  name: minitest
49
+ requirement: &70183398142900 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
76
55
  type: :development
77
- - !ruby/object:Gem::Dependency
78
56
  prerelease: false
79
- version_requirements: &id005 !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
88
- requirement: *id005
57
+ version_requirements: *70183398142900
58
+ - !ruby/object:Gem::Dependency
89
59
  name: aruba
60
+ requirement: &70183398140540 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
90
66
  type: :development
91
- - !ruby/object:Gem::Dependency
92
67
  prerelease: false
93
- version_requirements: &id006 !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
102
- requirement: *id006
68
+ version_requirements: *70183398140540
69
+ - !ruby/object:Gem::Dependency
103
70
  name: colorize
71
+ requirement: &70183398138940 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
104
77
  type: :development
78
+ prerelease: false
79
+ version_requirements: *70183398138940
105
80
  description: Adds Ruby's powers to the command line
106
- email:
81
+ email:
107
82
  - chabotm@gmail.com
108
- executables:
83
+ executables:
109
84
  - rubyc
110
85
  extensions: []
111
-
112
86
  extra_rdoc_files: []
113
-
114
- files:
87
+ files:
115
88
  - .gitignore
116
89
  - Gemfile
117
90
  - Guardfile
91
+ - LICENSE.txt
118
92
  - README.md
119
93
  - Rakefile
120
94
  - bin/rubyc
95
+ - features/fixtures/file1.csv
96
+ - features/fixtures/file1.txt
97
+ - features/fixtures/file2.txt
121
98
  - features/rubyc.feature
122
99
  - features/step_definitions/.rubyc_steps.rb.swp
123
100
  - features/step_definitions/rubyc_steps.rb
124
101
  - features/support/env.rb
125
102
  - lib/rubyc.rb
126
103
  - lib/rubyc/cli.rb
104
+ - lib/rubyc/colorize_stack.rb
127
105
  - lib/rubyc/core_extensions.rb
128
106
  - lib/rubyc/version.rb
129
107
  - rubyc.gemspec
130
108
  - spec/cli_spec.rb
131
- - spec/rubyc_spec.rb
109
+ - spec/colorize_stack_spec.rb
132
110
  - spec/spec_helper.rb
133
111
  homepage: https://github.com/martinos/rubyc
134
112
  licenses: []
135
-
136
113
  post_install_message:
137
114
  rdoc_options: []
138
-
139
- require_paths:
115
+ require_paths:
140
116
  - lib
141
- required_ruby_version: !ruby/object:Gem::Requirement
117
+ required_ruby_version: !ruby/object:Gem::Requirement
142
118
  none: false
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- hash: 3
147
- segments:
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
148
124
  - 0
149
- version: "0"
150
- required_rubygems_version: !ruby/object:Gem::Requirement
125
+ hash: -2279959136995254074
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
127
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- hash: 3
156
- segments:
157
- - 0
158
- version: "0"
128
+ requirements:
129
+ - - ! '>'
130
+ - !ruby/object:Gem::Version
131
+ version: 1.3.1
159
132
  requirements: []
160
-
161
133
  rubyforge_project: rubyc
162
- rubygems_version: 1.8.11
134
+ rubygems_version: 1.8.10
163
135
  signing_key:
164
136
  specification_version: 3
165
137
  summary: Adds Ruby's powers to the command line
166
- test_files:
138
+ test_files:
139
+ - features/fixtures/file1.csv
140
+ - features/fixtures/file1.txt
141
+ - features/fixtures/file2.txt
167
142
  - features/rubyc.feature
168
143
  - features/step_definitions/.rubyc_steps.rb.swp
169
144
  - features/step_definitions/rubyc_steps.rb
170
145
  - features/support/env.rb
171
146
  - spec/cli_spec.rb
172
- - spec/rubyc_spec.rb
147
+ - spec/colorize_stack_spec.rb
173
148
  - spec/spec_helper.rb
data/spec/rubyc_spec.rb DELETED
File without changes