Class: RailsBase::Features::Facebook

Inherits:
Object
  • Object
show all
Extended by:
CliActions, RailsBase::FileManipulation
Defined in:
lib/rs-rails-base/features/facebook.rb

Class Method Summary collapse

Methods included from RailsBase::FileManipulation

append_to_file, create_file, inject_into_file, install_gem, read_all_content, replace_in_file

Methods included from CliActions

ask_for_something, say_something

Class Method Details

.inject_files(templates_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rs-rails-base/features/facebook.rb', line 20

def self.inject_files(templates_path)
  inject_into_file('config/routes.rb', 'resource :user, only: :update do',
                   "#{templates_path}routes.rb")
  inject_into_file('app/controllers/api/v1/sessions_controller.rb',
                   "include Api::Concerns::ActAsApiRequest\n",
                   "#{templates_path}sessions_controller.rb", true)
  inject_into_file('app/controllers/api/v1/sessions_controller.rb',
                   "private\n",
                   "#{templates_path}sessions_controller_2.rb")
  inject_into_file('spec/factories/user.rb',
                   "number(10) }\n  end",
                   "#{templates_path}factories_user.rb")
  inject_into_file('spec/models/user_spec.rb',
                   "it { should validate_uniqueness_of(:uid).scoped_to(:provider) }\n",
                   "#{templates_path}user_spec.rb")
  inject_into_file('spec/routing/sessions_routing_spec.rb',
                   "sessions#create'\)\n    end",
                   "#{templates_path}sessions_routing_spec.rb")
end

.installObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rs-rails-base/features/facebook.rb', line 8

def self.install
  templates_path = '../templates/facebook/'
  inject_files(templates_path)
  install_gem('koala', '3.0.0')
  create_file('spec/requests/api/v1/sessions/facebook_spec.rb',
              "#{templates_path}facebook_spec.rb")
  create_file('app/services/facebook_service.rb',
              "#{templates_path}facebook_service.rb")
  append_to_file('apiary.apib', "#{templates_path}apiary.apib")
  append_to_file('config/locales/en.yml', "#{templates_path}en.yml")
end