look_like 0.2.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24455b0329770ab18e13367054b6636b24a821dd
4
- data.tar.gz: 1677f5e906454dd63cdb82fe5bcf49db4aad23c5
3
+ metadata.gz: bc5507768dc299dc84e2a03e6886670a95f4419e
4
+ data.tar.gz: 9cf26914d8ce4e6cb04b84a006e9008ed46b1295
5
5
  SHA512:
6
- metadata.gz: dce5a57a541b600e86a9086b487815230e5b89a3c13e3198f76435513452642ec3be06dceb32be288ec2fa73bb32363e4e222bd698c5a270b8b0e363c940aa3b
7
- data.tar.gz: 3f654ac86eac4e9997170723969e6f4fbc13c42fd540287216d1fe9a3b41a318f59459050d83d58c1926913bae5069119bf6b0ea652f0ee4b8f76fb9fa296116
6
+ metadata.gz: 19829fe95ff62328cf7cef68877ce206c1b4d257709f7b9fa04dd8441698e8e64b3b3c797c0a2ec1d159446d421edd9b7794aa1861598ca37ef73a51af7ad699
7
+ data.tar.gz: 9f0e4479622e925f276d8a39edd24a484ac4e0dc8dc413bc1d44a8429b2d9a0f4f735fbe2b1577643b84c838627f12a707cf559116313aa030f054bba3c62f45
data/README.md CHANGED
@@ -138,6 +138,11 @@ expect("5000").to look_like("5,000")
138
138
  expect("$5000").not_to look_like("5000")
139
139
  ```
140
140
 
141
+ - [**Date and Time**](http://amoeba.social/lab/try-look-like/#/Date%20and%20Time)
142
+ ```ruby
143
+
144
+ ```
145
+
141
146
  ## Development
142
147
  - After checking out the repo, run `bin/setup` to install dependencies.
143
148
  - Then, run `rake spec` to run the tests.
data/lib/look_like.rb CHANGED
@@ -10,6 +10,8 @@ require "look_like/matchers/any-value"
10
10
  require "look_like/matchers/string"
11
11
  require "look_like/matchers/email"
12
12
  require "look_like/matchers/enum"
13
+ require "look_like/matchers/time-stamp"
14
+ require "look_like/matchers/date"
13
15
  require "look_like/matchers/url"
14
16
  require "look_like/matchers/regex"
15
17
  require "look_like/matchers/formatted-number"
@@ -0,0 +1,12 @@
1
+ LookLike::Matchers.define(
2
+ {
3
+ :name => :date,
4
+ :desc => "date",
5
+ :select => lambda{|expected|
6
+ "date".eql?(expected) || LookLike::Support.date?(LookLike::Support.mask_date(expected.nil? ? "" : expected))
7
+ },
8
+ :match => lambda{|actual, expected|
9
+ LookLike::Support.mask_date(expected).eql?(LookLike::Support.mask_date(actual)) || ("date".eql?(expected) && LookLike::Support.date?(LookLike::Support.mask_date(actual.nil? ? "" : actual)))
10
+ }
11
+ })
12
+
@@ -0,0 +1,12 @@
1
+ LookLike::Matchers.define(
2
+ {
3
+ :name => :time_stamp,
4
+ :desc => "time-stamp",
5
+ :select => lambda{|expected|
6
+ "timestamp".eql?(expected) || LookLike::Support.time?(LookLike::Support.mask_date(expected.nil? ? "" : expected))
7
+ },
8
+ :match => lambda{|actual, expected|
9
+ LookLike::Support.mask_date(expected).eql?(LookLike::Support.mask_date(actual)) || ("timestamp".eql?(expected) && LookLike::Support.time?(LookLike::Support.mask_date(actual.nil? ? "" : actual)))
10
+ }
11
+ })
12
+
@@ -2,6 +2,10 @@ require "uri"
2
2
  module LookLike
3
3
  class Support
4
4
 
5
+ @@DATE_CHARS = /[DMYHSmhs\d]/
6
+ @@DATE_STAMP_REGEX = /^[\/x]+$/
7
+ @@TIME_STAMP_REGEX = /^[\/x\-\:TZ\s]+$/
8
+
5
9
  def self.url?(string)
6
10
  !!(string =~ /\A#{URI::regexp}\z/)
7
11
  end
@@ -46,5 +50,17 @@ module LookLike
46
50
  amount?(expected.sub(/^[^\d]+/, "$"))
47
51
  end
48
52
 
53
+ def self.time?(stamp)
54
+ @@TIME_STAMP_REGEX === stamp
55
+ end
56
+
57
+ def self.date?(stamp)
58
+ @@DATE_STAMP_REGEX === stamp
59
+ end
60
+
61
+ def self.mask_date(stamp)
62
+ stamp.gsub(@@DATE_CHARS, "x")
63
+ end
64
+
49
65
  end
50
66
  end
@@ -1,3 +1,3 @@
1
1
  module LookLike
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: look_like
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nishant
@@ -76,12 +76,14 @@ files:
76
76
  - lib/look_like/matchers.rb
77
77
  - lib/look_like/matchers/amount.rb
78
78
  - lib/look_like/matchers/any-value.rb
79
+ - lib/look_like/matchers/date.rb
79
80
  - lib/look_like/matchers/email.rb
80
81
  - lib/look_like/matchers/enum.rb
81
82
  - lib/look_like/matchers/formatted-number.rb
82
83
  - lib/look_like/matchers/number.rb
83
84
  - lib/look_like/matchers/regex.rb
84
85
  - lib/look_like/matchers/string.rb
86
+ - lib/look_like/matchers/time-stamp.rb
85
87
  - lib/look_like/matchers/url.rb
86
88
  - lib/look_like/nested-array-matcher.rb
87
89
  - lib/look_like/rspec-matcher.rb