request-log-analyzer 1.2.1 → 1.2.6
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/.gitignore +10 -0
- data/Rakefile +3 -1
- data/lib/request_log_analyzer/aggregator/database.rb +79 -46
- data/lib/request_log_analyzer/controller.rb +12 -7
- data/lib/request_log_analyzer/file_format/merb.rb +5 -7
- data/lib/request_log_analyzer/line_definition.rb +9 -0
- data/lib/request_log_analyzer/request.rb +2 -2
- data/lib/request_log_analyzer/source/log_parser.rb +4 -0
- data/lib/request_log_analyzer.rb +1 -1
- data/request-log-analyzer.gemspec +36 -0
- data/spec/fixtures/header_and_footer.log +6 -0
- data/spec/fixtures/merb_prefixed.log +9 -0
- data/spec/integration/command_line_usage_spec.rb +0 -2
- data/spec/lib/{helper.rb → helpers.rb} +1 -3
- data/spec/lib/macros.rb +2 -0
- data/spec/lib/matchers.rb +63 -0
- data/spec/lib/mocks.rb +12 -1
- data/spec/lib/testing_format.rb +6 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +13 -4
- data/spec/unit/aggregator/database_spec.rb +234 -0
- data/spec/unit/aggregator/summarizer_spec.rb +0 -2
- data/spec/unit/controller/controller_spec.rb +0 -2
- data/spec/unit/controller/log_processor_spec.rb +0 -2
- data/spec/unit/file_format/file_format_api_spec.rb +50 -71
- data/spec/unit/file_format/line_definition_spec.rb +49 -45
- data/spec/unit/file_format/merb_format_spec.rb +20 -2
- data/spec/unit/file_format/rails_format_spec.rb +0 -2
- data/spec/unit/filter/anonymize_filter_spec.rb +0 -1
- data/spec/unit/filter/field_filter_spec.rb +0 -3
- data/spec/unit/filter/filter_spec.rb +17 -0
- data/spec/unit/filter/timespan_filter_spec.rb +0 -3
- data/spec/unit/source/log_parser_spec.rb +5 -4
- data/spec/unit/source/request_spec.rb +91 -52
- data/spec/unit/tracker/duration_tracker_spec.rb +0 -6
- data/spec/unit/tracker/frequency_tracker_spec.rb +0 -6
- data/spec/unit/tracker/hourly_spread_spec.rb +0 -4
- data/spec/unit/tracker/timespan_tracker_spec.rb +0 -4
- data/spec/unit/tracker/tracker_api_spec.rb +0 -2
- data/tasks/github-gem.rake +199 -192
- metadata +120 -92
- data/RELEASE_NOTES.rdoc +0 -10
- data/spec/unit/aggregator/database_inserter_spec.rb +0 -106
- data/tasks/rspec.rake +0 -12
data/tasks/github-gem.rake
CHANGED
|
@@ -1,249 +1,256 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
require 'rubyforge'
|
|
3
2
|
require 'rake'
|
|
4
3
|
require 'rake/tasklib'
|
|
5
4
|
require 'date'
|
|
5
|
+
require 'git'
|
|
6
6
|
|
|
7
|
-
module
|
|
7
|
+
module GithubGem
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
reload_gemspec!
|
|
9
|
+
def self.detect_gemspec_file
|
|
10
|
+
FileList['*.gemspec'].first
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.detect_main_include
|
|
14
|
+
if detect_gemspec_file =~ /^(\.*)\.gemspec$/ && File.exist?("lib/#{$1}.rb")
|
|
15
|
+
"lib/#{$1}.rb"
|
|
16
|
+
elsif FileList['lib/*.rb'].length == 1
|
|
17
|
+
FileList['lib/*.rb'].first
|
|
18
|
+
else
|
|
19
|
+
raise "Could not detect main include file!"
|
|
21
20
|
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class RakeTasks
|
|
24
|
+
|
|
25
|
+
attr_reader :gemspec, :modified_files, :git
|
|
26
|
+
attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
|
|
27
|
+
|
|
28
|
+
def initialize(task_namespace = :gem)
|
|
29
|
+
@gemspec_file = GithubGem.detect_gemspec_file
|
|
30
|
+
@task_namespace = task_namespace
|
|
31
|
+
@main_include = GithubGem.detect_main_include
|
|
32
|
+
@modified_files = []
|
|
33
|
+
@root_dir = Dir.pwd
|
|
34
|
+
@test_pattern = 'test/**/*_test.rb'
|
|
35
|
+
@spec_pattern = 'spec/**/*_spec.rb'
|
|
36
|
+
@local_branch = 'master'
|
|
37
|
+
@remote = 'origin'
|
|
38
|
+
@remote_branch = 'master'
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
yield(self) if block_given?
|
|
22
42
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
@git = Git.open(@root_dir)
|
|
44
|
+
load_gemspec!
|
|
45
|
+
define_tasks!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
protected
|
|
49
|
+
|
|
50
|
+
def define_test_tasks!
|
|
51
|
+
require 'rake/testtask'
|
|
27
52
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
release_dependencies.push 'doc:publish' if has_rdoc?
|
|
34
|
-
release_dependencies.unshift 'test' if has_tests?
|
|
35
|
-
release_dependencies.unshift 'spec' if has_specs?
|
|
36
|
-
|
|
37
|
-
desc "Releases a new version of #{@name}"
|
|
38
|
-
task(:release => release_dependencies) { release_task }
|
|
39
|
-
|
|
40
|
-
# helper task for releasing
|
|
41
|
-
task(:check_clean_master_branch) { verify_clean_status('master') }
|
|
42
|
-
task(:check_version) { verify_version(ENV['VERSION'] || @specification.version) }
|
|
43
|
-
task(:version => [:check_version]) { set_gem_version! }
|
|
44
|
-
task(:create_tag) { create_version_tag! }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Register RDoc tasks
|
|
48
|
-
if has_rdoc?
|
|
49
|
-
require 'rake/rdoctask'
|
|
50
|
-
|
|
51
|
-
namespace(:doc) do
|
|
52
|
-
desc 'Generate documentation for request-log-analyzer'
|
|
53
|
-
Rake::RDocTask.new(:compile) do |rdoc|
|
|
54
|
-
rdoc.rdoc_dir = 'doc'
|
|
55
|
-
rdoc.title = @name
|
|
56
|
-
rdoc.options += @specification.rdoc_options
|
|
57
|
-
rdoc.rdoc_files.include(@specification.extra_rdoc_files)
|
|
58
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
desc "Publish RDoc files for #{@name} to Github"
|
|
62
|
-
task(:publish => :compile) do
|
|
63
|
-
sh 'git checkout gh-pages'
|
|
64
|
-
sh 'git pull origin gh-pages'
|
|
65
|
-
sh 'cp -rf doc/* .'
|
|
66
|
-
sh "git commit -am \"Publishing newest RDoc documentation for #{@name}\""
|
|
67
|
-
sh "git push origin gh-pages"
|
|
68
|
-
sh "git checkout master"
|
|
69
|
-
end
|
|
53
|
+
namespace(:test) do
|
|
54
|
+
Rake::TestTask.new(:basic) do |t|
|
|
55
|
+
t.pattern = test_pattern
|
|
56
|
+
t.verbose = true
|
|
57
|
+
t.libs << 'test'
|
|
70
58
|
end
|
|
71
59
|
end
|
|
60
|
+
|
|
61
|
+
desc "Run all unit tests for #{gemspec.name}"
|
|
62
|
+
task(:test => ['test:basic'])
|
|
63
|
+
end
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
require 'spec/rake/spectask'
|
|
65
|
+
def define_rspec_tasks!
|
|
66
|
+
require 'spec/rake/spectask'
|
|
76
67
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
namespace(:spec) do
|
|
69
|
+
desc "Verify all RSpec examples for #{gemspec.name}"
|
|
70
|
+
Spec::Rake::SpecTask.new(:basic) do |t|
|
|
71
|
+
t.spec_files = FileList[spec_pattern]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
|
75
|
+
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
|
76
|
+
t.spec_files = FileList[spec_pattern]
|
|
77
|
+
t.spec_opts << '--format' << 'specdoc' << '--color'
|
|
80
78
|
end
|
|
79
|
+
|
|
80
|
+
desc "Run RCov on specs for #{gemspec.name}"
|
|
81
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
82
|
+
t.spec_files = FileList[spec_pattern]
|
|
83
|
+
t.rcov = true
|
|
84
|
+
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
|
85
|
+
end
|
|
81
86
|
end
|
|
82
87
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
require 'rake/testtask'
|
|
86
|
-
|
|
87
|
-
desc "Run all unit tests for #{@name}"
|
|
88
|
-
Rake::TestTask.new(:test) do |t|
|
|
89
|
-
t.pattern = 'test/**/*_test.rb'
|
|
90
|
-
t.verbose = true
|
|
91
|
-
t.libs << 'test'
|
|
92
|
-
end
|
|
93
|
-
end
|
|
88
|
+
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
|
89
|
+
task(:spec => ['spec:specdoc'])
|
|
94
90
|
end
|
|
95
91
|
|
|
96
|
-
|
|
92
|
+
# Defines the rake tasks
|
|
93
|
+
def define_tasks!
|
|
94
|
+
|
|
95
|
+
define_test_tasks! if has_tests?
|
|
96
|
+
define_rspec_tasks! if has_specs?
|
|
97
|
+
|
|
98
|
+
namespace(@task_namespace) do
|
|
99
|
+
desc "Updates the filelist in the gemspec file"
|
|
100
|
+
task(:manifest) { manifest_task }
|
|
101
|
+
|
|
102
|
+
desc "Builds the .gem package"
|
|
103
|
+
task(:build => :manifest) { build_task }
|
|
97
104
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
desc "Sets the version of the gem in the gemspec"
|
|
106
|
+
task(:set_version => [:check_version, :check_current_branch]) { version_task }
|
|
107
|
+
task(:check_version => :fetch_origin) { check_version_task }
|
|
108
|
+
|
|
109
|
+
task(:fetch_origin) { fetch_origin_task }
|
|
110
|
+
task(:check_current_branch) { check_current_branch_task }
|
|
111
|
+
task(:check_clean_status) { check_clean_status_task }
|
|
112
|
+
task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }
|
|
113
|
+
|
|
114
|
+
checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]
|
|
115
|
+
checks.unshift('spec:basic') if has_specs?
|
|
116
|
+
checks.unshift('test:basic') if has_tests?
|
|
117
|
+
|
|
118
|
+
desc "Perform all checks that would occur before a release"
|
|
119
|
+
task(:release_checks => checks)
|
|
101
120
|
|
|
102
|
-
|
|
103
|
-
|
|
121
|
+
desc "Release a new verison of the gem"
|
|
122
|
+
task(:release => [:release_checks, :set_version, :build, :push_changes]) { release_task }
|
|
123
|
+
|
|
124
|
+
task(:push_changes => [:commit_modified_files, :tag_version]) { push_changes_task }
|
|
125
|
+
task(:tag_version) { tag_version_task }
|
|
126
|
+
task(:commit_modified_files) { commit_modified_files_task }
|
|
127
|
+
end
|
|
104
128
|
end
|
|
105
129
|
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
@specification = eval(spec)
|
|
114
|
-
@name = specification.name
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def run_command(command)
|
|
118
|
-
lines = []
|
|
119
|
-
IO.popen(command) { |f| lines = f.readlines }
|
|
120
|
-
return lines
|
|
130
|
+
def manifest_task
|
|
131
|
+
# Load all the gem's files using "git ls-files"
|
|
132
|
+
repository_files = git.ls_files.keys
|
|
133
|
+
test_files = Dir[test_pattern] + Dir[spec_pattern]
|
|
134
|
+
|
|
135
|
+
update_gemspec(:files, repository_files)
|
|
136
|
+
update_gemspec(:test_files, repository_files & test_files)
|
|
121
137
|
end
|
|
122
138
|
|
|
123
|
-
def
|
|
124
|
-
|
|
139
|
+
def build_task
|
|
140
|
+
sh "gem build -q #{gemspec_file}"
|
|
141
|
+
Dir.mkdir('pkg') unless File.exist?('pkg')
|
|
142
|
+
sh "mv #{gemspec.name}-#{gemspec.version}.gem pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
|
125
143
|
end
|
|
126
144
|
|
|
127
|
-
def
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
raise "#{file} is not modified and cannot be committed!"
|
|
134
|
-
end
|
|
145
|
+
def version_task
|
|
146
|
+
update_gemspec(:version, ENV['VERSION']) if ENV['VERSION']
|
|
147
|
+
update_gemspec(:date, Date.today)
|
|
148
|
+
|
|
149
|
+
update_version_file(gemspec.version)
|
|
150
|
+
update_version_constant(gemspec.version)
|
|
135
151
|
end
|
|
136
152
|
|
|
137
|
-
def
|
|
138
|
-
|
|
153
|
+
def check_version_task
|
|
154
|
+
raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
|
|
155
|
+
proposed_version = Gem::Version.new(ENV['VERSION'] || gemspec.version)
|
|
156
|
+
# Loads the latest version number using the created tags
|
|
157
|
+
newest_version = git.tags.map { |tag| tag.name.split('-').last }.compact.map { |v| Gem::Version.new(v) }.max
|
|
158
|
+
raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version && newest_version >= proposed_version
|
|
139
159
|
end
|
|
140
160
|
|
|
141
|
-
def
|
|
142
|
-
|
|
143
|
-
options_str = options.map { |o| "--#{o}"}.join(' ')
|
|
144
|
-
sh "git push #{options_str} #{remote} #{branch}"
|
|
161
|
+
def check_not_diverged_task
|
|
162
|
+
raise "The current branch is diverged from the remote branch!" if git.log.between('HEAD', git.branches["#{remote}/#{remote_branch}"].gcommit).any?
|
|
145
163
|
end
|
|
146
164
|
|
|
147
|
-
def
|
|
148
|
-
|
|
149
|
-
spec.gsub!(/^(\s*s\.version\s*=\s*)('|")(.+)('|")(\s*)$/) { "#{$1}'#{new_version}'#{$5}" }
|
|
150
|
-
spec.gsub!(/^(\s*s\.date\s*=\s*)('|")(.+)('|")(\s*)$/) { "#{$1}'#{Date.today.strftime('%Y-%m-%d')}'#{$5}" }
|
|
151
|
-
File.open(gemspec_file, 'w') { |f| f << spec }
|
|
152
|
-
reload_gemspec!
|
|
165
|
+
def check_clean_status_task
|
|
166
|
+
raise "The current working copy contains modifications" if git.status.changed.any?
|
|
153
167
|
end
|
|
154
168
|
|
|
155
|
-
def
|
|
156
|
-
|
|
157
|
-
spec.gsub!(/^(\s*s\.date\s*=\s*)('|")(.+)('|")(\s*)$/) { "#{$1}'#{new_date.strftime('%Y-%m-%d')}'#{$5}" }
|
|
158
|
-
File.open(gemspec_file, 'w') { |f| f << spec }
|
|
159
|
-
reload_gemspec!
|
|
169
|
+
def check_current_branch_task
|
|
170
|
+
raise "Currently not on #{local_branch} branch!" unless git.branch.name == local_branch.to_s
|
|
160
171
|
end
|
|
161
172
|
|
|
162
|
-
def
|
|
163
|
-
|
|
173
|
+
def fetch_origin_task
|
|
174
|
+
git.fetch('origin')
|
|
164
175
|
end
|
|
165
176
|
|
|
166
|
-
def
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
def commit_modified_files_task
|
|
178
|
+
if modified_files.any?
|
|
179
|
+
modified_files.each { |file| git.add(file) }
|
|
180
|
+
git.commit("Released #{gemspec.name} gem version #{gemspec.version}")
|
|
181
|
+
end
|
|
169
182
|
end
|
|
170
183
|
|
|
171
|
-
def
|
|
172
|
-
|
|
173
|
-
lines = run_command('git status')
|
|
174
|
-
raise "You don't have the most recent version available. Run git pull first." if /^\# Your branch is behind/ =~ lines[1]
|
|
175
|
-
raise "You are currently not working in the #{on_branch} branch!" unless on_branch.nil? || (/^\# On branch (.+)/ =~ lines.first && $1 == on_branch)
|
|
176
|
-
raise "Your master branch contains modifications!" unless /^nothing to commit \(working directory clean\)/ =~ lines.last
|
|
184
|
+
def tag_version_task
|
|
185
|
+
git.add_tag("#{gemspec.name}-#{gemspec.version}")
|
|
177
186
|
end
|
|
178
187
|
|
|
179
|
-
def
|
|
180
|
-
|
|
181
|
-
raise "This version number (#{new_version}) is not higher than the highest tagged version (#{newest_version})" if !newest_version.nil? && newest_version >= Gem::Version.new(new_version.to_s)
|
|
188
|
+
def push_changes_task
|
|
189
|
+
git.push(remote, remote_branch, true)
|
|
182
190
|
end
|
|
183
191
|
|
|
184
|
-
def
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
def release_task
|
|
193
|
+
puts
|
|
194
|
+
puts '------------------------------------------------------------'
|
|
195
|
+
puts "Released #{gemspec.name} version #{gemspec.version}"
|
|
188
196
|
end
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
list -= [gemspec_file]
|
|
195
|
-
|
|
196
|
-
if File.exist?('.gitignore')
|
|
197
|
-
File.read('.gitignore').each_line do |glob|
|
|
198
|
-
glob = glob.chomp.sub(/^\//, '')
|
|
199
|
-
list -= Dir[glob]
|
|
200
|
-
list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
# update the spec file
|
|
205
|
-
spec = File.read(gemspec_file)
|
|
206
|
-
spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
|
|
207
|
-
assignment = $1
|
|
208
|
-
bunch = $2 ? list.grep(/^(test.*_test\.rb|spec.*_spec.rb)$/) : list
|
|
209
|
-
'%s%%w(%s)' % [assignment, bunch.join(' ')]
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
File.open(gemspec_file, 'w') { |f| f << spec }
|
|
213
|
-
reload_gemspec!
|
|
197
|
+
|
|
198
|
+
private
|
|
199
|
+
|
|
200
|
+
def has_specs?
|
|
201
|
+
FileList[spec_pattern].any?
|
|
214
202
|
end
|
|
215
203
|
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
Dir.mkdir('pkg') unless File.exist?('pkg')
|
|
219
|
-
sh "mv #{name}-#{specification.version}.gem pkg/#{name}-#{specification.version}.gem"
|
|
204
|
+
def has_tests?
|
|
205
|
+
FileList[test_pattern].any?
|
|
220
206
|
end
|
|
221
207
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
208
|
+
|
|
209
|
+
# Loads the gemspec file
|
|
210
|
+
def load_gemspec!
|
|
211
|
+
@gemspec = eval(File.read(@gemspec_file))
|
|
225
212
|
end
|
|
226
213
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
214
|
+
# Updates the VERSION file with the new version
|
|
215
|
+
def update_version_file(version)
|
|
216
|
+
if File.exists?('VERSION')
|
|
217
|
+
File.open('VERSION', 'w') { |f| f << version.to_s }
|
|
218
|
+
modified_files << 'VERSION'
|
|
219
|
+
end
|
|
220
|
+
end
|
|
231
221
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
222
|
+
# Updates the VERSION constant in the main include file if it exists
|
|
223
|
+
def update_version_constant(version)
|
|
224
|
+
file_contents = File.read(main_include)
|
|
225
|
+
if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
|
|
226
|
+
File.open(main_include, 'w') { |f| f << file_contents }
|
|
227
|
+
modified_files << main_include
|
|
228
|
+
end
|
|
239
229
|
end
|
|
240
230
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
231
|
+
# Updates an attribute of the gemspec file.
|
|
232
|
+
# This function will open the file, and search/replace the attribute using a regular expression.
|
|
233
|
+
def update_gemspec(attribute, new_value, literal = false)
|
|
234
|
+
|
|
235
|
+
unless literal
|
|
236
|
+
new_value = case new_value
|
|
237
|
+
when Array then "%w(#{new_value.join(' ')})"
|
|
238
|
+
when Hash, String then new_value.inspect
|
|
239
|
+
when Date then new_value.strftime('%Y-%m-%d').inspect
|
|
240
|
+
else raise "Cannot write value #{new_value.inspect} to gemspec file!"
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
spec = File.read(gemspec_file)
|
|
245
|
+
regexp = Regexp.new('^(\s+\w+\.' + Regexp.quote(attribute.to_s) + '\s*=\s*)[^\s].*$')
|
|
246
|
+
if spec.sub!(regexp) { $1 + new_value }
|
|
247
|
+
File.open(gemspec_file, 'w') { |f| f << spec }
|
|
248
|
+
modified_files << gemspec_file
|
|
249
|
+
|
|
250
|
+
# Reload the gemspec so the changes are incorporated
|
|
251
|
+
load_gemspec!
|
|
252
|
+
end
|
|
245
253
|
end
|
|
254
|
+
|
|
246
255
|
end
|
|
247
256
|
end
|
|
248
|
-
|
|
249
|
-
Rake::GithubGem.define_tasks!
|