Skip to content

Commit eab4058

Browse files
committedJan 21, 2016
[RAILS] Added checks for proper launch order to the example application templates
In order to prevent confusing errors when users try to run templates not sequentially, added checks which ensure the templates are run properly one after another.
1 parent 77ce500 commit eab4058

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
 

‎elasticsearch-rails/lib/rails/templates/02-pretty.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/02-pretty.rb
22

3-
# (See: 01-basic.rb)
3+
unless File.read('README.rdoc').include? '== [1] Basic'
4+
say_status "ERROR", "You have to run the 01-basic.rb template first.", :red
5+
exit(1)
6+
end
47

58
puts
69
say_status "README", "Updating Readme...\n", :yellow

‎elasticsearch-rails/lib/rails/templates/03-expert.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# $ rails new searchapp --skip --skip-bundle --template https://raw.github.com/elasticsearch/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/03-expert.rb
22

3-
# (See: 01-basic.rb, 02-pretty.rb)
3+
unless File.read('README.rdoc').include? '== [2] Pretty'
4+
say_status "ERROR", "You have to run the 01-basic.rb and 02-pretty.rb templates first.", :red
5+
exit(1)
6+
end
47

58
append_to_file 'README.rdoc', <<-README
69

‎elasticsearch-rails/lib/rails/templates/04-dsl.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# $ rails new searchapp --skip --skip-bundle --template https://raw.githubusercontent.com/elastic/elasticsearch-rails/master/elasticsearch-rails/lib/rails/templates/04-dsl.rb
22

3-
# (See: 01-basic.rb, 02-pretty.rb, 03-expert.rb)
3+
unless File.read('README.rdoc').include? '== [3] Expert'
4+
say_status "ERROR", "You have to run the 01-basic.rb, 02-pretty.rb and 03-expert.rb templates first.", :red
5+
exit(1)
6+
end
47

58
append_to_file 'README.rdoc', <<-README
69

0 commit comments

Comments
 (0)