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 +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +2 -1
- data/README.md +15 -9
- data/lib/capistrano-chewy/version.rb +1 -1
- data/lib/capistrano/tasks/chewy.rake +19 -31
- data/spec/diff_parser_spec.rb +5 -12
- data/spec/stub/chewy_current/accounts_index.rb +2 -0
- data/spec/stub/chewy_current/comments_index.rb +2 -0
- data/spec/stub/chewy_current/posts_index.rb +2 -0
- data/spec/stub/chewy_current/users_index.rb +2 -0
- data/spec/stub/chewy_release/accounts_index.rb +3 -0
- data/spec/stub/chewy_release/applications_index.rb +2 -0
- data/spec/stub/chewy_release/comments_index.rb +3 -0
- data/spec/stub/chewy_release/posts_index.rb +3 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62184798aa12d2608926e1b7d651656146274e1b
|
4
|
+
data.tar.gz: f0194127c6527aaf28de28272d929a16e62db2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d79f930792405f66fa87d02b81c52b028939a817908f59f959d23ce49b33251d5a459452161731534bb974fbbf81ea160688f4545bd7af1f788a3199d7ee598
|
7
|
+
data.tar.gz: cdeae3d5cb65947f0f073d72ebdf285d97d4fc6f00553e922475bbdd108234e1efd3788d448a396e09d456079ee7bcdd61f46ef2c115b7d9e5d65c1b3259aa67
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Capistrano::Chewy
|
2
2
|
[](http://badge.fury.io/rb/capistrano-chewy)
|
3
3
|
[](https://travis-ci.org/nbulaj/capistrano-chewy)
|
4
|
+
[](https://gemnasium.com/nbulaj/capistrano-chewy)
|
5
|
+
[](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
|
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
|
80
|
-
set :chewy_path, 'app/my_indexes'
|
81
|
-
set :chewy_env, :chewy_production
|
82
|
-
set :chewy_role, :web
|
83
|
-
set :chewy_default_hooks, false
|
84
|
-
set :chewy_delete_removed_indexes, false
|
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
|
-
|
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`)
|
@@ -40,46 +40,36 @@ namespace :chewy do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
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
|
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,
|
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
|
-
|
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
|
107
|
-
invoke :'chewy:reset
|
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)
|
data/spec/diff_parser_spec.rb
CHANGED
@@ -1,24 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CapistranoChewy::DiffParser do
|
4
|
-
let(:current_path) { '/
|
5
|
-
let(:release_path) { '/
|
6
|
-
|
7
|
-
|
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
|
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
|
|
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.
|
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
|
-
|
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
|