Class: VlineProviderGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/vline_provider/vline_provider_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_jsonp_supportObject



37
38
39
40
41
42
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 37

def add_jsonp_support
  line = "# This file is used by Rack-based servers to start the application."
  gsub_file 'config.ru', /(#{Regexp.escape(line)})/mi do |match|
    "#{match}\nrequire 'rack/jsonp'\nuse Rack::JSONP\n"
  end
end

#add_routesObject



31
32
33
34
35
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 31

def add_routes
  route "match '_vline/launch' => 'vline#launch', :via => :get"
  route "match '_vline/api/v1/oauth/authorize' => 'vline#authorize', :via => :get"
  route "mount Vline::API => '_vline/api'"
end

#check_class_collisionsObject



19
20
21
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 19

def check_class_collisions
  class_collisions class_path, "#{class_name}Controller"
end

#copy_controller_fileObject



23
24
25
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 23

def copy_controller_file
  template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
end

#copy_initializer_fileObject



27
28
29
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 27

def copy_initializer_file
  template 'initializer.rb', "config/initializers/#{file_name}.rb"
end

#outputObject



44
45
46
47
48
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 44

def output
  say_status "Service ID", "#{options[:service_id]}", :blue
  say_status "Client ID", "#{options[:client_id]}", :blue
  say_status "Client Secret", "#{options[:client_secret]}", :blue
end