Class: VlineProviderGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- VlineProviderGenerator
- Defined in:
- lib/generators/vline_provider/vline_provider_generator.rb
Instance Method Summary collapse
- #add_jsonp_support ⇒ Object
- #add_routes ⇒ Object
- #check_class_collisions ⇒ Object
- #copy_controller_file ⇒ Object
- #copy_initializer_file ⇒ Object
- #output ⇒ Object
Instance Method Details
#add_jsonp_support ⇒ Object
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_routes ⇒ Object
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_collisions ⇒ Object
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_file ⇒ Object
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_file ⇒ Object
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 |
#output ⇒ Object
44 45 46 47 48 |
# File 'lib/generators/vline_provider/vline_provider_generator.rb', line 44 def output say_status "Service ID", "#{[:service_id]}", :blue say_status "Client ID", "#{[:client_id]}", :blue say_status "Client Secret", "#{[:client_secret]}", :blue end |