Class: PixelproSdk::AddPage
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- PixelproSdk::AddPage
- Includes:
- Thor::Actions
- Defined in:
- lib/pixelpro_sdk/add_page.rb
Overview
add or edit files to the rails project
Class Method Summary collapse
Instance Method Summary collapse
-
#add_controller_file(name) ⇒ Object
Add controller files to the rails project
config_ui for the ui page for configration
ins for install the pixel app
info for display dll
event for response pixel pro action event(optional)
. - #add_migrate_file ⇒ Object
-
#append_route(name) ⇒ Object
Append route to the config/routes file.
Class Method Details
.source_root ⇒ Object
8 9 10 |
# File 'lib/pixelpro_sdk/add_page.rb', line 8 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#add_controller_file(name) ⇒ Object
Add controller files to the rails project
config_ui for the ui page for configration
ins for install the pixel app
info for display dll
event for response pixel pro action event(optional)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pixelpro_sdk/add_page.rb', line 17 def add_controller_file name create_file "app/controller/#{name}_controller.rb" do "class CarRestrictionController < ApplicationController\n skip_before_action :verify_authenticity_token\n def config_ui # Add your codes here end def ins # Add your codes here end def info # Add your codes here end def event # Add your codes here end\nend\n" end end |
#add_migrate_file ⇒ Object
55 56 57 |
# File 'lib/pixelpro_sdk/add_page.rb', line 55 def add_migrate_file execute :bundle, "rails generate migration CreatePixel pixel_uid:string user_id:integer" end |
#append_route(name) ⇒ Object
Append route to the config/routes file
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pixelpro_sdk/add_page.rb', line 40 def append_route name if (::File.exist? "config/routes.rb") append_to_file "config/routes.rb" do "Rails.application.routes.draw do get 'info' => '#{name}#info' get 'event' => '#{name}#event' get 'config' => '#{name}#config_ui' post 'ins' => '#{name}#ins' end\n" end else raise "No Routes File Found" end end |