redsafe 0.1.4 → 0.1.5

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.
@@ -4,7 +4,6 @@ if Object.const_defined?("DataMapper")
4
4
  require 'dm-validations'
5
5
  require 'date'
6
6
  require 'time'
7
- require 'DateTime'
8
7
 
9
8
  require Pathname(__FILE__).dirname.expand_path + "sl_user.rb"
10
9
  require Pathname(__FILE__).dirname.expand_path + "sl_aah.rb"
@@ -53,27 +52,28 @@ class User
53
52
  #3. resist: receives the desist string and reviews its integrity
54
53
 
55
54
  def self.sist
56
- #:TIME_FMT = '%Y-%m-%dT%H:%M:%SZ'
55
+ const_set(TIME_FMT, '%Y-%m-%dT%H:%M:%SZ')
57
56
  junk = self.random_string(6)
58
57
  t = Time.now.getutc
59
- time_str = t.strftime('%Y-%m-%dT%H:%M:%SZ')
58
+ time_str = t.strftime(TIME_FMT)
60
59
  the_sist_str = time_str + junk
61
60
  return the_sist_str
62
61
  end
63
62
 
64
63
  def self.desist( the_sist_str )
65
- Time::DATE_FORMATS[:TIME_STR_LEN] = "0000-00-00T00:00:00Z"
66
- #TIME_VALIDATOR = /\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/
67
- timestamp_str = the_sist_str[0...20]
68
- raise ArgumentError if timestamp_str.size < 20
69
- raise ArgumentError unless timestamp_str.match('/\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/')
64
+ #"0000-00-00T00:00:00Z"
65
+ const_set(TIME_STR_LEN, 20 )
66
+ const_set(TIME_VALIDATOR,"/\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/")
67
+ timestamp_str = the_sist_str[0...TIME_STR_LEN]
68
+ raise ArgumentError if timestamp_str.size < TIME_STR_LEN
69
+ raise ArgumentError unless timestamp_str.match(TIME_VALIDATOR)
70
70
  timestamp = Time.parse(timestamp_str).to_i
71
71
  raise ArgumentError if ts < 0
72
72
  return timestamp, the_sist_str[20..-1]
73
73
  end
74
74
 
75
75
  def self.resist(the_sist_str)
76
- const_set TIME_RANGE = 60*60*5
76
+ const_set(TIME_RANGE, 60*60*5)
77
77
  timestamp, junk = self.desist(the_sist_str)
78
78
  now = Time.now.to_i
79
79
  start = now - TIME_RANGE
@@ -2,7 +2,7 @@ class Redsafe
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 4
5
+ PATCH = 5
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redsafe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Shot