veritas-sql-generator 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +33 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +25 -0
- data/TODO +17 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/roodi.yml +16 -0
- data/config/site.reek +124 -0
- data/config/yardstick.yml +2 -0
- data/lib/veritas-sql-generator.rb +3 -0
- data/lib/veritas/base_relation.rb +36 -0
- data/lib/veritas/sql/generator.rb +35 -0
- data/lib/veritas/sql/generator/attribute.rb +25 -0
- data/lib/veritas/sql/generator/direction.rb +36 -0
- data/lib/veritas/sql/generator/identifier.rb +27 -0
- data/lib/veritas/sql/generator/literal.rb +160 -0
- data/lib/veritas/sql/generator/logic.rb +349 -0
- data/lib/veritas/sql/generator/relation.rb +111 -0
- data/lib/veritas/sql/generator/relation/base.rb +14 -0
- data/lib/veritas/sql/generator/relation/binary.rb +184 -0
- data/lib/veritas/sql/generator/relation/set.rb +99 -0
- data/lib/veritas/sql/generator/relation/unary.rb +326 -0
- data/lib/veritas/sql/generator/version.rb +9 -0
- data/lib/veritas/sql/generator/visitor.rb +121 -0
- data/spec/rcov.opts +6 -0
- data/spec/shared/command_method_behavior.rb +7 -0
- data/spec/shared/generated_sql_behavior.rb +15 -0
- data/spec/shared/idempotent_method_behavior.rb +7 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/unit/veritas/base_relation/name_spec.rb +45 -0
- data/spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_descending_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/identifier/visit_identifier_spec.rb +26 -0
- data/spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb +23 -0
- data/spec/unit/veritas/sql/generator/literal/visit_class_spec.rb +31 -0
- data/spec/unit/veritas/sql/generator/literal/visit_date_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/literal/visit_date_time_spec.rb +61 -0
- data/spec/unit/veritas/sql/generator/literal/visit_enumerable_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/literal/visit_false_class_spec.rb +14 -0
- data/spec/unit/veritas/sql/generator/literal/visit_nil_class_spec.rb +14 -0
- data/spec/unit/veritas/sql/generator/literal/visit_numeric_spec.rb +34 -0
- data/spec/unit/veritas/sql/generator/literal/visit_string_spec.rb +26 -0
- data/spec/unit/veritas/sql/generator/literal/visit_time_spec.rb +97 -0
- data/spec/unit/veritas/sql/generator/literal/visit_true_class_spec.rb +14 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb +16 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_equality_spec.rb +27 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_exclusion_spec.rb +43 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inclusion_spec.rb +43 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inequality_spec.rb +55 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb +15 -0
- data/spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb +35 -0
- data/spec/unit/veritas/sql/generator/relation/binary/base/visit_veritas_base_relation_spec.rb +22 -0
- data/spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb +42 -0
- data/spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb +35 -0
- data/spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb +35 -0
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb +138 -0
- data/spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb +139 -0
- data/spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb +33 -0
- data/spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb +61 -0
- data/spec/unit/veritas/sql/generator/relation/name_spec.rb +30 -0
- data/spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb +55 -0
- data/spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb +55 -0
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb +138 -0
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb +138 -0
- data/spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb +138 -0
- data/spec/unit/veritas/sql/generator/relation/to_sql_spec.rb +52 -0
- data/spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb +55 -0
- data/spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb +75 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb +138 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb +136 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb +157 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_base_relation_spec.rb +21 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb +125 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb +125 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb +136 -0
- data/spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb +125 -0
- data/spec/unit/veritas/sql/generator/relation/visit_spec.rb +54 -0
- data/spec/unit/veritas/sql/generator/relation/visited_spec.rb +35 -0
- data/spec/unit/veritas/sql/generator/visitor/class_methods/handler_for_spec.rb +71 -0
- data/spec/unit/veritas/sql/generator/visitor/visit_spec.rb +12 -0
- data/spec/unit/veritas/sql/generator/visitor/visited_spec.rb +11 -0
- data/tasks/quality/ci.rake +2 -0
- data/tasks/quality/flay.rake +41 -0
- data/tasks/quality/flog.rake +45 -0
- data/tasks/quality/heckle.rake +203 -0
- data/tasks/quality/metric_fu.rake +26 -0
- data/tasks/quality/reek.rake +9 -0
- data/tasks/quality/roodi.rake +15 -0
- data/tasks/quality/yardstick.rake +23 -0
- data/tasks/spec.rake +38 -0
- data/tasks/yard.rake +9 -0
- data/veritas-sql-generator.gemspec +222 -0
- metadata +285 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
begin
|
2
|
+
require 'flay'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
config = YAML.load_file(File.expand_path('../../../config/flay.yml', __FILE__)).freeze
|
6
|
+
threshold = config.fetch('threshold').to_i
|
7
|
+
total_score = config.fetch('total_score').to_f
|
8
|
+
files = Flay.expand_dirs_to_files(config.fetch('path', 'lib'))
|
9
|
+
|
10
|
+
# original code by Marty Andrews:
|
11
|
+
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
12
|
+
desc 'Analyze for code duplication'
|
13
|
+
task :flay do
|
14
|
+
# run flay once without a threshold to ensure the max mass matches the threshold
|
15
|
+
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => 0)
|
16
|
+
flay.process(*files)
|
17
|
+
|
18
|
+
max = (flay.masses.map { |hash, mass| mass.to_f / flay.hashes[hash].size }.max) || 0
|
19
|
+
unless max >= threshold
|
20
|
+
raise "Adjust flay threshold down to #{max}"
|
21
|
+
end
|
22
|
+
|
23
|
+
total = flay.masses.reduce(0.0) { |total, (hash, mass)| total + (mass.to_f / flay.hashes[hash].size) }
|
24
|
+
unless total == total_score
|
25
|
+
raise "Flay total is now #{total}, but expected #{total_score}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# run flay a second time with the threshold set
|
29
|
+
flay = Flay.new(:fuzzy => false, :verbose => false, :mass => threshold.succ)
|
30
|
+
flay.process(*files)
|
31
|
+
|
32
|
+
if flay.masses.any?
|
33
|
+
flay.report
|
34
|
+
raise "#{flay.masses.size} chunks of code have a duplicate mass > #{threshold}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :flay do
|
39
|
+
abort 'Flay is not available. In order to run flay, you must: gem install flay'
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
begin
|
2
|
+
require 'flog'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
class Float
|
6
|
+
def round_to(n)
|
7
|
+
(self * 10**n).round.to_f * 10**-n
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
config = YAML.load_file(File.expand_path('../../../config/flog.yml', __FILE__)).freeze
|
12
|
+
threshold = config.fetch('threshold').to_f.round_to(1)
|
13
|
+
|
14
|
+
# original code by Marty Andrews:
|
15
|
+
# http://blog.martyandrews.net/2009/05/enforcing-ruby-code-quality.html
|
16
|
+
desc 'Analyze for code complexity'
|
17
|
+
task :flog do
|
18
|
+
flog = Flog.new
|
19
|
+
flog.flog Array(config.fetch('path', 'lib'))
|
20
|
+
|
21
|
+
totals = flog.totals.select { |name, score| name[-5, 5] != '#none' }.
|
22
|
+
map { |name, score| [ name, score.round_to(1) ] }.
|
23
|
+
sort_by { |name, score| score }
|
24
|
+
|
25
|
+
if totals.any?
|
26
|
+
max = totals.last[1]
|
27
|
+
unless max >= threshold
|
28
|
+
raise "Adjust flog score down to #{max}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
bad_methods = totals.select { |name, score| score > threshold }
|
33
|
+
if bad_methods.any?
|
34
|
+
bad_methods.reverse_each do |name, score|
|
35
|
+
puts '%8.1f: %s' % [ score, name ]
|
36
|
+
end
|
37
|
+
|
38
|
+
raise "#{bad_methods.size} methods have a flog complexity > #{threshold}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
rescue LoadError
|
42
|
+
task :flog do
|
43
|
+
abort 'Flog is not available. In order to run flog, you must: gem install flog'
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
|
2
|
+
|
3
|
+
# original code by Ashley Moran:
|
4
|
+
# http://aviewfromafar.net/2007/11/1/rake-task-for-heckling-your-specs
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'pathname'
|
8
|
+
require 'active_support/inflector'
|
9
|
+
require 'heckle'
|
10
|
+
require 'mspec'
|
11
|
+
require 'mspec/utils/name_map'
|
12
|
+
|
13
|
+
SKIP_METHODS = %w[ blank_slate_method_added ].freeze
|
14
|
+
|
15
|
+
class NameMap
|
16
|
+
def file_name(method, constant)
|
17
|
+
map = MAP[method]
|
18
|
+
name = if map
|
19
|
+
map[constant] || map[:default]
|
20
|
+
else
|
21
|
+
method.gsub(/[?!=]\z/, '')
|
22
|
+
end
|
23
|
+
"#{name}_spec.rb"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Heckle each module and class'
|
28
|
+
task :heckle => :verify_rcov do
|
29
|
+
unless Ruby2Ruby::VERSION == '1.2.2'
|
30
|
+
raise "ruby2ruby version #{Ruby2Ruby::VERSION} may not work properly, 1.2.2 *only* is recommended for use with heckle"
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'veritas/sql/generator'
|
34
|
+
root_module = 'Veritas::SQL::Generator'
|
35
|
+
|
36
|
+
spec_dir = Pathname('spec/unit')
|
37
|
+
|
38
|
+
NameMap::MAP.each do |op, method|
|
39
|
+
next if method.kind_of?(Hash)
|
40
|
+
NameMap::MAP[op] = { :default => method }
|
41
|
+
end
|
42
|
+
|
43
|
+
aliases = Hash.new { |h,mod| h[mod] = Hash.new { |h,method| h[method] = method } }
|
44
|
+
|
45
|
+
map = NameMap.new
|
46
|
+
|
47
|
+
heckle_caught_modules = Hash.new { |hash, key| hash[key] = [] }
|
48
|
+
unhandled_mutations = 0
|
49
|
+
|
50
|
+
ObjectSpace.each_object(Module) do |mod|
|
51
|
+
next unless mod.name =~ /\A#{root_module}(?::|\z)/
|
52
|
+
|
53
|
+
spec_prefix = spec_dir.join(mod.name.underscore)
|
54
|
+
|
55
|
+
specs = []
|
56
|
+
|
57
|
+
# get the public class methods
|
58
|
+
metaclass = class << mod; self end
|
59
|
+
ancestors = metaclass.ancestors
|
60
|
+
|
61
|
+
spec_class_methods = mod.singleton_methods(false)
|
62
|
+
|
63
|
+
spec_class_methods.reject! do |method|
|
64
|
+
%w[ yaml_new yaml_tag_subclasses? included nesting constants ].include?(method.to_s)
|
65
|
+
end
|
66
|
+
|
67
|
+
if mod.ancestors.include?(Singleton)
|
68
|
+
spec_class_methods.reject! { |method| method.to_s == 'instance' }
|
69
|
+
end
|
70
|
+
|
71
|
+
# get the protected and private class methods
|
72
|
+
other_class_methods = metaclass.protected_instance_methods(false) |
|
73
|
+
metaclass.private_instance_methods(false)
|
74
|
+
|
75
|
+
ancestors.each do |ancestor|
|
76
|
+
other_class_methods -= ancestor.protected_instance_methods(false) |
|
77
|
+
ancestor.private_instance_methods(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
other_class_methods.reject! do |method|
|
81
|
+
method.to_s == 'allocate' || SKIP_METHODS.include?(method.to_s)
|
82
|
+
end
|
83
|
+
|
84
|
+
other_class_methods.reject! do |method|
|
85
|
+
next unless spec_class_methods.any? { |specced| specced.to_s == $1 }
|
86
|
+
|
87
|
+
spec_class_methods << method
|
88
|
+
end
|
89
|
+
|
90
|
+
# get the instances methods
|
91
|
+
spec_methods = mod.public_instance_methods(false)
|
92
|
+
|
93
|
+
other_methods = mod.protected_instance_methods(false) |
|
94
|
+
mod.private_instance_methods(false)
|
95
|
+
|
96
|
+
other_methods.reject! do |method|
|
97
|
+
next unless spec_methods.any? { |specced| specced.to_s == $1 }
|
98
|
+
|
99
|
+
spec_methods << method
|
100
|
+
end
|
101
|
+
|
102
|
+
# map the class methods to spec files
|
103
|
+
spec_class_methods.each do |method|
|
104
|
+
method = aliases[mod.name][method]
|
105
|
+
next if SKIP_METHODS.include?(method.to_s)
|
106
|
+
|
107
|
+
spec_file = spec_prefix.join('class_methods').join(map.file_name(method, mod.name))
|
108
|
+
|
109
|
+
unless spec_file.file?
|
110
|
+
raise "No spec file #{spec_file} for #{mod}.#{method}"
|
111
|
+
end
|
112
|
+
|
113
|
+
specs << [ ".#{method}", [ spec_file ] ]
|
114
|
+
end
|
115
|
+
|
116
|
+
# map the instance methods to spec files
|
117
|
+
spec_methods.each do |method|
|
118
|
+
method = aliases[mod.name][method]
|
119
|
+
next if SKIP_METHODS.include?(method.to_s)
|
120
|
+
|
121
|
+
spec_file = spec_prefix.join(map.file_name(method, mod.name))
|
122
|
+
|
123
|
+
unless spec_file.file?
|
124
|
+
raise "No spec file #{spec_file} for #{mod}##{method}"
|
125
|
+
end
|
126
|
+
|
127
|
+
specs << [ "##{method}", [ spec_file ] ]
|
128
|
+
end
|
129
|
+
|
130
|
+
# non-public methods are considered covered if they can be mutated
|
131
|
+
# and any spec fails for the current or descendant modules
|
132
|
+
other_methods.each do |method|
|
133
|
+
descedant_specs = []
|
134
|
+
|
135
|
+
ObjectSpace.each_object(Module) do |descedant|
|
136
|
+
next unless descedant.name =~ /\A#{root_module}(?::|\z)/ && mod >= descedant
|
137
|
+
descedant_spec_prefix = spec_dir.join(descedant.name.underscore)
|
138
|
+
descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('*_spec.rb')))
|
139
|
+
|
140
|
+
if method.to_s == 'initialize'
|
141
|
+
descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/new_spec.rb')))
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
specs << [ "##{method}", descedant_specs ]
|
146
|
+
end
|
147
|
+
|
148
|
+
other_class_methods.each do |method|
|
149
|
+
descedant_specs = []
|
150
|
+
|
151
|
+
ObjectSpace.each_object(Module) do |descedant|
|
152
|
+
next unless descedant.name =~ /\A#{root_module}(?::|\z)/ && mod >= descedant
|
153
|
+
descedant_spec_prefix = spec_dir.join(descedant.name.underscore)
|
154
|
+
descedant_specs.concat(Pathname.glob(descedant_spec_prefix.join('class_methods/*_spec.rb')))
|
155
|
+
end
|
156
|
+
|
157
|
+
specs << [ ".#{method}", descedant_specs ]
|
158
|
+
end
|
159
|
+
|
160
|
+
specs.sort.each do |(method, spec_files)|
|
161
|
+
puts "Heckling #{mod}#{method}"
|
162
|
+
IO.popen("spec #{spec_files.join(' ')} --heckle '#{mod}#{method}'") do |pipe|
|
163
|
+
while line = pipe.gets
|
164
|
+
case line = line.chomp
|
165
|
+
when "The following mutations didn't cause test failures:"
|
166
|
+
heckle_caught_modules[mod.name] << method
|
167
|
+
when '+++ mutation'
|
168
|
+
unhandled_mutations += 1
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
if unhandled_mutations > 0
|
176
|
+
error_message_lines = [ "*************\n" ]
|
177
|
+
|
178
|
+
error_message_lines << "Heckle found #{unhandled_mutations} " \
|
179
|
+
"mutation#{"s" unless unhandled_mutations == 1} " \
|
180
|
+
"that didn't cause spec violations\n"
|
181
|
+
|
182
|
+
heckle_caught_modules.each do |mod, methods|
|
183
|
+
error_message_lines << "#{mod} contains the following " \
|
184
|
+
'poorly-specified methods:'
|
185
|
+
methods.each do |method|
|
186
|
+
error_message_lines << " - #{method}"
|
187
|
+
end
|
188
|
+
error_message_lines << ''
|
189
|
+
end
|
190
|
+
|
191
|
+
error_message_lines << 'Get your act together and come back ' \
|
192
|
+
'when your specs are doing their job!'
|
193
|
+
|
194
|
+
raise error_message_lines.join("\n")
|
195
|
+
else
|
196
|
+
puts 'Well done! Your code withstood a heckling.'
|
197
|
+
end
|
198
|
+
end
|
199
|
+
rescue LoadError
|
200
|
+
task :heckle do
|
201
|
+
abort 'Heckle or mspec is not available. In order to run heckle, you must: gem install heckle mspec'
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'metric_fu'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
MetricFu::Configuration.run do |config|
|
6
|
+
config.rcov = {
|
7
|
+
:environment => 'test',
|
8
|
+
:test_files => %w[ spec/**/*_spec.rb ],
|
9
|
+
:rcov_opts => %w[
|
10
|
+
--sort coverage
|
11
|
+
--no-html
|
12
|
+
--text-coverage
|
13
|
+
--no-color
|
14
|
+
--profile
|
15
|
+
--exclude spec/,^/
|
16
|
+
--include lib:spec
|
17
|
+
],
|
18
|
+
}
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
namespace :metrics do
|
22
|
+
task :all do
|
23
|
+
abort 'metric_fu is not available. In order to run metrics:all, you must: gem install metric_fu'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
begin
|
2
|
+
require 'roodi'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
require 'roodi_task'
|
5
|
+
|
6
|
+
RoodiTask.new do |t|
|
7
|
+
t.verbose = false
|
8
|
+
t.config = File.expand_path('../../../config/roodi.yml', __FILE__)
|
9
|
+
t.patterns = %w[ lib/**/*.rb ]
|
10
|
+
end
|
11
|
+
rescue LoadError
|
12
|
+
task :roodi do
|
13
|
+
abort 'Roodi is not available. In order to run roodi, you must: gem install roodi'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
begin
|
2
|
+
require 'pathname'
|
3
|
+
require 'yardstick'
|
4
|
+
require 'yardstick/rake/measurement'
|
5
|
+
require 'yardstick/rake/verify'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
config = YAML.load_file(File.expand_path('../../../config/yardstick.yml', __FILE__))
|
9
|
+
|
10
|
+
# yardstick_measure task
|
11
|
+
Yardstick::Rake::Measurement.new
|
12
|
+
|
13
|
+
# verify_measurements task
|
14
|
+
Yardstick::Rake::Verify.new do |verify|
|
15
|
+
verify.threshold = config.fetch('threshold')
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
%w[ yardstick_measure verify_measurements ].each do |name|
|
19
|
+
task name.to_s do
|
20
|
+
abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
spec_defaults = lambda do |spec|
|
2
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
3
|
+
spec.libs << 'lib' << 'spec'
|
4
|
+
spec.spec_opts << '--options' << 'spec/spec.opts'
|
5
|
+
end
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
|
10
|
+
Spec::Rake::SpecTask.new(:spec, &spec_defaults)
|
11
|
+
rescue LoadError
|
12
|
+
task :spec do
|
13
|
+
abort 'rspec is not available. In order to run spec, you must: gem install rspec'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'rcov'
|
19
|
+
require 'spec/rake/verify_rcov'
|
20
|
+
|
21
|
+
Spec::Rake::SpecTask.new(:rcov) do |rcov|
|
22
|
+
spec_defaults.call(rcov)
|
23
|
+
rcov.rcov = true
|
24
|
+
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
25
|
+
end
|
26
|
+
|
27
|
+
RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
|
28
|
+
rcov.threshold = 100
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
%w[ rcov verify_rcov ].each do |name|
|
32
|
+
task name do
|
33
|
+
abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :spec
|
data/tasks/yard.rake
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{veritas-sql-generator}
|
8
|
+
s.version = "0.0.3"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dan Kubb"]
|
12
|
+
s.date = %q{2011-04-22}
|
13
|
+
s.description = %q{Generate SQL from a veritas relation}
|
14
|
+
s.email = %q{dan.kubb@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"TODO",
|
26
|
+
"config/flay.yml",
|
27
|
+
"config/flog.yml",
|
28
|
+
"config/roodi.yml",
|
29
|
+
"config/site.reek",
|
30
|
+
"config/yardstick.yml",
|
31
|
+
"lib/veritas-sql-generator.rb",
|
32
|
+
"lib/veritas/base_relation.rb",
|
33
|
+
"lib/veritas/sql/generator.rb",
|
34
|
+
"lib/veritas/sql/generator/attribute.rb",
|
35
|
+
"lib/veritas/sql/generator/direction.rb",
|
36
|
+
"lib/veritas/sql/generator/identifier.rb",
|
37
|
+
"lib/veritas/sql/generator/literal.rb",
|
38
|
+
"lib/veritas/sql/generator/logic.rb",
|
39
|
+
"lib/veritas/sql/generator/relation.rb",
|
40
|
+
"lib/veritas/sql/generator/relation/base.rb",
|
41
|
+
"lib/veritas/sql/generator/relation/binary.rb",
|
42
|
+
"lib/veritas/sql/generator/relation/set.rb",
|
43
|
+
"lib/veritas/sql/generator/relation/unary.rb",
|
44
|
+
"lib/veritas/sql/generator/version.rb",
|
45
|
+
"lib/veritas/sql/generator/visitor.rb",
|
46
|
+
"spec/rcov.opts",
|
47
|
+
"spec/shared/command_method_behavior.rb",
|
48
|
+
"spec/shared/generated_sql_behavior.rb",
|
49
|
+
"spec/shared/idempotent_method_behavior.rb",
|
50
|
+
"spec/spec.opts",
|
51
|
+
"spec/spec_helper.rb",
|
52
|
+
"spec/unit/veritas/base_relation/name_spec.rb",
|
53
|
+
"spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb",
|
54
|
+
"spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb",
|
55
|
+
"spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_descending_spec.rb",
|
56
|
+
"spec/unit/veritas/sql/generator/identifier/visit_identifier_spec.rb",
|
57
|
+
"spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb",
|
58
|
+
"spec/unit/veritas/sql/generator/literal/visit_class_spec.rb",
|
59
|
+
"spec/unit/veritas/sql/generator/literal/visit_date_spec.rb",
|
60
|
+
"spec/unit/veritas/sql/generator/literal/visit_date_time_spec.rb",
|
61
|
+
"spec/unit/veritas/sql/generator/literal/visit_enumerable_spec.rb",
|
62
|
+
"spec/unit/veritas/sql/generator/literal/visit_false_class_spec.rb",
|
63
|
+
"spec/unit/veritas/sql/generator/literal/visit_nil_class_spec.rb",
|
64
|
+
"spec/unit/veritas/sql/generator/literal/visit_numeric_spec.rb",
|
65
|
+
"spec/unit/veritas/sql/generator/literal/visit_string_spec.rb",
|
66
|
+
"spec/unit/veritas/sql/generator/literal/visit_time_spec.rb",
|
67
|
+
"spec/unit/veritas/sql/generator/literal/visit_true_class_spec.rb",
|
68
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb",
|
69
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb",
|
70
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb",
|
71
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_equality_spec.rb",
|
72
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_exclusion_spec.rb",
|
73
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb",
|
74
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_spec.rb",
|
75
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inclusion_spec.rb",
|
76
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inequality_spec.rb",
|
77
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb",
|
78
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_spec.rb",
|
79
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb",
|
80
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb",
|
81
|
+
"spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb",
|
82
|
+
"spec/unit/veritas/sql/generator/relation/binary/base/visit_veritas_base_relation_spec.rb",
|
83
|
+
"spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb",
|
84
|
+
"spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb",
|
85
|
+
"spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb",
|
86
|
+
"spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb",
|
87
|
+
"spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb",
|
88
|
+
"spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb",
|
89
|
+
"spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb",
|
90
|
+
"spec/unit/veritas/sql/generator/relation/name_spec.rb",
|
91
|
+
"spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb",
|
92
|
+
"spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb",
|
93
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb",
|
94
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb",
|
95
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb",
|
96
|
+
"spec/unit/veritas/sql/generator/relation/to_sql_spec.rb",
|
97
|
+
"spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb",
|
98
|
+
"spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb",
|
99
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb",
|
100
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb",
|
101
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb",
|
102
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_base_relation_spec.rb",
|
103
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb",
|
104
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb",
|
105
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb",
|
106
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb",
|
107
|
+
"spec/unit/veritas/sql/generator/relation/visit_spec.rb",
|
108
|
+
"spec/unit/veritas/sql/generator/relation/visited_spec.rb",
|
109
|
+
"spec/unit/veritas/sql/generator/visitor/class_methods/handler_for_spec.rb",
|
110
|
+
"spec/unit/veritas/sql/generator/visitor/visit_spec.rb",
|
111
|
+
"spec/unit/veritas/sql/generator/visitor/visited_spec.rb",
|
112
|
+
"tasks/quality/ci.rake",
|
113
|
+
"tasks/quality/flay.rake",
|
114
|
+
"tasks/quality/flog.rake",
|
115
|
+
"tasks/quality/heckle.rake",
|
116
|
+
"tasks/quality/metric_fu.rake",
|
117
|
+
"tasks/quality/reek.rake",
|
118
|
+
"tasks/quality/roodi.rake",
|
119
|
+
"tasks/quality/yardstick.rake",
|
120
|
+
"tasks/spec.rake",
|
121
|
+
"tasks/yard.rake",
|
122
|
+
"veritas-sql-generator.gemspec"
|
123
|
+
]
|
124
|
+
s.homepage = %q{https://github.com/dkubb/veritas-sql-generator}
|
125
|
+
s.require_paths = ["lib"]
|
126
|
+
s.rubygems_version = %q{1.7.2}
|
127
|
+
s.summary = %q{Relational algebra SQL generator}
|
128
|
+
s.test_files = [
|
129
|
+
"spec/shared/command_method_behavior.rb",
|
130
|
+
"spec/shared/generated_sql_behavior.rb",
|
131
|
+
"spec/shared/idempotent_method_behavior.rb",
|
132
|
+
"spec/spec_helper.rb",
|
133
|
+
"spec/unit/veritas/base_relation/name_spec.rb",
|
134
|
+
"spec/unit/veritas/sql/generator/attribute/visit_veritas_attribute_spec.rb",
|
135
|
+
"spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_ascending_spec.rb",
|
136
|
+
"spec/unit/veritas/sql/generator/direction/visit_veritas_relation_operation_order_descending_spec.rb",
|
137
|
+
"spec/unit/veritas/sql/generator/identifier/visit_identifier_spec.rb",
|
138
|
+
"spec/unit/veritas/sql/generator/literal/class_methods/dup_frozen_spec.rb",
|
139
|
+
"spec/unit/veritas/sql/generator/literal/visit_class_spec.rb",
|
140
|
+
"spec/unit/veritas/sql/generator/literal/visit_date_spec.rb",
|
141
|
+
"spec/unit/veritas/sql/generator/literal/visit_date_time_spec.rb",
|
142
|
+
"spec/unit/veritas/sql/generator/literal/visit_enumerable_spec.rb",
|
143
|
+
"spec/unit/veritas/sql/generator/literal/visit_false_class_spec.rb",
|
144
|
+
"spec/unit/veritas/sql/generator/literal/visit_nil_class_spec.rb",
|
145
|
+
"spec/unit/veritas/sql/generator/literal/visit_numeric_spec.rb",
|
146
|
+
"spec/unit/veritas/sql/generator/literal/visit_string_spec.rb",
|
147
|
+
"spec/unit/veritas/sql/generator/literal/visit_time_spec.rb",
|
148
|
+
"spec/unit/veritas/sql/generator/literal/visit_true_class_spec.rb",
|
149
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_conjunction_spec.rb",
|
150
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_disjunction_spec.rb",
|
151
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_connective_negation_spec.rb",
|
152
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_equality_spec.rb",
|
153
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_exclusion_spec.rb",
|
154
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_or_equal_to_spec.rb",
|
155
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_greater_than_spec.rb",
|
156
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inclusion_spec.rb",
|
157
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_inequality_spec.rb",
|
158
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_or_equal_to_spec.rb",
|
159
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_predicate_less_than_spec.rb",
|
160
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_contradiction_spec.rb",
|
161
|
+
"spec/unit/veritas/sql/generator/logic/visit_veritas_logic_proposition_tautology_spec.rb",
|
162
|
+
"spec/unit/veritas/sql/generator/relation/binary/base/to_subquery_spec.rb",
|
163
|
+
"spec/unit/veritas/sql/generator/relation/binary/base/visit_veritas_base_relation_spec.rb",
|
164
|
+
"spec/unit/veritas/sql/generator/relation/binary/class_methods/subquery_spec.rb",
|
165
|
+
"spec/unit/veritas/sql/generator/relation/binary/to_s_spec.rb",
|
166
|
+
"spec/unit/veritas/sql/generator/relation/binary/to_subquery_spec.rb",
|
167
|
+
"spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_join_spec.rb",
|
168
|
+
"spec/unit/veritas/sql/generator/relation/binary/visit_veritas_algebra_product_spec.rb",
|
169
|
+
"spec/unit/veritas/sql/generator/relation/class_methods/subquery_spec.rb",
|
170
|
+
"spec/unit/veritas/sql/generator/relation/class_methods/visit_spec.rb",
|
171
|
+
"spec/unit/veritas/sql/generator/relation/name_spec.rb",
|
172
|
+
"spec/unit/veritas/sql/generator/relation/set/to_s_spec.rb",
|
173
|
+
"spec/unit/veritas/sql/generator/relation/set/to_subquery_spec.rb",
|
174
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_difference_spec.rb",
|
175
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_intersection_spec.rb",
|
176
|
+
"spec/unit/veritas/sql/generator/relation/set/visit_veritas_algebra_union_spec.rb",
|
177
|
+
"spec/unit/veritas/sql/generator/relation/to_sql_spec.rb",
|
178
|
+
"spec/unit/veritas/sql/generator/relation/unary/to_s_spec.rb",
|
179
|
+
"spec/unit/veritas/sql/generator/relation/unary/to_subquery_spec.rb",
|
180
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_projection_spec.rb",
|
181
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_rename_spec.rb",
|
182
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_algebra_restriction_spec.rb",
|
183
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_base_relation_spec.rb",
|
184
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_limit_spec.rb",
|
185
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_offset_spec.rb",
|
186
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_order_spec.rb",
|
187
|
+
"spec/unit/veritas/sql/generator/relation/unary/visit_veritas_relation_operation_reverse_spec.rb",
|
188
|
+
"spec/unit/veritas/sql/generator/relation/visit_spec.rb",
|
189
|
+
"spec/unit/veritas/sql/generator/relation/visited_spec.rb",
|
190
|
+
"spec/unit/veritas/sql/generator/visitor/class_methods/handler_for_spec.rb",
|
191
|
+
"spec/unit/veritas/sql/generator/visitor/visit_spec.rb",
|
192
|
+
"spec/unit/veritas/sql/generator/visitor/visited_spec.rb"
|
193
|
+
]
|
194
|
+
|
195
|
+
if s.respond_to? :specification_version then
|
196
|
+
s.specification_version = 3
|
197
|
+
|
198
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
199
|
+
s.add_runtime_dependency(%q<veritas>, ["= 0.0.3"])
|
200
|
+
s.add_development_dependency(%q<backports>, ["~> 2.1.0"])
|
201
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
202
|
+
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
|
203
|
+
s.add_development_dependency(%q<rspec>, ["~> 1.3.2"])
|
204
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6.8"])
|
205
|
+
else
|
206
|
+
s.add_dependency(%q<veritas>, ["= 0.0.3"])
|
207
|
+
s.add_dependency(%q<backports>, ["~> 2.1.0"])
|
208
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
209
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
210
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
211
|
+
s.add_dependency(%q<yard>, ["~> 0.6.8"])
|
212
|
+
end
|
213
|
+
else
|
214
|
+
s.add_dependency(%q<veritas>, ["= 0.0.3"])
|
215
|
+
s.add_dependency(%q<backports>, ["~> 2.1.0"])
|
216
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
217
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
218
|
+
s.add_dependency(%q<rspec>, ["~> 1.3.2"])
|
219
|
+
s.add_dependency(%q<yard>, ["~> 0.6.8"])
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|