bugzyrb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/common/sed.rb ADDED
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env ruby -w
2
+ =begin
3
+ * Name: sed.rb
4
+ * Description: Sed like operations
5
+ * Author: rkumar
6
+ * Date: 2010-06-10 20:10
7
+ * License: Ruby License
8
+
9
+ =end
10
+
11
+ ##
12
+ # changes one or more rows based on pattern and replacement
13
+ # Also if replacement is not given, expects a block and yields
14
+ # matching lines to it
15
+
16
+ module Sed
17
+ def change_row filename, pattern, replacement = nil
18
+ d = _read filename
19
+ d.each { |row|
20
+ if row =~ pattern
21
+ if replacement
22
+ row.gsub!( pattern, replacement)
23
+ else
24
+ yield row
25
+ end
26
+ end
27
+ }
28
+ _write filename, d
29
+ end
30
+ def change_file filename
31
+ d = _read filename
32
+ d.each { |row|
33
+ yield row
34
+ }
35
+ _write filename, d
36
+ end
37
+ ##
38
+ # deletes on more rows based on a pattern
39
+ # Also takes a block and yields each row to it
40
+ def delete_row filename, pattern = nil
41
+ d = _read filename
42
+ if pattern
43
+ d.delete_if { |row| row =~ pattern }
44
+ else
45
+ d.delete_if { |row| yield row }
46
+ end
47
+ _write filename, d
48
+ end
49
+ ##
50
+ # inserts text in filename at lineno.
51
+ #
52
+ def insert_row filename, lineno, text
53
+ d = _read filename
54
+ d.insert(lineno, text)
55
+ _write filename, d
56
+ 0
57
+ end
58
+ ##
59
+ # read the given filename into an array
60
+ def _read filename
61
+ d = []
62
+ File.open(filename).each { |line|
63
+ d << line
64
+ }
65
+ return d
66
+ end
67
+ ##
68
+ # write the given array to the filename
69
+ def _write filename, array
70
+ File.open(filename, "w") do |file|
71
+ array.each { |row| file.puts row }
72
+ end
73
+ end
74
+ ##
75
+ # searches filelist array for pattern yielding filename, linenumber and line
76
+ # @return [Array, nil] array of lines containing filename,lineno,line tab delimited
77
+ # or nil if nothing found
78
+ # Taken from http://facets.rubyforge.org/apidoc/index.html more filelist.
79
+ # egrepoptions - count only, linenumber, filename, invert etc
80
+ def egrep(filelist, pattern, egrepoptions={})
81
+ lines = []
82
+ filelist.each do |fn|
83
+ open(fn) do |inf|
84
+ count = 0
85
+
86
+ inf.each do |line|
87
+ count += 1
88
+ if pattern.match(line)
89
+ if block_given?
90
+ yield fn, count, line
91
+ else
92
+ #puts "#{fn}:#{count}:#{line}"
93
+ lines << "#{fn}#{@todo_delim}#{count}#{@todo_delim}#{line}"
94
+ end
95
+ end
96
+ end
97
+
98
+ end
99
+ end
100
+ unless block_given?
101
+ ret = lines.empty? nil:lines
102
+ return ret
103
+ end
104
+ end
105
+ end # module
106
+
107
+ if __FILE__ == $0
108
+ include Sed
109
+ filename = "tmp.txt"
110
+ change_row filename, /_10_/ do |row|
111
+ row.sub!(/_10_/,"10")
112
+ end
113
+ change_row filename, /\+13\+/, "13"
114
+ delete_row(filename,/XXX/)
115
+ delete_row(filename) do |line|
116
+ line =~ /junk/
117
+ end
118
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bugzyrb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Rahul Kumar
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-07 00:00:00 +05:30
18
+ default_executable: bugzyrb
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: yard
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 5
30
+ version: "0.5"
31
+ type: :development
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: subcommand
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 0
43
+ - 5
44
+ version: 1.0.5
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ - !ruby/object:Gem::Dependency
48
+ name: highline
49
+ prerelease: false
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 1
56
+ - 5
57
+ - 2
58
+ version: 1.5.2
59
+ type: :runtime
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: terminal-table
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 1
70
+ - 4
71
+ - 2
72
+ version: 1.4.2
73
+ type: :runtime
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: sqlite3-ruby
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ segments:
83
+ - 1
84
+ - 2
85
+ - 5
86
+ version: 1.2.5
87
+ type: :runtime
88
+ version_requirements: *id005
89
+ - !ruby/object:Gem::Dependency
90
+ name: arrayfields
91
+ prerelease: false
92
+ requirement: &id006 !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ segments:
97
+ - 4
98
+ - 7
99
+ - 4
100
+ version: 4.7.4
101
+ type: :runtime
102
+ version_requirements: *id006
103
+ description: basic, easy-to-use command-line issue-tracker using sqlite for ruby 1.9
104
+ email: sentinel1879@gmail.com
105
+ executables:
106
+ - bugzyrb
107
+ extensions: []
108
+
109
+ extra_rdoc_files:
110
+ - LICENSE
111
+ - README.rdoc
112
+ files:
113
+ - .document
114
+ - .gitignore
115
+ - LICENSE
116
+ - README.rdoc
117
+ - Rakefile
118
+ - VERSION
119
+ - bin/bugzyrb
120
+ - bugzy.cfg
121
+ - bugzyrb.gemspec
122
+ - lib/bugzyrb.rb
123
+ - lib/common/cmdapp.rb
124
+ - lib/common/colorconstants.rb
125
+ - lib/common/db.rb
126
+ - lib/common/sed.rb
127
+ has_rdoc: true
128
+ homepage: http://github.com/rkumar/bugzyrb
129
+ licenses: []
130
+
131
+ post_install_message:
132
+ rdoc_options:
133
+ - --charset=UTF-8
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ requirements: []
151
+
152
+ rubyforge_project: bugzyrb
153
+ rubygems_version: 1.3.6
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: command-line bug/issue tracker using sqlite, ruby 1.9
157
+ test_files: []
158
+