handshake_service 0.1.5 → 0.1.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.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/lib/handshake_service/version.rb +1 -1
- data/lib/tasks/auto_annotate_models.rake +1 -1
- data/lib/tasks/deploy.rake +0 -2
- data/lib/tasks/elasticsearch.rake +60 -58
- data/lib/tasks/invalids.rake +25 -23
- data/lib/tasks/rspec_generator.rake +18 -16
- metadata +1 -2
- data/lib/handshake_service/railtie.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5922673b0c8bc5de4fd74e232495f95657f9be66
|
4
|
+
data.tar.gz: d819fd2f8f632a5e870d9bf11610a514788fd815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bee3cee2f06f22b0c7d5bd029f893a6a801214882221810cdca1968e168ecce82bbc0e5522a5ea3686765f4a09c43aba56e670339f953621054ce7d2e5b25ff
|
7
|
+
data.tar.gz: 9929ef8325393dc2c1ce8906ba1a8ee8fb6d93a5d71e4f3530c54876a184cbebcd935e2a7a8440cc9f0d28dae273fdc9c3215299fd12a776574fcc9fd18f398a
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# NOTE: only doing this in development as some production environments (Heroku)
|
2
2
|
# NOTE: are sensitive to local FS writes, and besides -- it's just not proper
|
3
3
|
# NOTE: to have a dev-mode tool do its thing in production.
|
4
|
-
if(Rails.env.development?
|
4
|
+
if defined?(Rails) and Rails.env.development?
|
5
5
|
task :set_annotation_options do
|
6
6
|
# You can override any of these by setting an environment variable of the
|
7
7
|
# same name.
|
data/lib/tasks/deploy.rake
CHANGED
@@ -4,82 +4,84 @@
|
|
4
4
|
# Assumes usage of the elasticsearch-ruby libraries
|
5
5
|
# TODO: Assumes you have a library called ElasticsearchAdminHelper defined with the right methods. Move that helper into this gem
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
if defined?(Rails)
|
8
|
+
namespace :elasticsearch do
|
9
|
+
desc 'Reindexes all ActiveRecord model indices'
|
10
|
+
task "reindex:all" => :environment do
|
11
|
+
Rails.application.eager_load!
|
12
|
+
include ElasticsearchAdminHelper
|
13
|
+
|
14
|
+
ActiveRecord::Base.descendants.each do |model_class|
|
15
|
+
next unless model_class.respond_to? :__elasticsearch__
|
16
|
+
reindex_model(model_class)
|
17
|
+
end
|
18
|
+
|
19
|
+
puts 'All indices reindexed'
|
16
20
|
end
|
17
21
|
|
18
|
-
|
19
|
-
|
22
|
+
desc 'Deletes indices and then reindexes all ActiveRecord model indices assuming none exist yet'
|
23
|
+
task "reindex:all:fresh" => :environment do
|
24
|
+
return unless Rails.env.development? or Rails.env.test?
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
return unless Rails.env.development? or Rails.env.test?
|
26
|
+
Rails.application.eager_load!
|
27
|
+
include ElasticsearchAdminHelper
|
24
28
|
|
25
|
-
|
26
|
-
|
29
|
+
# If we don't create the temporary indices, then mass emails (for example) will try
|
30
|
+
# to query users for recipient count and fail
|
31
|
+
ActiveRecord::Base.descendants.each do |model_class|
|
32
|
+
next unless model_class.respond_to? :__elasticsearch__
|
33
|
+
delete_index(model_class.index_name)
|
34
|
+
create_temporary_index(model_class)
|
35
|
+
end
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
delete_index(model_class.index_name)
|
33
|
-
create_temporary_index(model_class)
|
34
|
-
end
|
37
|
+
ActiveRecord::Base.descendants.each do |model_class|
|
38
|
+
next unless model_class.respond_to? :__elasticsearch__
|
39
|
+
reindex_model(model_class, true)
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
next unless model_class.respond_to? :__elasticsearch__
|
38
|
-
reindex_model(model_class, true)
|
42
|
+
puts 'All indices created, aliased and ready'
|
39
43
|
end
|
40
44
|
|
41
|
-
|
42
|
-
|
45
|
+
desc 'Deletes indices and then reindexes all ActiveRecord model indices assuming none exist yet. Is used for testing where aliases are not used'
|
46
|
+
task "tests:prepare" => :environment do
|
47
|
+
return unless Rails.env.development? or Rails.env.test?
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
return unless Rails.env.development? or Rails.env.test?
|
49
|
+
Rails.application.eager_load!
|
50
|
+
include ElasticsearchAdminHelper
|
47
51
|
|
48
|
-
|
49
|
-
|
52
|
+
# If we don't create the temporary indices, then mass emails (for example) will try
|
53
|
+
# to query users for recipient count and fail
|
54
|
+
ActiveRecord::Base.descendants.each do |model_class|
|
55
|
+
next unless model_class.respond_to? :__elasticsearch__
|
56
|
+
delete_index(model_class.index_name)
|
57
|
+
create_temporary_index(model_class)
|
58
|
+
end
|
50
59
|
|
51
|
-
|
52
|
-
# to query users for recipient count and fail
|
53
|
-
ActiveRecord::Base.descendants.each do |model_class|
|
54
|
-
next unless model_class.respond_to? :__elasticsearch__
|
55
|
-
delete_index(model_class.index_name)
|
56
|
-
create_temporary_index(model_class)
|
60
|
+
puts 'All indices created, aliased and ready'
|
57
61
|
end
|
58
62
|
|
59
|
-
|
60
|
-
|
63
|
+
Dir.foreach("#{Rails.root}/app/models") do |item|
|
64
|
+
next if item == '.' or item == '..' or not item
|
65
|
+
name = item.split(".")[0].pluralize
|
61
66
|
|
62
|
-
|
63
|
-
|
64
|
-
|
67
|
+
desc "Reindexes #{name} using aliases"
|
68
|
+
task "reindex:#{name}" => :environment do
|
69
|
+
Rails.application.eager_load!
|
70
|
+
include ElasticsearchAdminHelper
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
include ElasticsearchAdminHelper
|
72
|
+
klass = Kernel.const_get(name.classify)
|
73
|
+
reindex_model(klass)
|
74
|
+
end
|
70
75
|
|
71
|
-
|
72
|
-
|
73
|
-
|
76
|
+
desc "Reindexes #{name} using aliases, and deletes the old one first" # because Tire tries to create an index for us sometimes
|
77
|
+
task "reindex:#{name}:delete_old_first" => :environment do
|
78
|
+
Rails.application.eager_load!
|
79
|
+
include ElasticsearchAdminHelper
|
74
80
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
include ElasticsearchAdminHelper
|
81
|
+
klass = Kernel.const_get(name.classify)
|
82
|
+
reindex_model(klass, true)
|
83
|
+
end
|
79
84
|
|
80
|
-
klass = Kernel.const_get(name.classify)
|
81
|
-
reindex_model(klass, true)
|
82
85
|
end
|
83
|
-
|
84
86
|
end
|
85
87
|
end
|
data/lib/tasks/invalids.rake
CHANGED
@@ -1,34 +1,36 @@
|
|
1
1
|
# Simple helpers to find invalid records and print why they are invalid. May
|
2
2
|
# take a while to run depending on size of data
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
if defined?(Rails)
|
4
|
+
namespace :invalids do
|
5
|
+
Dir.foreach("#{Rails.root}/app/models") do |item|
|
6
|
+
next if item == '.' or item == '..' or not item
|
7
|
+
name = item.split(".")[0].pluralize
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
desc "Finds invalid records for #{name} scaffold"
|
10
|
+
task "find:#{name}" => :environment do
|
11
|
+
Rails.application.eager_load!
|
12
|
+
klass = Kernel.const_get(name.classify)
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
invalids = []
|
15
|
+
index = 0
|
16
|
+
klass.find_each do |obj|
|
17
|
+
index += 1
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if index % 1000 == 0
|
20
|
+
ap "invalids at index #{index}"
|
21
|
+
ap invalids
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
next if obj.valid?
|
25
|
+
invalids << { id: obj.id, errors: obj.errors }
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
ap "Invalids at end:"
|
29
|
+
ap invalids
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
# This is used for log based alerts
|
32
|
+
ap "LOG NOTIFIER: INVALID RECORDS EXIST" if invalids.count > 0
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
@@ -1,23 +1,25 @@
|
|
1
1
|
# Finds missing rspec files and generates them for you. May take a while to run, depending
|
2
2
|
# on the number of scaffolds in the project.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
if defined?(Rails)
|
4
|
+
namespace :rspec_generator do
|
5
|
+
desc 'Generate rspec specs for all scaffolds that are missing specs'
|
6
|
+
task :generate => :environment do
|
7
|
+
Rails.application.eager_load!
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# Iterate over all 'normal' active record classes. By normal
|
10
|
+
# I mean that rails includes habtm join tables in the list
|
11
|
+
# which we don't want.
|
12
|
+
ActiveRecord::Base.descendants.each do |model_class|
|
13
|
+
next if model_class.name.starts_with?("HABTM_")
|
14
|
+
generate_for_model(model_class)
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def generate_for_model(model_class)
|
19
|
+
underscore_name = model_class.name.underscore
|
20
|
+
puts "Generating missing specs for #{underscore_name}"
|
21
|
+
system("rails g rspec:scaffold #{underscore_name} -s --view-specs=false --controller-specs=false --request-specs=true")
|
22
|
+
system("rails g rspec:model #{underscore_name} -s")
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handshake_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Ringwelski
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- bin/setup
|
71
71
|
- handshake_service.gemspec
|
72
72
|
- lib/handshake_service.rb
|
73
|
-
- lib/handshake_service/railtie.rb
|
74
73
|
- lib/handshake_service/version.rb
|
75
74
|
- lib/tasks/auto_annotate_models.rake
|
76
75
|
- lib/tasks/deploy.rake
|