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.
@@ -1,9 +1,10 @@
1
1
  class Prak
2
- VERSION = "1.1"
2
+ VERSION = "1.3"
3
3
  end
4
4
 
5
5
  require "prak/bootstrap"
6
6
  require "prak/command_line"
7
+ require "prak/help"
7
8
  require "prak/compile_match_file"
8
9
  require "prak/file"
9
10
  require "prak/search"
@@ -20,6 +20,7 @@ class Prak
20
20
  :java => %w( .java properties ),
21
21
  :js => %w( .js ),
22
22
  :jsp => %w( .jsp .jspx .jhtm .jhtml ),
23
+ :log => %w( .log ),
23
24
  :make => %w( Makefile ),
24
25
  :mason => %w( .mas .mhtml .mpl .mtxt ),
25
26
  :ocaml => %w( .ml .mli ),
@@ -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
- c << %{ f = File.open(fn, "r", :encoding => opt[:standard_encoding]) }
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
- c << %{ line = line.force_encoding("BINARY") unless line.valid_encoding? }
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]) } }
@@ -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{2008-02-03}
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.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: &2153032040 !ruby/object:Gem::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: *2153032040
24
+ version_requirements: *2156887920
25
25
  description: ! 'Modifications by Sven Winkler
26
26
 
27
27