Sha256: 01768cbbbbc8d6e3a88740b579f4aa94a8c947bed003b7569d9c2309ebcac6dc

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Login
  class FacebookGenerator < Rails::Generators::NamedBase
    source_root File.expand_path('../templates', __FILE__)
    argument :name, type: :string, default: "Usuario"

    def copy_initializer_file
      @app_name = file_name
      template 'controller.rb', "app/controller/omniauth_callbacks_controller.rb", @app_name
      inject_into_file 'config/devise.rb' do
<<-RUBY
  config.omniauth :facebook, 'id', 'idfacebook', secure_image_url: true, image_size: 'large'
RUBY
      end
      inject_into_file 'app/models/usuario.rb', after: ":validatable" do
<<-RUBY
  , :omniauthable, :omniauth_providers => [:facebook]
RUBY
      end
      inject_into_file 'app/models/usuario.rb', before: "end" do
<<-RUBY
  def self.create_from_social(auth)
   usuario = Usuario.new
   usuario.link_social(auth)
   if auth.provider == 'facebook'
     usuario.facebook = auth.extra.raw_info.username
   elsif auth.provider == 'linkedin'
     usuario.linkedin = auth.info.urls.public_profile.split('/').last
   end
   usuario
  end
RUBY
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
raro_generator-0.2.1 lib/generators/login/facebook/facebook_generator.rb
raro_generator-0.1.1 lib/generators/login/facebook/facebook_generator.rb
raro_generator-0.1.0 lib/generators/login/facebook/facebook_generator.rb
raro_generator-0.0.4 lib/generators/login/facebook/facebook_generator.rb
raro_generator-0.0.3 lib/generators/login/facebook/facebook_generator.rb