dont-overstay 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dont-overstay.rb +8 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62614d9d64410b2c509fe2ae6ff9b5dc1ba0bc25
4
- data.tar.gz: acdd3ab18846d56efeebbdc655d4ddbc6e439655
3
+ metadata.gz: 1fecd3eca9860702512068c85514cfd5ef3b1551
4
+ data.tar.gz: 01bc5589303d725ad5d10199d7a8924f473a3845
5
5
  SHA512:
6
- metadata.gz: 546ca43ccad2439c7a4894b02a3cd6a6ef1b1388ec78f04be2f94bad382d0d356081f26a74ddde8baac4cfdd526ea964d959575a84f45acddf959d0571094a82
7
- data.tar.gz: 6fe0853207f749980b508c910dde745f4c7c849a0d70b255c9d991bfdfd712ea6293f97573d86e373baa09e405087d34c0d88d030d0c8e02be966145e0e41228
6
+ metadata.gz: bdf887195a69f0aa8a7e5f9ea2cf07075b5631a3a73002b78d77f89e66936bc69a8cf8f713a3484812b35b08f2cf1918c7be3c38b9e85e0da9a2dabce19c919e
7
+ data.tar.gz: 66ade12b67578345967297b8f6ae6b3a079a5f28422b887dc3ef0edea3faa0078485b597f8d539a77870bc4bcca248e9cd41958c5999845528989c4f27aa79fd
data/lib/dont-overstay.rb CHANGED
@@ -12,7 +12,12 @@ class Daytracker
12
12
  end
13
13
  end
14
14
 
15
- def query(before=Time.now.to_i, after=Time.now.to_i - 31536000)
15
+ def query(before=Time.now.to_i, after=((Date.today - 365).to_time.to_i), padded_days=0)
16
+ if ENV['dryrun'] then
17
+ if ENV['dryrun'] == "true" then
18
+ return {:status => "Test", before: before, after: after, padded_days: (padded_days || 0)}
19
+ end
20
+ end
16
21
  country_list = []
17
22
  if @full_url != nil then
18
23
  if before.to_i + 3600 > Time.now.to_i then
@@ -30,7 +35,7 @@ class Daytracker
30
35
  if meta["code"] == 200 then
31
36
  checkins.each{|checkin|
32
37
  if country_list.length == 0 then
33
- country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: 1}
38
+ country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: padded_days.to_i}
34
39
  else
35
40
  if country_list[country_list.length - 1][:code] == checkin["venue"]["location"]["cc"] then
36
41
  # Work out days between the last checkin
@@ -41,7 +46,7 @@ class Daytracker
41
46
  country_list[country_list.length - 1][:length] = days.to_i # Set the number of days stayed here
42
47
  else
43
48
  # Then just create a new entry
44
- country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: 1}
49
+ country_list << {:visit => checkin["createdAt"].to_i, :code => checkin["venue"]["location"]["cc"].to_s, :name => checkin["venue"]["location"]["country"].to_s, length: padded_days.to_i}
45
50
  end
46
51
  end
47
52
  after_timestamp = checkin["createdAt"].to_i + 1800 # Set the createdAt to after Timestamp
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dont-overstay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barry Teoh