Class: SpreeExactor::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/spree_exactor/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#installObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/spree_exactor/install/install_generator.rb', line 10

def install
  supported_versions '1.1.1.112920126'=>['1.1.1','1.1.2','1.1.3']
  supported_versions '1.1.2.20130723'=>['2.0.*']
  supported_versions '1.1.3.20130726'=>['2.0.*']
  supported_versions '1.1.4.20130729'=>['2.0.*']
  unless @supported_versions.include? _plugin_version
    puts "Unknown plug-in version. Try any of those: "+ @supported_versions.keys.to_s
    exit(0)
  end
  spree_versions = @supported_versions.values_at(_plugin_version)[0]
  answer=ask("ATTENTION! This plug-in supports only these versions of Spree: "+spree_versions.to_s+" Is your version of Spree listed there? [Y/n] \n")
  if (answer.downcase=='n')
    puts "Please contact Exactor customer technical support at [email protected] for compatibility with other versions."
    exit(0)
  end
  puts "Removing all previous Exactor dependencies (if exist)... "
  gsub_file "Gemfile", /^\s*gem\s* "spree_exactor"\s*,\s*.{5,17}$/, ""
  puts "  * Done"
  puts "Adding Exactor plugin of version "+_plugin_version+" to your gem file..."
  append_file "Gemfile", "\n", :force => true
  gem 'spree_exactor', _plugin_version
  puts "  * Done"
  puts "Executing bundle update..."
  run 'bundle update'
  puts "  * Done"

  puts "Performing resource migrations..."
  add_javascripts
  add_stylesheets
  puts "  * Done"

  puts "Performing database migrations..."
  add_migrations
  run_migrations _environment
  puts "  * Done"
end

#supported_versions(versions = {}) ⇒ Object



47
48
49
# File 'lib/generators/spree_exactor/install/install_generator.rb', line 47

def supported_versions(versions={})
  @supported_versions=versions
end