Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add emojis_count #12

Open
wants to merge 2 commits into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 20, 2012
  1. @carlosgaldino

    Add emojis_count

    carlosgaldino authored
  2. @carlosgaldino
This page is out of date. Refresh to see the latest.
View
14 app/probes/commits.rb
@@ -2,7 +2,7 @@ module Hopper
# Analysis of the commits that go into this repo.
class Commits < Probe
# The data for this Probe.
- exposes :total_count, :commits_per_day, :days_old
+ exposes :total_count, :commits_per_day, :days_old, :emojis_count
# The description.
#
@@ -43,5 +43,15 @@ def days_old(to=nil)
to ||= repository.repo.lookup(revision).author[:time]
((to - birthday) / 60 / 60 / 24).to_i
end
+
+ # The number of emojis present in the commits messages.
+ #
+ # Returns an Integer.
+ def emojis_count
+ emoji_regex = /:\w+:/
+ repository.commit_messages.map do |m|
+ m.scan(emoji_regex).size
+ end.sum
+ end
end
-end
+end
View
BIN  test/examples/simple.tgz
Binary file not shown
View
8 test/probes/commits_test.rb
@@ -7,7 +7,7 @@
test "total_count" do
@probe.total_count # calling it twice to avoid segfaults on ruby_parser
- assert_equal 6, @probe.total_count
+ assert_equal 7, @probe.total_count
end
test "birthday" do
@@ -28,4 +28,8 @@
assert_equal 3, @probe.days_old(to)
end
-end
+
+ test "emojis_count" do
+ assert_equal 2, @probe.emojis_count
+ end
+end
View
4 test/probes/contributors_test.rb
@@ -6,11 +6,11 @@
end
test "contributors_count" do
- assert_equal 1, @probe.contributors_count
+ assert_equal 2, @probe.contributors_count
end
test "contributors" do
assert_equal 'Zach Holman', @probe.contributors['zach@zachholman.com'][:author]
assert 0 < @probe.contributors['zach@zachholman.com'][:count]
end
-end
+end
View
6 test/probes/loc_test.rb
@@ -10,7 +10,7 @@
end
test "all lines" do
- assert_equal 74, @probe.lines
+ assert_equal 78, @probe.lines
end
test "ruby lines" do
@@ -18,7 +18,7 @@
end
test "comment lines" do
- assert_equal 4, @probe.comment_lines
+ assert_equal 5, @probe.comment_lines
end
test "average_width" do
@@ -30,4 +30,4 @@
@probe.stubs(:widths).returns([10,90,25,0])
assert_equal 0.25, @probe.percent_80c
end
-end
+end
View
4 test/probes/whitespace_test.rb
@@ -10,6 +10,6 @@
end
test "trailing_percent" do
- assert_equal "0.02702702702702703", @probe.trailing_percent.to_s
+ assert_equal "0.02564102564102564", @probe.trailing_percent.to_s
end
-end
+end
View
4 test/unit/repository_test.rb
@@ -37,7 +37,7 @@
end
test "revisions" do
- assert_equal 6, @repo.revisions.size
+ assert_equal 7, @repo.revisions.size
end
test "commit_messages" do
@@ -51,4 +51,4 @@
assert !@repo.file_exists?('lolNOPPPPPPEEEEE')
assert !@repo.file_exists?('lib/NOOOOPPPE')
end
-end
+end
Something went wrong with that request. Please try again.