relation 0.3.7 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +26 -0
- data/.gitignore +1 -1
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +7 -5
- data/Gemfile.lock +159 -128
- data/MIT-LICENSE +3 -1
- data/README.md +35 -26
- data/Rakefile +5 -5
- data/app/models/dangling.rb +7 -6
- data/app/models/relation.rb +4 -2
- data/app/models/relation_ext.rb +6 -4
- data/db/migrate/{20150810152808_relation.rb → 003_create_relations.rb} +2 -2
- data/lib/relation/engine.rb +1 -23
- data/lib/relation/version.rb +12 -8
- data/lib/relation.rb +3 -6
- data/relation.gemspec +19 -23
- data/test/dangling_test.rb +17 -23
- data/test/internal/app/models/order.rb +2 -0
- data/test/internal/app/models/user.rb +2 -0
- data/test/internal/config/database.yml +3 -0
- data/test/internal/db/schema.rb +28 -0
- data/test/relation_ext_test.rb +14 -21
- data/test/relation_test.rb +10 -17
- data/test/test_helper.rb +11 -12
- metadata +40 -54
- data/.rubocop.yml +0 -8
- data/.travis.yml +0 -43
- data/.watchr +0 -48
- data/Appraisals +0 -15
- data/gemfiles/rails_5.2.gemfile +0 -11
- data/gemfiles/rails_6.0.gemfile +0 -11
- data/test/support/database.rb +0 -57
data/.watchr
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
HH = '#' * 22 unless defined?(HH)
|
2
|
-
H = '#' * 5 unless defined?(H)
|
3
|
-
|
4
|
-
def usage
|
5
|
-
puts <<-EOS
|
6
|
-
Ctrl-\\ or ctrl-4 Running all tests
|
7
|
-
Ctrl-C Exit
|
8
|
-
EOS
|
9
|
-
end
|
10
|
-
|
11
|
-
def run(cmd)
|
12
|
-
puts "#{HH} #{Time.now} #{HH}"
|
13
|
-
puts "#{H} #{cmd}"
|
14
|
-
system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def run_it(type, file)
|
18
|
-
case type
|
19
|
-
when 'test'; run %(ruby -I test #{file})
|
20
|
-
# when 'spec'; run %(rspec -X #{file})
|
21
|
-
else; puts "#{H} unknown type: #{type}, file: #{file}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def run_all_tests
|
26
|
-
puts "\n#{HH} Running all tests #{HH}\n"
|
27
|
-
%w[test spec].each { |dir| run "rake #{dir}" if File.exist?(dir) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def run_matching_files(base)
|
31
|
-
base = base.split('_').first
|
32
|
-
%w[test spec].each { |type|
|
33
|
-
files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
|
34
|
-
run_it type, files.join(' ') unless files.empty?
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
%w[test spec].each { |type|
|
39
|
-
watch("#{type}/#{type}_helper\.rb") { run_all_tests }
|
40
|
-
watch('lib/.*\.rb') { run_all_tests }
|
41
|
-
watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
|
42
|
-
}
|
43
|
-
|
44
|
-
# Ctrl-\ or ctrl-4
|
45
|
-
Signal.trap('QUIT') { run_all_tests }
|
46
|
-
# Ctrl-C
|
47
|
-
Signal.trap('INT') { abort("Interrupted\n") }
|
48
|
-
usage
|
data/Appraisals
DELETED
data/gemfiles/rails_5.2.gemfile
DELETED
data/gemfiles/rails_6.0.gemfile
DELETED
data/test/support/database.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
class DB
|
2
|
-
ActiveRecord::Base.establish_connection adapter: 'sqlite3',
|
3
|
-
database: ':memory:'
|
4
|
-
|
5
|
-
def self.setup
|
6
|
-
capture_stdout do
|
7
|
-
ActiveRecord::Base.logger
|
8
|
-
ActiveRecord::Schema.define(version: 1) do
|
9
|
-
create_table :orders do |t|
|
10
|
-
t.column :name, :string
|
11
|
-
end
|
12
|
-
create_table :users do |t|
|
13
|
-
t.column :name, :string
|
14
|
-
end
|
15
|
-
create_table :relations, id: false do |t|
|
16
|
-
t.string :name
|
17
|
-
t.references :from, null: false
|
18
|
-
t.references :to, null: false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Order.reset_column_information
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.teardown
|
27
|
-
if ActiveRecord::Base.connection.respond_to?(:data_sources)
|
28
|
-
ActiveRecord::Base.connection.data_sources.each do |table|
|
29
|
-
ActiveRecord::Base.connection.drop_table(table)
|
30
|
-
end
|
31
|
-
else
|
32
|
-
ActiveRecord::Base.connection.tables.each do |table|
|
33
|
-
ActiveRecord::Base.connection.drop_table(table)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.capture_stdout
|
39
|
-
real_stdout = $stdout
|
40
|
-
|
41
|
-
$stdout = StringIO.new
|
42
|
-
yield
|
43
|
-
$stdout.string
|
44
|
-
ensure
|
45
|
-
$stdout = real_stdout
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class Order < ActiveRecord::Base
|
50
|
-
end
|
51
|
-
|
52
|
-
class User < ActiveRecord::Base
|
53
|
-
end
|
54
|
-
|
55
|
-
require_relative '../../app/models/relation'
|
56
|
-
require_relative '../../app/models/relation_ext'
|
57
|
-
require_relative '../../app/models/dangling'
|