iam 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- gem 'rails', '~> 3.2.6'
6
- gem 'jquery-rails'
7
- gem 'sass'
8
- gem 'devise'
9
-
10
- platforms :ruby do
11
- gem 'sqlite3'
12
- end
data/README.md CHANGED
@@ -31,7 +31,7 @@ Also you may log in using user_id (e.g. 42):
31
31
  Add gem to your gemfile:
32
32
 
33
33
  ```ruby
34
- gem 'iam', '~> 0.1.0'
34
+ gem 'iam', '~> 0.1.1'
35
35
  ```
36
36
 
37
37
  Add helper to your application layout (after `jQuery`):
@@ -3,7 +3,7 @@ class IamController < ApplicationController
3
3
  account = Iam::Configuration.account_class.constantize.find(params[:id])
4
4
  sign_in Iam::Configuration.account_class.downcase, account
5
5
 
6
- account_attributes = account.attributes.slice(*Iam::Configuration.account_attributes).values.join(' ')
7
- render json: { notice: "Successfully logged in as:\n#{account_attributes}" }
6
+ name = Iam::Configuration.account_attributes.map{ |key| account.public_send(key)}.join(' ')
7
+ render json: { notice: I18n.t('iam.success', name: name) }
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  <tr href='<%= log_in_as_path(account) %>'>
2
- <%= render partial: 'iam/account_attribute', collection: Iam::Configuration.account_attributes.map { |key| [key, account.send(key)] } %>
2
+ <%= render partial: 'iam/account_attribute', collection: Iam::Configuration.account_attributes.map { |key| [key, account.public_send(key)] } %>
3
3
  </tr>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <tr>
4
4
  <td class='role-name' colspan=<%= Iam::Configuration.account_attributes.count %>>
5
- <%= role.send Iam::Configuration.role_name_attribute %>
5
+ <%= role.public_send Iam::Configuration.role_name_attribute %>
6
6
  </td>
7
7
  </tr>
8
8
  <%= render partial: 'iam/account', collection: accounts %>
@@ -0,0 +1,3 @@
1
+ en:
2
+ iam:
3
+ success: "Successfully logged in as %{name}"
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- match '/iam_you/:id', controller: :iam, action: :log_in_as, as: :log_in_as
2
+ post '/iam_you/:id', controller: :iam, action: :log_in_as, as: :log_in_as
3
3
  end
@@ -5,7 +5,6 @@ module Iam
5
5
  source_root File.expand_path("../../templates", __FILE__)
6
6
 
7
7
  desc 'Creates a sample Iam initializer.'
8
-
9
8
  def copy_initializer
10
9
  copy_file 'iam.rb', 'config/initializers/iam.rb'
11
10
  end
@@ -1,5 +1,7 @@
1
1
  module IamHelper
2
2
  def include_iam
3
+ return if Rails.env == 'production'
4
+
3
5
  @account_samples = account_samples
4
6
  stylesheet_link_tag('iam') +
5
7
  javascript_include_tag('iam') +
data/lib/iam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iam
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -12,8 +12,8 @@ $ ->
12
12
  log_in_by_link = (link) ->
13
13
  $.post link, (data) ->
14
14
  $menu.hide()
15
- iamNotice data.notice
16
15
  window.location.reload()
16
+ iamNotice data.notice
17
17
 
18
18
  log_in_by_input = ->
19
19
  if inputMode
@@ -33,7 +33,9 @@ $ ->
33
33
  input = ''
34
34
 
35
35
  $(document).on 'keypress', (e) ->
36
- if e.keyCode == 96 || e.keyCode == 1105 # '`' || 'ё'
36
+ $selectedInput = $(document.getSelection().focusNode).find('input')
37
+
38
+ if $selectedInput.length == 0 && (e.keyCode == 96 || e.keyCode == 1105) # '`' || 'ё'
37
39
  log_in_by_input()
38
40
 
39
41
  inputMode = !inputMode
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -124,6 +124,7 @@ files:
124
124
  - app/views/iam/_account_attribute.html.erb
125
125
  - app/views/iam/_account_group.html.erb
126
126
  - app/views/iam/_menu.html.erb
127
+ - config/locales/iam.en.yml
127
128
  - config/routes.rb
128
129
  - iam.gemspec
129
130
  - lib/generators/iam/initializer_generator.rb
@@ -205,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
206
  version: '0'
206
207
  requirements: []
207
208
  rubyforge_project: iam
208
- rubygems_version: 1.8.23
209
+ rubygems_version: 1.8.24
209
210
  signing_key:
210
211
  specification_version: 3
211
212
  summary: Simple account switcher for Rails.