github_streak_check 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ad582344ff768d248778902ac303eb9128d2500
4
- data.tar.gz: b892b48f3a5c2bb49835843e7660eeffbed5b348
3
+ metadata.gz: 211bb95c653fc218ff2df2b580498358a9e29e63
4
+ data.tar.gz: 742c3140e01e0fb1ee53c3a1d16916b64c354538
5
5
  SHA512:
6
- metadata.gz: 777caa13d4a7825bee82c5f2942d7af0cbe91d01544e1273027008c415844f6eec6f4b1a4a75aca24c02b23a63314fb68035b696af80aac3ed032087a5f43c51
7
- data.tar.gz: 3d338b36e18c921290ec0da6afa4c534c353865636edb2ddc6b2d69a5d2411aee2066a3c5692ec928359dc9a0fc94a26270c0c6708e721e546a17afc92a58c04
6
+ metadata.gz: d22c372291759035e239257240212842d3f3ca4cd118b786f924e909328b64f168bea2d6633bd1ab9093d9d6aa80f7308807d69991fcc19431c7e6884d3abcca
7
+ data.tar.gz: 93127b83905dd879be2c4ec36164639599eed9b090e99e1d4d73ecc6cd21332735ba17a0ab0fbaa0aa2a22143f84a7a712f010b69003537929b82e6944d43749
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/README.md CHANGED
@@ -6,6 +6,8 @@ how many successive days the user is keep contributing.
6
6
  This RubyGem provides a command to check if you have done today's
7
7
  contribution and optionally send an email if not.
8
8
 
9
+ [![Build Status](https://travis-ci.org/yhara/github_streak_check.png?branch=master)](https://travis-ci.org/yhara/github_streak_check)
10
+
9
11
  ## Installation
10
12
 
11
13
  $ gem i github_streak_check
@@ -31,6 +33,8 @@ way to send email; use /usr/sbin/sendmail if exists, then try to send with SMTP
31
33
 
32
34
  ## Limitations
33
35
 
36
+ IMPORTANT: this gem does not guarantee 100% accuracy!
37
+
34
38
  - Private repos are not supported
35
39
  - Commits to forked repo are not counted [unless it is merged to main repo](https://help.github.com/articles/why-are-my-contributions-not-showing-up-on-my-profile), but github_streak_check returns OK for them, too
36
40
  - Fetches only recent 300 events, so it may fail if you make over 300 commits a day.
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,3 +1,3 @@
1
1
  class GithubStreakCheck
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -7,14 +7,16 @@ require 'pony'
7
7
  class GithubStreakCheck
8
8
  def initialize(opts)
9
9
  @opts = opts
10
+
11
+ @pst = ActiveSupport::TimeZone["Pacific Time (US & Canada)"]
10
12
  end
11
13
 
12
14
  def run
13
15
  if commited_today?
14
- puts "Check OK: you've already done today(#{pst_today} PST)'s contribution."
16
+ puts "Check OK: you've already done today(#{@pst.today} PST)'s contribution."
15
17
  exit 0
16
18
  else
17
- msg = "Check failed: You have not extended today(#{pst_today} PST)'s streak yet"
19
+ msg = "Check failed: You have not extended today(#{@pst.today} PST)'s streak yet"
18
20
  $stderr.puts msg
19
21
  if (addr = @opts[:mail_to])
20
22
  ret = Pony.mail(to: addr,
@@ -32,13 +34,7 @@ class GithubStreakCheck
32
34
  return false if events.length == 0
33
35
 
34
36
  return events.any?{|event|
35
- Time.parse(event["created_at"]).to_date == pst_today
37
+ Time.parse(event["created_at"]).in_time_zone(@pst).to_date == @pst.today
36
38
  }
37
39
  end
38
-
39
- private
40
-
41
- def pst_today
42
- @pst_today ||= ActiveSupport::TimeZone["Pacific Time (US & Canada)"].today
43
- end
44
40
  end
@@ -22,11 +22,11 @@ describe GithubStreakCheck do
22
22
  it "<yesterday's event> : false" do
23
23
  FakeWeb.register_uri(:get,
24
24
  "https://api.github.com/users/#{@login}/events?per_page=300",
25
- body: '[{"created_at":"2013-11-04T10:47:16Z"}]'
26
- # == "2013-11-04T02:47:16-08:00"
25
+ body: '[{"created_at":"2013-11-04T07:47:16Z"}]'
26
+ # == "2013-11-03T23:47:16-08:00"
27
27
 
28
28
  )
29
- Timecop.freeze(Time.parse("2013-11-05T07:00:00-08:00")) do
29
+ Timecop.freeze(Time.parse("2013-11-04T07:00:00-08:00")) do
30
30
  expect(@checker.commited_today?).to be_false
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_streak_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka HARA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pony
@@ -117,6 +117,7 @@ extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
119
  - .gitignore
120
+ - .travis.yml
120
121
  - Gemfile
121
122
  - README.md
122
123
  - Rakefile