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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12a7aa9eb42f6207d92c504cbef6fb9f9ea0d73f
4
- data.tar.gz: a12e2697373921c30fac12a1a67150123992cc02
3
+ metadata.gz: 5922673b0c8bc5de4fd74e232495f95657f9be66
4
+ data.tar.gz: d819fd2f8f632a5e870d9bf11610a514788fd815
5
5
  SHA512:
6
- metadata.gz: ebdae6b2a8ceef4f3092d6c5dd02ed6531071d0b475a528a3baa5fac1f556e9963d2702433652b6b0201478b07c147049d670a9e32e125f95e7bfaae95ca269d
7
- data.tar.gz: 98cf86a3a26eb539337946e2fe33f49fbae6b594a522019e1aae15a6c932bcbe8f42cd915a3e352d9414f6a8b17e535ccafb61e21feac0888a446e22aa8d703a
6
+ metadata.gz: 9bee3cee2f06f22b0c7d5bd029f893a6a801214882221810cdca1968e168ecce82bbc0e5522a5ea3686765f4a09c43aba56e670339f953621054ce7d2e5b25ff
7
+ data.tar.gz: 9929ef8325393dc2c1ce8906ba1a8ee8fb6d93a5d71e4f3530c54876a184cbebcd935e2a7a8440cc9f0d28dae273fdc9c3215299fd12a776574fcc9fd18f398a
data/Rakefile CHANGED
@@ -3,4 +3,7 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
+ # Add all of the rake tasks in lib/tasks/*.rake
7
+ Dir.glob('lib/tasks/*.rake').each {|r| import r}
8
+
6
9
  task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module HandshakeService
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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.
@@ -1,5 +1,3 @@
1
- require 'librato/metrics'
2
-
3
1
  # A collection of rake tasks to deploy applications to heroku. At the basic level, all that needs to be called
4
2
  # in most cases is
5
3
  #
@@ -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
- namespace :elasticsearch do
8
- desc 'Reindexes all ActiveRecord model indices'
9
- task "reindex:all" => :environment do
10
- Rails.application.eager_load!
11
- include ElasticsearchAdminHelper
12
-
13
- ActiveRecord::Base.descendants.each do |model_class|
14
- next unless model_class.respond_to? :__elasticsearch__
15
- reindex_model(model_class)
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
- puts 'All indices reindexed'
19
- end
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
- desc 'Deletes indices and then reindexes all ActiveRecord model indices assuming none exist yet'
22
- task "reindex:all:fresh" => :environment do
23
- return unless Rails.env.development? or Rails.env.test?
26
+ Rails.application.eager_load!
27
+ include ElasticsearchAdminHelper
24
28
 
25
- Rails.application.eager_load!
26
- include ElasticsearchAdminHelper
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
- # If we don't create the temporary indices, then mass emails (for example) will try
29
- # to query users for recipient count and fail
30
- ActiveRecord::Base.descendants.each do |model_class|
31
- next unless model_class.respond_to? :__elasticsearch__
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
- ActiveRecord::Base.descendants.each do |model_class|
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
- puts 'All indices created, aliased and ready'
42
- end
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
- desc 'Deletes indices and then reindexes all ActiveRecord model indices assuming none exist yet. Is used for testing where aliases are not used'
45
- task "tests:prepare" => :environment do
46
- return unless Rails.env.development? or Rails.env.test?
49
+ Rails.application.eager_load!
50
+ include ElasticsearchAdminHelper
47
51
 
48
- Rails.application.eager_load!
49
- include ElasticsearchAdminHelper
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
- # If we don't create the temporary indices, then mass emails (for example) will try
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
- puts 'All indices created, aliased and ready'
60
- end
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
- Dir.foreach("#{Rails.root}/app/models") do |item|
63
- next if item == '.' or item == '..' or not item
64
- name = item.split(".")[0].pluralize
67
+ desc "Reindexes #{name} using aliases"
68
+ task "reindex:#{name}" => :environment do
69
+ Rails.application.eager_load!
70
+ include ElasticsearchAdminHelper
65
71
 
66
- desc "Reindexes #{name} using aliases"
67
- task "reindex:#{name}" => :environment do
68
- Rails.application.eager_load!
69
- include ElasticsearchAdminHelper
72
+ klass = Kernel.const_get(name.classify)
73
+ reindex_model(klass)
74
+ end
70
75
 
71
- klass = Kernel.const_get(name.classify)
72
- reindex_model(klass)
73
- end
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
- desc "Reindexes #{name} using aliases, and deletes the old one first" # because Tire tries to create an index for us sometimes
76
- task "reindex:#{name}:delete_old_first" => :environment do
77
- Rails.application.eager_load!
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
@@ -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
- namespace :invalids do
4
- Dir.foreach("#{Rails.root}/app/models") do |item|
5
- next if item == '.' or item == '..' or not item
6
- name = item.split(".")[0].pluralize
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
- desc "Finds invalid records for #{name} scaffold"
9
- task "find:#{name}" => :environment do
10
- Rails.application.eager_load!
11
- klass = Kernel.const_get(name.classify)
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
- invalids = []
14
- index = 0
15
- klass.find_each do |obj|
16
- index += 1
14
+ invalids = []
15
+ index = 0
16
+ klass.find_each do |obj|
17
+ index += 1
17
18
 
18
- if index % 1000 == 0
19
- ap "invalids at index #{index}"
20
- ap invalids
21
- end
19
+ if index % 1000 == 0
20
+ ap "invalids at index #{index}"
21
+ ap invalids
22
+ end
22
23
 
23
- next if obj.valid?
24
- invalids << { id: obj.id, errors: obj.errors }
25
- end
24
+ next if obj.valid?
25
+ invalids << { id: obj.id, errors: obj.errors }
26
+ end
26
27
 
27
- ap "Invalids at end:"
28
- ap invalids
28
+ ap "Invalids at end:"
29
+ ap invalids
29
30
 
30
- # This is used for log based alerts
31
- ap "LOG NOTIFIER: INVALID RECORDS EXIST" if invalids.count > 0
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
- namespace :rspec_generator do
4
- desc 'Generate rspec specs for all scaffolds that are missing specs'
5
- task :generate => :environment do
6
- Rails.application.eager_load!
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
- # Iterate over all 'normal' active record classes. By normal
9
- # I mean that rails includes habtm join tables in the list
10
- # which we don't want.
11
- ActiveRecord::Base.descendants.each do |model_class|
12
- next if model_class.name.starts_with?("HABTM_")
13
- generate_for_model(model_class)
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
- def generate_for_model(model_class)
18
- underscore_name = model_class.name.underscore
19
- puts "Generating missing specs for #{underscore_name}"
20
- system("rails g rspec:scaffold #{underscore_name} -s --view-specs=false --controller-specs=false --request-specs=true")
21
- system("rails g rspec:model #{underscore_name} -s")
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.5
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
@@ -1,11 +0,0 @@
1
- require 'handshake_service'
2
- require 'rails'
3
-
4
- module HandshakeService
5
-
6
- class Railtie < Rails::Railtie
7
- rake_tasks do
8
- Dir[File.expand_path("lib/tasks/*.rake", File.dirname(__FILE__))].each { |ext| load ext }
9
- end
10
- end
11
- end