capistrano-chewy 0.2.1 → 0.2.2

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: 7b6374523d9371bd4b852392ca60ee9cd55a4af6
4
- data.tar.gz: d4823ef99f9c17c9ed9c3cc7037d4823b39914e7
3
+ metadata.gz: 62184798aa12d2608926e1b7d651656146274e1b
4
+ data.tar.gz: f0194127c6527aaf28de28272d929a16e62db2cf
5
5
  SHA512:
6
- metadata.gz: b658bbbe5b8f28656bef50eddd9850fae492d82a82520b3071240ef9d369d736e016f9242272e3c9a0f781de4d56f000e18e4b3ffc32672919b86cd149d613d7
7
- data.tar.gz: e39fda7430b47631c38f48880ad0caede6103ac825e718e48f457cece00f9fed7481c56a51d7a39b6e4ea42c4960993759ca730545ae7290f3468d52b10c6a36
6
+ metadata.gz: 5d79f930792405f66fa87d02b81c52b028939a817908f59f959d23ce49b33251d5a459452161731534bb974fbbf81ea160688f4545bd7af1f788a3199d7ee598
7
+ data.tar.gz: cdeae3d5cb65947f0f073d72ebdf285d97d4fc6f00553e922475bbdd108234e1efd3788d448a396e09d456079ee7bcdd61f46ef2c115b7d9e5d65c1b3259aa67
@@ -10,3 +10,5 @@ Documentation:
10
10
  Enabled: false
11
11
  Style/EndOfLine:
12
12
  Enabled: false
13
+ Metrics/MethodLength:
14
+ Max: 12
@@ -4,7 +4,8 @@ bundler_args: --without yard guard benchmarks
4
4
  script: "rake spec"
5
5
  rvm:
6
6
  - 2.2.4
7
- - 2.3.1
7
+ - 2.3.3
8
+ - 2.4.0
8
9
  - ruby-head
9
10
  matrix:
10
11
  allow_failures:
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Capistrano::Chewy
2
2
  [![Gem Version](https://badge.fury.io/rb/capistrano-chewy.svg)](http://badge.fury.io/rb/capistrano-chewy)
3
3
  [![Build Status](https://travis-ci.org/nbulaj/capistrano-chewy.svg?branch=master)](https://travis-ci.org/nbulaj/capistrano-chewy)
4
+ [![Dependency Status](https://gemnasium.com/nbulaj/capistrano-chewy.svg)](https://gemnasium.com/nbulaj/capistrano-chewy)
5
+ [![Code Climate](https://codeclimate.com/github/nbulaj/capistrano-chewy/badges/gpa.svg)](https://codeclimate.com/github/nbulaj/capistrano-chewy)
4
6
 
5
7
  Manage and continuously rebuild your ElasticSearch indexes with [Chewy](https://github.com/toptal/chewy/) and [Capistrano](https://github.com/capistrano/capistrano) v3.
6
8
 
@@ -60,7 +62,7 @@ require 'capistrano/chewy'
60
62
  then you can use `cap -T` to list `Capistrano::Chewy` tasks:
61
63
 
62
64
  ```ruby
63
- cap chewy:rebuild # Reset only modified Chewy indexes
65
+ cap chewy:rebuild # Reset modified and delete removed Chewy indexes
64
66
  cap chewy:reset # Destroy, recreate and import data to all the indexes
65
67
  cap chewy:reset[indexes] # Destroy, recreate and import data to the specified indexes
66
68
  cap chewy:update # Updates data to all the indexes
@@ -72,21 +74,25 @@ If you want to change it, then you need to disable default gem hooks by setting
72
74
 
73
75
  ## Configuration
74
76
 
75
- You can setup the following:
77
+ You can setup the following options:
76
78
 
77
79
  ```ruby
78
80
  # deploy.rb
79
- set :chewy_conditionally_reset, false # Reset only modified Chewy indexes, true by default
80
- set :chewy_path, 'app/my_indexes' # Path to Chewy indexes, 'app/chewy' by default
81
- set :chewy_env, :chewy_production # Environment variable for Chewy, equal to RAILS_ENV by default
82
- set :chewy_role, :web # Chewy role, :app by default
83
- set :chewy_default_hooks, false # Add default capistrano-chewy hooks to your deploy flow, true by default
84
- set :chewy_delete_removed_indexes, false # Delete indexes which files have been deleted, true by default
81
+ set :chewy_conditionally_reset, false # Reset only modified Chewy indexes, true by default
82
+ set :chewy_path, 'app/my_indexes' # Path to Chewy indexes, 'app/chewy' by default
83
+ set :chewy_env, :chewy_production # Environment variable for Chewy, equal to RAILS_ENV by default
84
+ set :chewy_role, :web # Chewy role, :app by default
85
+ set :chewy_default_hooks, false # Add default gem hooks to project deploy flow, true by default
86
+ set :chewy_delete_removed_indexes, false # Delete indexes which files have been deleted, true by default
85
87
  ```
86
88
 
87
89
  ## Contributing
88
90
 
89
- 1. Fork it ( http://github.com/nbulaj/capistrano-chewy/fork )
91
+ You are very welcome to help improve `Capistrano:Chewy` if you have suggestions for features that other people can use or some code improvements.
92
+
93
+ To contribute:
94
+
95
+ 1. Fork the project( http://github.com/nbulaj/capistrano-chewy/fork )
90
96
  2. Create your feature branch (`git checkout -b my-new-feature`)
91
97
  3. Commit your changes (`git commit -am 'Add some feature'`)
92
98
  4. Push to the branch (`git push origin my-new-feature`)
@@ -6,7 +6,7 @@ module CapistranoChewy
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 2
9
- TINY = 1
9
+ TINY = 2
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
12
12
  end
@@ -40,46 +40,36 @@ namespace :chewy do
40
40
  end
41
41
  end
42
42
 
43
- # Adds default Capistrano::Chewy hooks to the deploy flow
44
- task :add_default_hooks do
45
- after :'deploy:updated', 'chewy:rebuild'
46
- after :'deploy:reverted', 'chewy:rebuild'
47
- end
48
-
49
- # Default Chewy rake tasks
50
- desc 'Destroy, recreate and import data to all or specified (pass with [one,two]) indexes'
51
- task :reset do |_task, args|
52
- indexes = args.extras
53
-
43
+ def run_default_chewy_task(task_name, indexes)
54
44
  on roles fetch(:chewy_role) do
55
45
  within release_path do
56
46
  with rails_env: fetch(:chewy_env) do
57
47
  if indexes.any?
58
- execute :rake, "chewy:reset[#{indexes.join(',')}]"
48
+ execute :rake, "chewy:#{task_name}[#{indexes.join(',')}]"
59
49
  else
60
50
  # Simply chewy:reset / chewy:update for Chewy > 0.8.4
61
- execute :rake, 'chewy:reset:all'
51
+ execute :rake, "chewy:#{task_name}"
62
52
  end
63
53
  end
64
54
  end
65
55
  end
66
56
  end
67
57
 
58
+ # Adds default Capistrano::Chewy hooks to the deploy flow
59
+ task :add_default_hooks do
60
+ after :'deploy:updated', 'chewy:rebuild'
61
+ after :'deploy:reverted', 'chewy:rebuild'
62
+ end
63
+
64
+ # Default Chewy rake tasks
65
+ desc 'Destroy, recreate and import data to all or specified (pass with [one,two]) indexes'
66
+ task :reset do |_task, args|
67
+ run_default_chewy_task(:reset, args.extras)
68
+ end
69
+
68
70
  desc 'Updates data to all or specified (passed with [one,two]) indexes'
69
71
  task :update do |_task, args|
70
- indexes = args.extras
71
-
72
- on roles fetch(:chewy_role) do
73
- within release_path do
74
- with rails_env: fetch(:chewy_env) do
75
- if indexes.any?
76
- execute :rake, "chewy:update[#{indexes.join(',')}]"
77
- else
78
- execute :rake, 'chewy:update:all'
79
- end
80
- end
81
- end
82
- end
72
+ run_default_chewy_task(:update, args.extras)
83
73
  end
84
74
 
85
75
  # Smart rebuild of modified Chewy indexes
@@ -103,8 +93,8 @@ namespace :chewy do
103
93
  exit 1
104
94
  end
105
95
  else
106
- info 'Running chewy:reset:all'
107
- invoke :'chewy:reset:all'
96
+ info 'Running chewy:reset'
97
+ invoke :'chewy:reset'
108
98
  end
109
99
  end
110
100
  end
@@ -135,9 +125,7 @@ namespace :chewy do
135
125
  indexes_to_delete = changes.removed
136
126
 
137
127
  # Reset indexes which have been modified or added
138
- if indexes_to_reset.any?
139
- reset_modified_indexes(indexes_to_reset)
140
- end
128
+ reset_modified_indexes(indexes_to_reset) if indexes_to_reset.any?
141
129
 
142
130
  # Delete indexes which have been removed
143
131
  if indexes_to_delete.any? && fetch(:chewy_delete_removed_indexes)
@@ -1,24 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CapistranoChewy::DiffParser do
4
- let(:current_path) { '/project/1/app/chewy' }
5
- let(:release_path) { '/project/2/app/chewy' }
6
-
7
- # TODO: make a real diff
8
- let(:full_diff) do
9
- "Files #{current_path}/accounts_index.rb and #{release_path}/accounts_index.rb differ\n" \
10
- "Files #{current_path}/posts_index.rb and #{release_path}/posts_index.rb differ\n" \
11
- "Only in #{release_path}: applications_index.rb\n" \
12
- "Files #{current_path}/comments_index.rb and #{release_path}/comments_index.rb differ\n" \
13
- "Only in #{current_path}: users_index.rb\n"
14
- end
4
+ let(:current_path) { File.expand_path('../stub/chewy_current', __FILE__) }
5
+ let(:release_path) { File.expand_path('../stub/chewy_release', __FILE__) }
6
+
7
+ let(:full_diff) { `diff -qZEB #{current_path} #{release_path}` }
15
8
 
16
9
  describe '#parse' do
17
10
  context 'with difference between directories' do
18
11
  it 'returns result object with removed, added and changed files' do
19
12
  result = described_class.parse(full_diff, current_path, release_path)
20
13
 
21
- expect(result.changed).to eq(["#{release_path}/accounts_index.rb", "#{release_path}/posts_index.rb", "#{release_path}/comments_index.rb"])
14
+ expect(result.changed).to match_array(["#{release_path}/accounts_index.rb", "#{release_path}/posts_index.rb", "#{release_path}/comments_index.rb"])
22
15
  expect(result.added).to eq(["#{release_path}/applications_index.rb"])
23
16
  expect(result.removed).to eq(["#{current_path}/users_index.rb"])
24
17
 
@@ -0,0 +1,2 @@
1
+ class AccountsIndex < Chewy::Index
2
+ end
@@ -0,0 +1,2 @@
1
+ class CommentsIndex < Chewy::Index
2
+ end
@@ -0,0 +1,2 @@
1
+ class PostsIndex < Chewy::Index
2
+ end
@@ -0,0 +1,2 @@
1
+ class UsersIndex < Chewy::Index
2
+ end
@@ -0,0 +1,3 @@
1
+ class AccountsIndex < Chewy::Index
2
+ field :id
3
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationsIndex < Chewy::Index
2
+ end
@@ -0,0 +1,3 @@
1
+ class CommentsIndex < Chewy::Index
2
+ field :id
3
+ end
@@ -0,0 +1,3 @@
1
+ class PostsIndex < Chewy::Index
2
+ field :id
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-chewy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Bulai
@@ -76,6 +76,14 @@ files:
76
76
  - lib/capistrano/tasks/chewy.rake
77
77
  - spec/diff_parser_spec.rb
78
78
  - spec/spec_helper.rb
79
+ - spec/stub/chewy_current/accounts_index.rb
80
+ - spec/stub/chewy_current/comments_index.rb
81
+ - spec/stub/chewy_current/posts_index.rb
82
+ - spec/stub/chewy_current/users_index.rb
83
+ - spec/stub/chewy_release/accounts_index.rb
84
+ - spec/stub/chewy_release/applications_index.rb
85
+ - spec/stub/chewy_release/comments_index.rb
86
+ - spec/stub/chewy_release/posts_index.rb
79
87
  homepage: https://github.com/nbulaj/capistrano-chewy
80
88
  licenses:
81
89
  - MIT
@@ -104,4 +112,11 @@ summary: Manage and continuously rebuild your ElasticSearch indexes with Chewy a
104
112
  test_files:
105
113
  - spec/diff_parser_spec.rb
106
114
  - spec/spec_helper.rb
107
- has_rdoc:
115
+ - spec/stub/chewy_current/accounts_index.rb
116
+ - spec/stub/chewy_current/comments_index.rb
117
+ - spec/stub/chewy_current/posts_index.rb
118
+ - spec/stub/chewy_current/users_index.rb
119
+ - spec/stub/chewy_release/accounts_index.rb
120
+ - spec/stub/chewy_release/applications_index.rb
121
+ - spec/stub/chewy_release/comments_index.rb
122
+ - spec/stub/chewy_release/posts_index.rb