userswitch 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db3320dc349520ba8a86294452d9681bc0990121
4
- data.tar.gz: d5b631eb58193e63980adb18bbe9fe2416207e17
3
+ metadata.gz: bec449f560253bfeb5acbda00ba6fb3ba351cf85
4
+ data.tar.gz: 939242e09521784854f835a858ee0ff2fe222527
5
5
  SHA512:
6
- metadata.gz: cc756ac69641c9daac98381c900d7f3d7e297436574bc612eeb338b0d62d80843d8c896f7bae5ed18ea15d6607d12ff22ba8e671e1be8de39b4b203728b619b4
7
- data.tar.gz: 652eb6318c56e25c2a22a93be469f5ce8a607bbe3e781cf9263bb6a6158a784f9df61ec4e561d68460ff56442f3793cd7987ad4052119ceca8787e939e801a44
6
+ metadata.gz: c5f77f9d9df73af080706911c6afd87dac67adf0a5132787d36cdc3b473c386ba4b119922d05f6a49a0abef84ae13207829ff14a86a455f72694fdb931638360
7
+ data.tar.gz: fe50c37355e92f6170edbfe8a646a42fa51f91a84324c19352ca2ff5ca8c79fa1dfa801a4566ccc13fdd6ad748371d354207c3d063a6cfdf4f94742a897daa8a
data/README.md CHANGED
@@ -1,41 +1,11 @@
1
1
  # Userswitch
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/userswitch`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Userswitch is a Rails plugin for switching between commonly used roles and users. It's particularly useful for development and staging environments when you often need to switch between various accounts. It saves you from the hassle of logging in or out.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Calling users with (Showing only users with negative id):
6
6
 
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'userswitch'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install userswitch
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/userswitch. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
-
37
-
38
- ## License
39
-
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
7
+ ``` Userswitch.users.html_safe ```
41
8
 
9
+ ![pic1](us1.png)
10
+ ![pic2](us2.png)
11
+ ![pic3](us3.png)
@@ -0,0 +1,10 @@
1
+ module Userswitch
2
+ class SwitchController < ApplicationController
3
+ include Devise::Controllers::Helpers
4
+
5
+ def switch_user
6
+ sign_in(User.find(params[:id]))
7
+ redirect_to :back
8
+ end
9
+ end
10
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get '/change-user/:id' => 'userswitch/switch#switch_user'
3
+ end
@@ -0,0 +1,3 @@
1
+ module Userswitch
2
+ class Engine < Rails::Engine; end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module Userswitch
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/userswitch.rb CHANGED
@@ -1,5 +1,26 @@
1
- require "userswitch/version"
1
+ require 'userswitch/version'
2
+ require 'userswitch/engine'
2
3
 
3
4
  module Userswitch
4
- # Your code goes here...
5
+ def initialize_switch_users
6
+ # AdminUser.where('id < 0')
7
+ # TODO ovo ce ucitat iz file-a ili seedova sere, Adminusere itd.
8
+ # nece bit where
9
+ User.where('id < 0')
10
+ end
11
+
12
+ def create_button_from_user
13
+ ceo_html = ''
14
+ initialize_switch_users.each do |user|
15
+ # pogleda koja je rola, ovisno o roli dodjelimo clase iz html-a css-a
16
+ ceo_html += "<a href=\"/change-user/#{user.id}\" class=\"btn #{user.id} btn-outline btn-info btn-sm\">#{user.email}</a> \n"
17
+ end
18
+ ceo_html.html_safe
19
+ end
20
+
21
+ def users
22
+ create_button_from_user
23
+ end
24
+
25
+ module_function :users, :create_button_from_user, :initialize_switch_users
5
26
  end
data/us1.png ADDED
Binary file
data/us2.png ADDED
Binary file
data/us3.png ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: userswitch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - matija
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,10 +67,16 @@ files:
67
67
  - LICENSE.txt
68
68
  - README.md
69
69
  - Rakefile
70
+ - app/controllers/userswitch/switch_controller.rb
70
71
  - bin/console
71
72
  - bin/setup
73
+ - config/routes.rb
72
74
  - lib/userswitch.rb
75
+ - lib/userswitch/engine.rb
73
76
  - lib/userswitch/version.rb
77
+ - us1.png
78
+ - us2.png
79
+ - us3.png
74
80
  - userswitch.gemspec
75
81
  homepage: https://github.com/kodius/userswitch
76
82
  licenses:
@@ -93,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
99
  version: '0'
94
100
  requirements: []
95
101
  rubyforge_project:
96
- rubygems_version: 2.6.11
102
+ rubygems_version: 2.4.5.2
97
103
  signing_key:
98
104
  specification_version: 4
99
105
  summary: Switch between various user roles on your Rails app.