little 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'little/error'
3
3
  require 'little/configuration'
4
4
  require 'little/asset'
5
5
  require 'little/tag'
6
- require 'little/attempt'
6
+ require 'little/user'
7
7
  require 'little/notification'
8
8
  require 'little/sender'
9
9
 
@@ -70,5 +70,10 @@ module Little
70
70
  def self.count_by_type(type)
71
71
  Little.get(:assets, {:type => type}, nil, 'count')
72
72
  end
73
+
74
+ # deletes the asset from the system, irrevocably purging assets and tags
75
+ def self.delete(asset, type)
76
+ Little.delete(:assets, {:asset => asset, :type => type, :verify => 'kludge'}, [:asset, :type, :verify])
77
+ end
73
78
  end
74
79
  end
@@ -21,12 +21,12 @@ module Little
21
21
  # removes a tag for a user to an asset
22
22
  # @param [String] id the tag's id
23
23
  def self.delete(id)
24
- Little.delete(:tags, {:id => id}, [:id])
24
+ Little.delete(:tags, {:id => id, :verify => 'kludge'}, [:id, :verify])
25
25
  end
26
26
 
27
27
  # generates a signature for deleting a tag (useful when using the javascript library)
28
28
  def self.sign_delete(id)
29
- Little.sign(:tags, {:id => id})
29
+ Little.sign(:tags, {:id => id, :verify => 'kludge'})
30
30
  end
31
31
 
32
32
  # gets a tag by id
@@ -0,0 +1,36 @@
1
+ module Little
2
+ # log and retrieve login attempts
3
+ class User
4
+ # adds a login attempt
5
+ # @param [String] user the user who attempted to login
6
+ # @param [String] ip the user's ip address (use request.remote_ip in rails)
7
+ # @param [bool] ok whether or not the login was successful
8
+ # @return [Hash] the number of failed attempts in the last 0.5, 1, 3 and 5 minutes
9
+ def self.login_attempt(user, ip, ok)
10
+ Little.post(:users, {:user => user, :ip => ip, :ok => ok}, [:user, :ip, :ok], 'attempt')
11
+ end
12
+
13
+ # gets the previous (2nd last) successful login attempt
14
+ def self.previous_successful_attempt(user)
15
+ Little.get(:users, {:user => user}, [:user], 'attempts')
16
+ end
17
+
18
+ # gets the login attempts for the user
19
+ # @param [String] user the user who attempted to login
20
+ # @param [int] count the number of past attempts to retrieve
21
+ def self.attempts(user, count = 1)
22
+ Little.get(:users, {:user => user, :count => count}, [:user], 'attempts')
23
+ end
24
+
25
+ # generates a signature for getting attempts(useful when using the javascript library)
26
+ def self.sign_attempts(user)
27
+ Little.sign(:users, {:user => user})
28
+ end
29
+
30
+ # deletes the user from the system, irrevocably purging all login attempts, assets, tags,
31
+ # notifications responses and so on for the user
32
+ def self.delete(user)
33
+ Little.delete(:users, {:user => user, :verify => 'kludge'}, [:user, :verify])
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module Little
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-31 00:00:00.000000000 Z
12
+ date: 2012-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &70247362540800 !ruby/object:Gem::Requirement
16
+ requirement: &70155352452020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70247362540800
24
+ version_requirements: *70155352452020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &70247362539500 !ruby/object:Gem::Requirement
27
+ requirement: &70155352450300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70247362539500
35
+ version_requirements: *70155352450300
36
36
  description:
37
37
  email:
38
38
  - help@little.io
@@ -41,12 +41,12 @@ extensions: []
41
41
  extra_rdoc_files: []
42
42
  files:
43
43
  - lib/little/asset.rb
44
- - lib/little/attempt.rb
45
44
  - lib/little/configuration.rb
46
45
  - lib/little/error.rb
47
46
  - lib/little/notification.rb
48
47
  - lib/little/sender.rb
49
48
  - lib/little/tag.rb
49
+ - lib/little/user.rb
50
50
  - lib/little/version.rb
51
51
  - lib/little.rb
52
52
  homepage: http://little.io
@@ -1,30 +0,0 @@
1
- module Little
2
- # log and retrieve login attempts
3
- class Attempt
4
- # adds a login attempt
5
- # @param [String] user the user who attempted to login
6
- # @param [String] ip the user's ip address (use request.remote_ip in rails)
7
- # @param [bool] ok whether or not the login was successful
8
- # @return [Hash] the number of failed attempts in the last 0.5, 1, 3 and 5 minutes
9
- def self.add(user, ip, ok)
10
- Little.post(:attempts, {:user => user, :ip => ip, :ok => ok}, [:user, :ip, :ok])
11
- end
12
-
13
- # gets the previous (2nd last) successful login attempt
14
- def self.get_previous_successful(user)
15
- Little.get(:attempts, {:user => user}, [:user])
16
- end
17
-
18
- # gets the login attempts for theu ser
19
- # @param [String] user the user who attempted to login
20
- # @param [int] count the number of past attempts to retrieve
21
- def self.get(user, count = 1)
22
- Little.get(:attempts, {:user => user, :count => count}, [:user])
23
- end
24
-
25
- # generates a signature for getting attempts(useful when using the javascript library)
26
- def self.sign_get(user)
27
- Little.sign(:attempts, {:user => user})
28
- end
29
- end
30
- end