prak 1.1 → 1.3
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/lib/prak.rb +2 -1
- data/lib/prak/command_line.rb +1 -0
- data/lib/prak/compile_match_file.rb +18 -2
- data/prak.gemspec +2 -2
- metadata +3 -3
data/lib/prak.rb
CHANGED
data/lib/prak/command_line.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
class Prak
|
2
|
+
|
3
|
+
|
4
|
+
def self.ruby_1_9?
|
5
|
+
RUBY_VERSION.to_f >= 1.9
|
6
|
+
end
|
7
|
+
|
2
8
|
def self.compile_match_file
|
3
9
|
c = []
|
4
10
|
c << %{def match_file(re, fn, file_separator) }
|
@@ -13,13 +19,23 @@ class Prak
|
|
13
19
|
c << %{ before_context_size = opt[:before_context] }
|
14
20
|
end
|
15
21
|
c << %{ if fn.is_a? String }
|
16
|
-
|
22
|
+
|
23
|
+
if ruby_1_9?
|
24
|
+
c << %{ f = File.open(fn, "r", :encoding => opt[:standard_encoding]) }
|
25
|
+
else
|
26
|
+
c << %{ f = File.open(fn, "r") }
|
27
|
+
end
|
28
|
+
|
17
29
|
c << %{ elsif fn.is_a? IO }
|
18
30
|
c << %{ f = fn }
|
19
31
|
c << %{ end }
|
20
32
|
|
21
33
|
c << %{ f.each_line do |line| }
|
22
|
-
|
34
|
+
|
35
|
+
if ruby_1_9?
|
36
|
+
c << %{line = line.force_encoding("BINARY") unless line.valid_encoding?}
|
37
|
+
end
|
38
|
+
|
23
39
|
c << %{ i += 1 }
|
24
40
|
if opt[:print_output]
|
25
41
|
c << %{ line.scan(re){ matches << eval(opt[:print_output]) } }
|
data/prak.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.spec do |s|
|
|
3
3
|
s.name = %q{prak}
|
4
4
|
s.version = "2.0"
|
5
5
|
|
6
|
-
s.authors = ["Daniel Lucraft"]
|
7
|
-
s.date = %q{
|
6
|
+
s.authors = ["Sven Winkler (original Daniel Lucraft)"]
|
7
|
+
s.date = %q{2011-08-22}
|
8
8
|
s.default_executable = %q{prak}
|
9
9
|
s.description = %q{Based on the Perl tool 'ack' by Andy Lester. Examples with similar grep: $ prak pattern $ grep pattern $(find . | grep -v .svn) $ prak --ruby pattern $ grep pattern $(find . -name '*.rb' | grep -v .svn) == FEATURES/PROBLEMS: * Ruby regular expression syntax (uses oniguruma gem if installed). * Highlighted output. * Automatically recurses down the current directory or any given directories. * Skips version control directories, backups like '~' and '#' and your * ruby project's pkg directory. * Allows inclusion and exclusion of files based on types. * Many options similar to grep.}
|
10
10
|
s.email = %q{dan@fluentradical.com}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-08-23 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hoe
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156887920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.12'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156887920
|
25
25
|
description: ! 'Modifications by Sven Winkler
|
26
26
|
|
27
27
|
|