flog 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/.autotest +15 -0
- data/History.txt +22 -0
- data/Manifest.txt +1 -17
- data/bin/flog +1 -1
- data/lib/flog.rb +107 -103
- data/test/test_flog.rb +463 -1414
- metadata +26 -24
- metadata.gz.sig +0 -0
- data/gem_updater.rb +0 -161
- data/spec_fixtures/collection/bigger_example/acts/date_range.rb +0 -199
- data/spec_fixtures/collection/bigger_example/acts/range.rb +0 -391
- data/spec_fixtures/collection/bigger_example/association_extensions/date_ranged.rb +0 -11
- data/spec_fixtures/collection/bigger_example/association_extensions/ranged.rb +0 -13
- data/spec_fixtures/collection/bigger_example/reflection_extensions/ranged.rb +0 -50
- data/spec_fixtures/directory/bot_filter.rb +0 -70
- data/spec_fixtures/directory/bot_parser.rb +0 -79
- data/spec_fixtures/directory/bot_parser_format.rb +0 -23
- data/spec_fixtures/directory/bot_sender.rb +0 -46
- data/spec_fixtures/empty/empty.rb +0 -0
- data/spec_fixtures/simple/simple.rb +0 -191
- data/test/test_flog_command.rb +0 -343
- data/test/test_flog_integration.rb +0 -946
- data/test/test_helper.rb +0 -65
- data/unpack.rb +0 -22
- data/update_scores.rb +0 -245
metadata
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
14
|
+
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZIm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OcZ8TdyiyINUHtb5ej/T
|
30
|
+
FBHgymkyj/AOSqKRIpXPhjC6
|
31
|
+
-----END CERTIFICATE-----
|
11
32
|
|
12
|
-
date: 2009-
|
33
|
+
date: 2009-12-09 00:00:00 -08:00
|
13
34
|
default_executable:
|
14
35
|
dependencies:
|
15
36
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +61,7 @@ dependencies:
|
|
40
61
|
requirements:
|
41
62
|
- - ">="
|
42
63
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
64
|
+
version: 2.4.0
|
44
65
|
version:
|
45
66
|
description: |-
|
46
67
|
Flog reports the most tortured code in an easy to read pain
|
@@ -56,32 +77,16 @@ extra_rdoc_files:
|
|
56
77
|
- Manifest.txt
|
57
78
|
- README.txt
|
58
79
|
files:
|
80
|
+
- .autotest
|
59
81
|
- History.txt
|
60
82
|
- Manifest.txt
|
61
83
|
- README.txt
|
62
84
|
- Rakefile
|
63
85
|
- bin/flog
|
64
|
-
- gem_updater.rb
|
65
86
|
- lib/flog.rb
|
66
87
|
- lib/flog_task.rb
|
67
88
|
- lib/gauntlet_flog.rb
|
68
|
-
- unpack.rb
|
69
|
-
- update_scores.rb
|
70
|
-
- spec_fixtures/collection/bigger_example/acts/date_range.rb
|
71
|
-
- spec_fixtures/collection/bigger_example/acts/range.rb
|
72
|
-
- spec_fixtures/collection/bigger_example/association_extensions/date_ranged.rb
|
73
|
-
- spec_fixtures/collection/bigger_example/association_extensions/ranged.rb
|
74
|
-
- spec_fixtures/collection/bigger_example/reflection_extensions/ranged.rb
|
75
|
-
- spec_fixtures/directory/bot_filter.rb
|
76
|
-
- spec_fixtures/directory/bot_parser.rb
|
77
|
-
- spec_fixtures/directory/bot_parser_format.rb
|
78
|
-
- spec_fixtures/directory/bot_sender.rb
|
79
|
-
- spec_fixtures/empty/empty.rb
|
80
|
-
- spec_fixtures/simple/simple.rb
|
81
89
|
- test/test_flog.rb
|
82
|
-
- test/test_flog_command.rb
|
83
|
-
- test/test_flog_integration.rb
|
84
|
-
- test/test_helper.rb
|
85
90
|
has_rdoc: true
|
86
91
|
homepage: http://ruby.sadi.st/
|
87
92
|
licenses: []
|
@@ -113,6 +118,3 @@ specification_version: 3
|
|
113
118
|
summary: Flog reports the most tortured code in an easy to read pain report
|
114
119
|
test_files:
|
115
120
|
- test/test_flog.rb
|
116
|
-
- test/test_flog_command.rb
|
117
|
-
- test/test_flog_integration.rb
|
118
|
-
- test/test_helper.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/gem_updater.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'rubygems/remote_fetcher'
|
2
|
-
|
3
|
-
$u ||= false
|
4
|
-
|
5
|
-
module GemUpdater
|
6
|
-
GEMURL = URI.parse 'http://gems.rubyforge.org'
|
7
|
-
|
8
|
-
@@index = nil
|
9
|
-
|
10
|
-
def self.stupid_gems
|
11
|
-
["ruby-aes-table1-1.0.gem", # stupid dups usually because of "dash" renames
|
12
|
-
"ruby-aes-unroll1-1.0.gem",
|
13
|
-
"hpricot-scrub-0.2.0.gem",
|
14
|
-
"extract_curves-0.0.1.gem",
|
15
|
-
"extract_curves-0.0.1-i586-linux.gem",
|
16
|
-
"extract_curves-0.0.1-mswin32.gem",
|
17
|
-
"rfeedparser-ictv-0.9.931.gem",
|
18
|
-
"spec_unit-0.0.1.gem"]
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.initialize_dir
|
22
|
-
Dir.mkdir "../gems" unless File.directory? "../gems"
|
23
|
-
self.in_gem_dir do
|
24
|
-
File.symlink ".", "cache" unless File.exist? "cache"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.get_source_index
|
29
|
-
return @@index if @@index
|
30
|
-
|
31
|
-
dump = if $u or not File.exist? '.source_index' then
|
32
|
-
url = GEMURL + "Marshal.#{Gem.marshal_version}.Z"
|
33
|
-
dump = Gem::RemoteFetcher.fetcher.fetch_path url
|
34
|
-
require 'zlib'
|
35
|
-
dump = Gem.inflate dump
|
36
|
-
open '.source_index', 'wb' do |io| io.write dump end
|
37
|
-
dump
|
38
|
-
else
|
39
|
-
open '.source_index', 'rb' do |io| io.read end
|
40
|
-
end
|
41
|
-
|
42
|
-
@@index = Marshal.load dump
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.get_latest_gems
|
46
|
-
@@cache ||= get_source_index.latest_specs
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.get_gems_by_name
|
50
|
-
@@by_name ||= Hash[*get_latest_gems.map { |gem|
|
51
|
-
[gem.name, gem, gem.full_name, gem]
|
52
|
-
}.flatten]
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.dependencies_of name
|
56
|
-
index = self.get_source_index
|
57
|
-
get_gems_by_name[name].dependencies.map { |dep| index.search(dep).last }
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.dependent_upon name
|
61
|
-
get_latest_gems.find_all { |gem|
|
62
|
-
gem.dependencies.any? { |dep| dep.name == name }
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.update_gem_tarballs
|
67
|
-
GemUpdater.initialize_dir
|
68
|
-
|
69
|
-
latest = GemUpdater.get_latest_gems
|
70
|
-
|
71
|
-
puts "updating mirror"
|
72
|
-
|
73
|
-
self.in_gem_dir do
|
74
|
-
gems = Dir["*.gem"]
|
75
|
-
tgzs = Dir["*.tgz"]
|
76
|
-
|
77
|
-
old = tgzs - latest.map { |spec| "#{spec.full_name}.tgz" }
|
78
|
-
unless old.empty? then
|
79
|
-
puts "deleting #{old.size} tgzs"
|
80
|
-
old.each do |tgz|
|
81
|
-
File.unlink tgz
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
new = latest.map { |spec|
|
86
|
-
"#{spec.full_name}.tgz"
|
87
|
-
} - tgzs
|
88
|
-
|
89
|
-
puts "fetching #{new.size} tgzs"
|
90
|
-
|
91
|
-
latest.sort.each do |spec|
|
92
|
-
full_name = spec.full_name
|
93
|
-
tgz_name = "#{full_name}.tgz"
|
94
|
-
gem_name = "#{full_name}.gem"
|
95
|
-
|
96
|
-
next if tgzs.include? tgz_name
|
97
|
-
|
98
|
-
unless gems.include? gem_name then
|
99
|
-
begin
|
100
|
-
warn "downloading #{full_name}"
|
101
|
-
Gem::RemoteFetcher.fetcher.download(spec, GEMURL, Dir.pwd)
|
102
|
-
rescue Gem::RemoteFetcher::FetchError
|
103
|
-
warn " failed"
|
104
|
-
next
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
warn "converting #{gem_name} to tarball"
|
109
|
-
|
110
|
-
unless File.directory? full_name then
|
111
|
-
system "gem unpack cache/#{gem_name}"
|
112
|
-
system "gem spec -l cache/#{gem_name} > #{full_name}/gemspec.rb"
|
113
|
-
end
|
114
|
-
|
115
|
-
system "tar zmcf #{tgz_name} #{full_name}"
|
116
|
-
system "rm -rf #{full_name} #{gem_name}"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.each_gem filter = /^[\w-]+-\d+(\.\d+)*\.tgz$/
|
122
|
-
self.in_gem_dir do
|
123
|
-
Dir["*.tgz"].each do |tgz|
|
124
|
-
next unless tgz =~ filter
|
125
|
-
|
126
|
-
yield File.basename(tgz, ".tgz")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.with_gem name
|
132
|
-
self.in_gem_dir do
|
133
|
-
begin
|
134
|
-
system "tar zxmf #{name}.tgz 2> /dev/null"
|
135
|
-
Dir.chdir name do
|
136
|
-
yield name
|
137
|
-
end
|
138
|
-
ensure
|
139
|
-
system "rm -r #{name}"
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def self.load_yaml path, default = {}
|
145
|
-
YAML.load(File.read(path)) rescue default
|
146
|
-
end
|
147
|
-
|
148
|
-
def self.save_yaml path, data
|
149
|
-
File.open("#{path}.new", 'w') do |f|
|
150
|
-
warn "*** saving #{path}"
|
151
|
-
YAML.dump data, f
|
152
|
-
end
|
153
|
-
File.rename "#{path}.new", path
|
154
|
-
end
|
155
|
-
|
156
|
-
def self.in_gem_dir
|
157
|
-
Dir.chdir "../gems" do
|
158
|
-
yield
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
module Centerstone #:nodoc:
|
2
|
-
module Acts #:nodoc:
|
3
|
-
module DateRange
|
4
|
-
include ActionView::Helpers::DateHelper
|
5
|
-
|
6
|
-
def self.included(base) # :nodoc:
|
7
|
-
base.extend ClassMethods
|
8
|
-
unless ActiveRecord::Base.respond_to?(:end_dated_association_date)
|
9
|
-
class << ActiveRecord::Base
|
10
|
-
attr :end_dated_association_date, true
|
11
|
-
end
|
12
|
-
ActiveRecord::Base.end_dated_association_date = Proc.new { Time.now }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
def self.included(base) # :nodoc:
|
18
|
-
base.extend ClassMethods
|
19
|
-
end
|
20
|
-
|
21
|
-
%w{begin end}.each do |bound|
|
22
|
-
define_method "acts_as_range_#{bound}" do
|
23
|
-
send(self.class.send("acts_as_range_#{bound}_attr").to_sym)
|
24
|
-
end
|
25
|
-
|
26
|
-
define_method "acts_as_range_#{bound}=" do |val|
|
27
|
-
send((self.class.send("acts_as_range_#{bound}_attr").to_s + '=').to_sym, val)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# does the range for this object include the specified point in time?
|
32
|
-
def include?(t)
|
33
|
-
true if self.class.find(self.id, :on => t)
|
34
|
-
rescue
|
35
|
-
false
|
36
|
-
end
|
37
|
-
|
38
|
-
# expire this object
|
39
|
-
def expire(time = Time.now)
|
40
|
-
return false if acts_as_range_end
|
41
|
-
if time.is_a?(Time)
|
42
|
-
self.acts_as_range_end = 1.second.ago(time)
|
43
|
-
elsif time.is_a?(Date)
|
44
|
-
self.acts_as_range_end = time - 1
|
45
|
-
end
|
46
|
-
save!
|
47
|
-
end
|
48
|
-
|
49
|
-
# see if this object is expired
|
50
|
-
def expired?(time = Time.now)
|
51
|
-
return false if not acts_as_range_end
|
52
|
-
return acts_as_range_end <= time
|
53
|
-
end
|
54
|
-
|
55
|
-
# return a description of how long this object (has) lived (as of some specified point in time)
|
56
|
-
def lifetime(time = Time.now)
|
57
|
-
return 'forever' if acts_as_range_begin.nil?
|
58
|
-
return 'in future' if acts_as_range_end.nil? and acts_as_range_begin > time
|
59
|
-
distance_of_time_in_words(acts_as_range_begin, acts_as_range_end || time)
|
60
|
-
end
|
61
|
-
|
62
|
-
def limit_date_range(&block)
|
63
|
-
time = [ acts_as_range_begin, acts_as_range_end ]
|
64
|
-
prior, ActiveRecord::Base.end_dated_association_date = ActiveRecord::Base.end_dated_association_date, Proc.new { time }
|
65
|
-
yield
|
66
|
-
ensure
|
67
|
-
ActiveRecord::Base.end_dated_association_date = prior
|
68
|
-
end
|
69
|
-
|
70
|
-
def destroy_without_callbacks
|
71
|
-
unless new_record?
|
72
|
-
if acts_as_range_configuration[:end_dated]
|
73
|
-
now = self.default_timezone == :utc ? Time.now.utc : Time.now
|
74
|
-
self.class.update_all self.class.send(:sanitize_sql, ["#{acts_as_range_end_attr} = ?", now]), "id = #{quote_value(id)}"
|
75
|
-
else
|
76
|
-
super
|
77
|
-
end
|
78
|
-
end
|
79
|
-
freeze
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
module ClassMethods
|
84
|
-
|
85
|
-
# find objects with intervals including the current time
|
86
|
-
def with_current_time_scope(&block)
|
87
|
-
t = ActiveRecord::Base.end_dated_association_date.call
|
88
|
-
if t.respond_to? :first
|
89
|
-
with_overlapping_scope(t.first, t.last, &block)
|
90
|
-
else
|
91
|
-
with_containing_scope(t, t, &block)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
module ClassMethods
|
99
|
-
def acts_as_date_range(options = {})
|
100
|
-
return if acts_as_date_range? # don't let this be done twice
|
101
|
-
raise "options must be a Hash" unless options.is_a?(Hash)
|
102
|
-
|
103
|
-
acts_as_range({ :begin => :begin_time, :end => :end_time }.update(options))
|
104
|
-
acts_as_date_range_configure_class(options)
|
105
|
-
end
|
106
|
-
|
107
|
-
def acts_as_date_range?
|
108
|
-
included_modules.include?(InstanceMethods)
|
109
|
-
end
|
110
|
-
|
111
|
-
def sequentialized?
|
112
|
-
sequentialized_on ? true : false
|
113
|
-
end
|
114
|
-
|
115
|
-
def sequentialized_on
|
116
|
-
acts_as_range_configuration[:sequentialize]
|
117
|
-
end
|
118
|
-
|
119
|
-
protected
|
120
|
-
|
121
|
-
def acts_as_date_range_singleton_sequentialize_class
|
122
|
-
before_validation_on_create do |obj|
|
123
|
-
obj.acts_as_range_begin ||= Time.now
|
124
|
-
true
|
125
|
-
end
|
126
|
-
|
127
|
-
before_create do |obj|
|
128
|
-
# Expiring any open object
|
129
|
-
obj.class.find(:all, :conditions => "#{acts_as_range_end_attr} is null").each {|o| o.expire(obj.acts_as_range_begin)}
|
130
|
-
true
|
131
|
-
end
|
132
|
-
|
133
|
-
validate_on_create do |obj|
|
134
|
-
# If any record defines a date after the begin_date then data is corrupt
|
135
|
-
if obj.class.count(:conditions => ["#{acts_as_range_begin_attr} >= ? or #{acts_as_range_end_attr} > ?",
|
136
|
-
obj.acts_as_range_begin, obj.acts_as_range_begin]) > 0
|
137
|
-
obj.errors.add(acts_as_range_begin_attr, 'Begin time is before other keys begin time or end time')
|
138
|
-
end
|
139
|
-
true
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
module ParamExtension
|
144
|
-
def to_sql
|
145
|
-
collect { |elem| "#{elem} = ?" }.join(' and ')
|
146
|
-
end
|
147
|
-
|
148
|
-
def to_attributes_for(obj)
|
149
|
-
collect { |elem| obj.attributes[elem.to_s] }
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
|
154
|
-
def acts_as_date_range_param_sequentialize_class(*params)
|
155
|
-
params.extend(ParamExtension)
|
156
|
-
|
157
|
-
before_validation_on_create do |obj|
|
158
|
-
obj.acts_as_range_begin ||= Time.now
|
159
|
-
true
|
160
|
-
end
|
161
|
-
|
162
|
-
before_create do |obj|
|
163
|
-
# Expiring any open object
|
164
|
-
obj.class.find(:all, :conditions => ["#{acts_as_range_end_attr} is null and #{params.to_sql}",
|
165
|
-
params.to_attributes_for(obj)].flatten).each do |o|
|
166
|
-
o.expire(obj.acts_as_range_begin)
|
167
|
-
end
|
168
|
-
true
|
169
|
-
end
|
170
|
-
|
171
|
-
validate_on_create do |obj|
|
172
|
-
# If any record defines a date after the begin_date then data is corrupt
|
173
|
-
if obj.class.count(:conditions => ["#{params.to_sql} and (#{acts_as_range_begin_attr} >= ? or #{acts_as_range_end_attr} > ?)",
|
174
|
-
params.to_attributes_for(obj), obj.acts_as_range_begin, obj.acts_as_range_begin].flatten) > 0
|
175
|
-
obj.errors.add(acts_as_range_begin_attr, 'Begin time is before other begin time or end time')
|
176
|
-
end
|
177
|
-
true
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
def acts_as_date_range_sequentialize_class(*params)
|
182
|
-
params.flatten!
|
183
|
-
if params == [true]
|
184
|
-
acts_as_date_range_singleton_sequentialize_class
|
185
|
-
else
|
186
|
-
acts_as_date_range_param_sequentialize_class(*params)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def acts_as_date_range_configure_class(options = {})
|
191
|
-
write_inheritable_attribute(:acts_as_date_range_configuration, options)
|
192
|
-
include InstanceMethods
|
193
|
-
|
194
|
-
acts_as_date_range_sequentialize_class(options[:sequentialize]) if options[:sequentialize]
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|