authmotion 0.1
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.
- checksums.yaml +7 -0
 - data/README.md +132 -0
 - data/lib/authmotion.rb +8 -0
 - data/lib/project/authmotion.rb +173 -0
 - metadata +61 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA1:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fa117fa3546b2c98906faf95de73ffba330e0a28
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 56c87a17ffd4c4edee893e0563b4b2c832cbef63
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e3dd76d8675aff838c8e38191fbe977105f1e44afd174cc4fe4e331eaa67601514747362f74463044fbf834bf3652b67f05119131f5269f252975e7d132677a7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 54c86f6dec654a8c52b5d3e252effe225d941f1ab54c5831c7ddd43238143f505ef748325e2c1ff9c1cd8d8a459d0841dfbfbc2fc422b680ea99bc87c52074db
         
     | 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,132 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            # authmotion
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                gem 'authmotion'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                $ bundle
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Or install it yourself as:
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                $ gem install authmotion
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ##How use it for login?
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             ```ruby
         
     | 
| 
      
 21 
     | 
    
         
            +
            class LoginController < UIViewController
         
     | 
| 
      
 22 
     | 
    
         
            +
              include Auth::EmailLogin
         
     | 
| 
      
 23 
     | 
    
         
            +
              
         
     | 
| 
      
 24 
     | 
    
         
            +
              def viewDidLoad
         
     | 
| 
      
 25 
     | 
    
         
            +
                 #anything here... should be your form
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              ## You need define how get this fields, in this example i guess that the
         
     | 
| 
      
 29 
     | 
    
         
            +
              ## inputs should be @email and @password  
         
     | 
| 
      
 30 
     | 
    
         
            +
              def user_field
         
     | 
| 
      
 31 
     | 
    
         
            +
                @email 
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              def password_field
         
     | 
| 
      
 35 
     | 
    
         
            +
                @password
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              #  format data for send to server
         
     | 
| 
      
 39 
     | 
    
         
            +
              def data_login_user
         
     | 
| 
      
 40 
     | 
    
         
            +
                {user:{login: @email.text, password:@password.text}}
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              # URL connection for login
         
     | 
| 
      
 44 
     | 
    
         
            +
              def url_log_in
         
     | 
| 
      
 45 
     | 
    
         
            +
                "http://auth-motion-server.herokuapp.com/users/login"
         
     | 
| 
      
 46 
     | 
    
         
            +
              end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
              #  Wating actions. In this app you'll see a background and an animation
         
     | 
| 
      
 49 
     | 
    
         
            +
              def waiting_view
         
     | 
| 
      
 50 
     | 
    
         
            +
                @background = WaitingView.create
         
     | 
| 
      
 51 
     | 
    
         
            +
                view.addSubview(@background)
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              def hide_waiting_view
         
     | 
| 
      
 55 
     | 
    
         
            +
                @background.removeFromSuperview
         
     | 
| 
      
 56 
     | 
    
         
            +
              end
         
     | 
| 
      
 57 
     | 
    
         
            +
              
         
     | 
| 
      
 58 
     | 
    
         
            +
              def success_conection_login
         
     | 
| 
      
 59 
     | 
    
         
            +
                lambda{ |response| "PUTS YOUR ACTIONS HERE" }
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
            end
         
     | 
| 
      
 62 
     | 
    
         
            +
             ```
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            case test
         
     | 
| 
      
 65 
     | 
    
         
            +
              * {user: login, password: 123456}
         
     | 
| 
      
 66 
     | 
    
         
            +
              
         
     | 
| 
      
 67 
     | 
    
         
            +
            ##How use it for Register?
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
             ```ruby
         
     | 
| 
      
 70 
     | 
    
         
            +
            class LoginController < UIViewController
         
     | 
| 
      
 71 
     | 
    
         
            +
              include Auth::EmailLogin
         
     | 
| 
      
 72 
     | 
    
         
            +
              
         
     | 
| 
      
 73 
     | 
    
         
            +
              def viewDidLoad
         
     | 
| 
      
 74 
     | 
    
         
            +
                 #anything here... should be your form
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              ## You need define how get this fields,
         
     | 
| 
      
 78 
     | 
    
         
            +
              ## in this example i guess that the inputs should be @email, @password,@password_confirmation  
         
     | 
| 
      
 79 
     | 
    
         
            +
              def user_field
         
     | 
| 
      
 80 
     | 
    
         
            +
                @email 
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              def password_field
         
     | 
| 
      
 84 
     | 
    
         
            +
                @password
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
              
         
     | 
| 
      
 87 
     | 
    
         
            +
              def password_confirmation_field
         
     | 
| 
      
 88 
     | 
    
         
            +
                @password_confirmation
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              #########
         
     | 
| 
      
 92 
     | 
    
         
            +
              #  format data for send to server
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              def data_login_user
         
     | 
| 
      
 95 
     | 
    
         
            +
                {user:{login: @email.text, password:@password.text, password_confirmation: @password_confirmation.text}}
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              # URL connection for register, POST
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              def url_log_in
         
     | 
| 
      
 101 
     | 
    
         
            +
                "http://auth-motion-server.herokuapp.com/users"
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              #  Wating actions. In this app you'll see a background and an animation
         
     | 
| 
      
 105 
     | 
    
         
            +
              def waiting_view
         
     | 
| 
      
 106 
     | 
    
         
            +
                @background = WaitingView.create
         
     | 
| 
      
 107 
     | 
    
         
            +
                view.addSubview(@background)
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def hide_waiting_view
         
     | 
| 
      
 111 
     | 
    
         
            +
                @background.removeFromSuperview
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
              
         
     | 
| 
      
 114 
     | 
    
         
            +
              def success_conection_register
         
     | 
| 
      
 115 
     | 
    
         
            +
                lambda{ |response| "PUTS YOUR ACTIONS HERE" }
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
            end
         
     | 
| 
      
 118 
     | 
    
         
            +
             ```
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            #### case test
         
     | 
| 
      
 121 
     | 
    
         
            +
              * Can register => {user: login, password: 123456, password_password: 123456}
         
     | 
| 
      
 122 
     | 
    
         
            +
              * Is registered => {user: registered, password: ..., password: ...} any password it's ok
         
     | 
| 
      
 123 
     | 
    
         
            +
              * Other error, you can test with any user.
         
     | 
| 
      
 124 
     | 
    
         
            +
              
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
            1. Fork it
         
     | 
| 
      
 129 
     | 
    
         
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
      
 130 
     | 
    
         
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
      
 131 
     | 
    
         
            +
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
      
 132 
     | 
    
         
            +
            5. Create new Pull Request
         
     | 
    
        data/lib/authmotion.rb
    ADDED
    
    | 
         @@ -0,0 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            unless defined?(Motion::Project::Config)
         
     | 
| 
      
 2 
     | 
    
         
            +
              raise "This file must be required within a RubyMotion project Rakefile."
         
     | 
| 
      
 3 
     | 
    
         
            +
            end
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            lib_dir_path = File.dirname(File.expand_path(__FILE__))
         
     | 
| 
      
 6 
     | 
    
         
            +
            Motion::Project::App.setup do |app|
         
     | 
| 
      
 7 
     | 
    
         
            +
              app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,173 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Authmotion
         
     | 
| 
      
 2 
     | 
    
         
            +
              module EmailLogin
         
     | 
| 
      
 3 
     | 
    
         
            +
                #method that should be call it for register a user
         
     | 
| 
      
 4 
     | 
    
         
            +
                def register_action
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @action = "Register"
         
     | 
| 
      
 6 
     | 
    
         
            +
                  waiting_view
         
     | 
| 
      
 7 
     | 
    
         
            +
                  if has_enough_data_register?
         
     | 
| 
      
 8 
     | 
    
         
            +
                    response = conection(url_register,data_register_user)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  else
         
     | 
| 
      
 10 
     | 
    
         
            +
                    custom_message("All fields are required")
         
     | 
| 
      
 11 
     | 
    
         
            +
                    hide_waiting_view
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                #method that should be call it for log in a user
         
     | 
| 
      
 16 
     | 
    
         
            +
                def login_action
         
     | 
| 
      
 17 
     | 
    
         
            +
                  @action = "login"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  waiting_view
         
     | 
| 
      
 19 
     | 
    
         
            +
                  if has_enough_data_login?
         
     | 
| 
      
 20 
     | 
    
         
            +
                    response = conection(url_log_in,data_login_user)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  else
         
     | 
| 
      
 22 
     | 
    
         
            +
                    custom_message("All fields are required")
         
     | 
| 
      
 23 
     | 
    
         
            +
                    hide_waiting_view
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def has_enough_data_login?
         
     | 
| 
      
 28 
     | 
    
         
            +
                  if user_field.nil? or password_field.nil?
         
     | 
| 
      
 29 
     | 
    
         
            +
                    raise "You need define email and password field"
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  user_valid? and password_field_simple?
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                def has_enough_data_register?
         
     | 
| 
      
 35 
     | 
    
         
            +
                  if user_field.nil? or password_field.nil? or password_confirmation_field.nil? 
         
     | 
| 
      
 36 
     | 
    
         
            +
                    raise "You need define email, password and password confirmation field"
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
      
 38 
     | 
    
         
            +
                  user_valid? and password_register_valid?
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                def errors_model(response)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  message_json = parse(response)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  messages=""
         
     | 
| 
      
 45 
     | 
    
         
            +
                  message_json["errors"].each do |field,message_array|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    messages = " #{messages}\n #{field}: #{message_array.join("\n")}"
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
      
 48 
     | 
    
         
            +
                  custom_message(messages)
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                def user_valid?
         
     | 
| 
      
 52 
     | 
    
         
            +
                  user_field.text != ""
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                def password_field_simple?
         
     | 
| 
      
 56 
     | 
    
         
            +
                  password_field.text != ""
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                def password_register_valid?
         
     | 
| 
      
 60 
     | 
    
         
            +
                  password_field.text != "" and password_confirmation_field.text == password_field.text
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
                
         
     | 
| 
      
 63 
     | 
    
         
            +
                def after_conection ; end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                def other_error
         
     | 
| 
      
 66 
     | 
    
         
            +
                  custom_message("Unknow error")
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                ####
         
     | 
| 
      
 70 
     | 
    
         
            +
                #   This methods should be implemented like a getters. example:
         
     | 
| 
      
 71 
     | 
    
         
            +
                #   def user_field
         
     | 
| 
      
 72 
     | 
    
         
            +
                #     @field #should be UITextField
         
     | 
| 
      
 73 
     | 
    
         
            +
                #   end
         
     | 
| 
      
 74 
     | 
    
         
            +
                ###
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                def user_field
         
     | 
| 
      
 77 
     | 
    
         
            +
                  raise "should be implemented"
         
     | 
| 
      
 78 
     | 
    
         
            +
                end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                def login_field
         
     | 
| 
      
 81 
     | 
    
         
            +
                  raise "should be implemented"
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                def password_field
         
     | 
| 
      
 85 
     | 
    
         
            +
                  raise "should be implemented"
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                def password_confirmation_field
         
     | 
| 
      
 89 
     | 
    
         
            +
                  raise "should be implemented"
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                ###
         
     | 
| 
      
 93 
     | 
    
         
            +
                #   This method is a hash, how we send the data
         
     | 
| 
      
 94 
     | 
    
         
            +
                #  {login: 'x', password: ''}
         
     | 
| 
      
 95 
     | 
    
         
            +
                ##
         
     | 
| 
      
 96 
     | 
    
         
            +
                def data_login_user
         
     | 
| 
      
 97 
     | 
    
         
            +
                  raise "data_login_user MUST BE IMPLEMENTED"
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
      
 99 
     | 
    
         
            +
                
         
     | 
| 
      
 100 
     | 
    
         
            +
                def data_create_user
         
     | 
| 
      
 101 
     | 
    
         
            +
                  raise "data_create_user MUST BE IMPLEMENTED"
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
                
         
     | 
| 
      
 104 
     | 
    
         
            +
                def errors
         
     | 
| 
      
 105 
     | 
    
         
            +
                  raise "errors should be implemented"
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                ###########################
         
     | 
| 
      
 109 
     | 
    
         
            +
                ## Methods for conections
         
     | 
| 
      
 110 
     | 
    
         
            +
                ###########################
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                def url_log_in
         
     | 
| 
      
 113 
     | 
    
         
            +
                  raise 'should be implemented'
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                def url_register
         
     | 
| 
      
 117 
     | 
    
         
            +
                  raise 'should be implemented'
         
     | 
| 
      
 118 
     | 
    
         
            +
                end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                def waiting_view
         
     | 
| 
      
 122 
     | 
    
         
            +
                  raise "waiting_view should be implemented"
         
     | 
| 
      
 123 
     | 
    
         
            +
                end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                ##############
         
     | 
| 
      
 126 
     | 
    
         
            +
                # failed conection, should be a lambda
         
     | 
| 
      
 127 
     | 
    
         
            +
                ###
         
     | 
| 
      
 128 
     | 
    
         
            +
                def failed_conection
         
     | 
| 
      
 129 
     | 
    
         
            +
                  lambda do |response|
         
     | 
| 
      
 130 
     | 
    
         
            +
                    if response.status_code.to_s =~ /40\d/
         
     | 
| 
      
 131 
     | 
    
         
            +
                      message = "#{@action} failed"
         
     | 
| 
      
 132 
     | 
    
         
            +
                    else
         
     | 
| 
      
 133 
     | 
    
         
            +
                      message = response.error_message
         
     | 
| 
      
 134 
     | 
    
         
            +
                    end
         
     | 
| 
      
 135 
     | 
    
         
            +
                    custom_message(message)
         
     | 
| 
      
 136 
     | 
    
         
            +
                  end 
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                def success_conection_register
         
     | 
| 
      
 140 
     | 
    
         
            +
                  lambda{|response| custom_message('Good, user register. May be you need change this :-) ')}      
         
     | 
| 
      
 141 
     | 
    
         
            +
                end
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                def success_conection_login
         
     | 
| 
      
 144 
     | 
    
         
            +
                 lambda{|response| custom_message('Good, user login. May be you need change this :-) ')}
         
     | 
| 
      
 145 
     | 
    
         
            +
                end
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
                private 
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                def conection(url,data)
         
     | 
| 
      
 150 
     | 
    
         
            +
                  @json = nil
         
     | 
| 
      
 151 
     | 
    
         
            +
                  BW::HTTP.post(url, {payload: data} ) do |response|
         
     | 
| 
      
 152 
     | 
    
         
            +
                    if response.ok?
         
     | 
| 
      
 153 
     | 
    
         
            +
                      @json = parse(response)
         
     | 
| 
      
 154 
     | 
    
         
            +
                      success_conection_register.call(response)
         
     | 
| 
      
 155 
     | 
    
         
            +
                    else 
         
     | 
| 
      
 156 
     | 
    
         
            +
                      failed_conection.call(response)
         
     | 
| 
      
 157 
     | 
    
         
            +
                      @json = nil
         
     | 
| 
      
 158 
     | 
    
         
            +
                    end
         
     | 
| 
      
 159 
     | 
    
         
            +
                    hide_waiting_view
         
     | 
| 
      
 160 
     | 
    
         
            +
                  end
         
     | 
| 
      
 161 
     | 
    
         
            +
                end
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                def custom_message(string)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  App.alert(string)
         
     | 
| 
      
 165 
     | 
    
         
            +
                end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                def parse response
         
     | 
| 
      
 168 
     | 
    
         
            +
                  puts response.body.class
         
     | 
| 
      
 169 
     | 
    
         
            +
                  BW::JSON.parse(response.body)
         
     | 
| 
      
 170 
     | 
    
         
            +
                end 
         
     | 
| 
      
 171 
     | 
    
         
            +
              end
         
     | 
| 
      
 172 
     | 
    
         
            +
            end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: authmotion
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: '0.1'
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - daniel
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-12-24 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - '>='
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: you can authenticate a user this gem
         
     | 
| 
      
 28 
     | 
    
         
            +
            email:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - xzdasx@gmail.com
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/authmotion.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/project/authmotion.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            homepage: ''
         
     | 
| 
      
 38 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 39 
     | 
    
         
            +
            - ''
         
     | 
| 
      
 40 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 41 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 42 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 43 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 45 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 46 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 47 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 48 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 50 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
              - - '>='
         
     | 
| 
      
 53 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 56 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 57 
     | 
    
         
            +
            rubygems_version: 2.1.11
         
     | 
| 
      
 58 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 60 
     | 
    
         
            +
            summary: mmmm
         
     | 
| 
      
 61 
     | 
    
         
            +
            test_files: []
         
     |