iam 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,4 +1,49 @@
1
- iam
1
+ ##Iam
2
2
  ===
3
3
 
4
- Simple on-fly logger.
4
+ I'm sure you have similar workflows and user stories across your application:
5
+
6
+ 1. Login as actor 1. Add any item. Prepare it for sale: price = $1.0, type of sale = [Existing in real world], Quantity = 2.
7
+ 2. Login as actor 2. Add the item to shopping cart.
8
+ 3. Login as actor 3. Add the item to shopping cart.
9
+ 4. Login as actor 1 and change the qauntity of the item to 1.
10
+ 5. Login as actor 2. Go to Shopping Cart. Make checkout.
11
+ 6. Login as actor 3. Go to Shopping Cart. Make checkout.
12
+ 7. Login as actor 1. Check the qautity value.
13
+
14
+ But you don't want to click log out, click log in, fill in email and password, click submit again and again, do you?
15
+
16
+ ##Usage
17
+
18
+ Iam enables you to log in as another user in single click. All you need is to:
19
+
20
+ * press `
21
+ * click user you want to log in as
22
+
23
+ Also you may log in using user_id (e.g. 42):
24
+
25
+ * press `
26
+ * type 42
27
+ * press `
28
+
29
+ ##Installation
30
+
31
+ Add gem to your gemfile:
32
+
33
+ ```ruby
34
+ gem 'iam', '~> 0.1.0'
35
+ ```
36
+
37
+ Add helper to your application layout (after `jQuery`):
38
+
39
+ ```ruby
40
+ <%= include_iam %>
41
+ ```
42
+
43
+ ##License
44
+
45
+ MIT
46
+
47
+ ##Author
48
+
49
+ Yury Kaliada
@@ -1,3 +1,3 @@
1
1
  <tr href='<%= log_in_as_path(account) %>'>
2
- <%= render partial: 'iam/account_attribute', collection: account.attributes.slice(*Iam::Configuration.account_attributes).to_a %>
2
+ <%= render partial: 'iam/account_attribute', collection: Iam::Configuration.account_attributes.map { |key| [key, account.send(key)] } %>
3
3
  </tr>
@@ -1,5 +1,18 @@
1
1
  # encoding : utf-8
2
2
 
3
- Iam.configure do |config|
3
+ Iam::Configuration.configure do |config|
4
+ # Account class name
5
+ # config.account_class = 'User'
4
6
 
7
+ # Account attributes to display in the table
8
+ # account_attributes = ['id', 'full_name']
9
+
10
+ # Role class name
11
+ # role_class = 'Role'
12
+
13
+ # Role attribute to display as a group name
14
+ # role_name_attribute = 'name'
15
+
16
+ # Accounts to display for each role
17
+ # accounts_for_each_role = 3
5
18
  end
@@ -0,0 +1,19 @@
1
+ module IamHelper
2
+ def include_iam
3
+ @account_samples = account_samples
4
+ stylesheet_link_tag('iam') +
5
+ javascript_include_tag('iam') +
6
+ render('iam/menu')
7
+ end
8
+
9
+ private
10
+ def account_samples
11
+ role_class = Iam::Configuration.role_class.constantize
12
+ account_class = Iam::Configuration.account_class.constantize
13
+
14
+ role_class.all.inject({}) do |account_groups, role|
15
+ account_group = account_class.where(role_class.to_s.foreign_key => role.id).order(:id).limit(Iam::Configuration.accounts_for_each_role)
16
+ account_groups.merge role => account_group
17
+ end
18
+ end
19
+ end
data/lib/iam.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'iam/configuration'
2
2
  require 'iam/engine'
3
3
  require 'iam/version'
4
+ require 'helpers/iam_helper'
4
5
 
5
6
  ActionView::Base.send :include, IamHelper
@@ -1,6 +1,6 @@
1
1
  module Iam
2
2
  module Configuration
3
- def configure
3
+ def self.configure
4
4
  yield self
5
5
  end
6
6
 
data/lib/iam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iam
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -21,7 +21,7 @@ $ ->
21
21
  link = linkTemplate.replace(/ID/, input)
22
22
  log_in_by_link link
23
23
  else
24
- iamNotice "#{input} is invalid id."
24
+ iamNotice "#{input} is invalid id." if input
25
25
  input = ''
26
26
 
27
27
  $menu.on 'click', 'td', ->
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.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -120,7 +120,6 @@ files:
120
120
  - README.md
121
121
  - Rakefile
122
122
  - app/controllers/iam_controller.rb
123
- - app/helpers/iam_helper.rb
124
123
  - app/views/iam/_account.html.erb
125
124
  - app/views/iam/_account_attribute.html.erb
126
125
  - app/views/iam/_account_group.html.erb
@@ -129,6 +128,7 @@ files:
129
128
  - iam.gemspec
130
129
  - lib/generators/iam/initializer_generator.rb
131
130
  - lib/generators/templates/iam.rb
131
+ - lib/helpers/iam_helper.rb
132
132
  - lib/iam.rb
133
133
  - lib/iam/configuration.rb
134
134
  - lib/iam/engine.rb
@@ -1,17 +0,0 @@
1
- module IamHelper
2
- ROLE_CLASS = Iam::Configuration.role_class.constantize
3
- ACCOUNT_CLASS = Iam::Configuration.account_class.constantize
4
-
5
- def iam
6
- @account_samples = account_samples
7
- render 'iam/menu'
8
- end
9
-
10
- private
11
- def account_samples
12
- ROLE_CLASS.all.inject({}) do |account_groups, role|
13
- account_group = ACCOUNT_CLASS.where(ROLE_CLASS.to_s.foreign_key => role.id).order(:id).limit(Iam::Configuration.accounts_for_each_role)
14
- account_groups.merge role => account_group
15
- end
16
- end
17
- end