duffy 0.1.3 → 0.1.4
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 +4 -4
- data/README.md +11 -0
- data/lib/duffy/git.rb +10 -2
- data/lib/duffy/version.rb +1 -1
- data/lib/duffy.rb +1 -0
- data/spec/git_spec.rb +23 -0
- data/spec/system_spec.rb +23 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ebf739e3215446bd88668031a347cd5092be22d
|
4
|
+
data.tar.gz: 740786c7c67f0d73cafe552a5d959ddcbea89e95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dd827beedf9849b0c4a1797791b6a70efc2ca7cb3d98054c10878bc4bfe87e0658111510e20e30bf2a61a5f4fe2a8b84cd9e2c652439f9766c7e81b17a816ee
|
7
|
+
data.tar.gz: 44074f8f7b0d594a5d0e9482dde30f8aba7ca998f0ba89cff15c9022963a95acdbb78a8b5123ddc165060d026250828c8798c28f7779ca3e09c3e9f66417f273
|
data/README.md
CHANGED
@@ -41,8 +41,19 @@ This one is namespaced in case you use the 'git' gem. I found it to be overkill
|
|
41
41
|
```ruby
|
42
42
|
Duffy::Git.log # => Produce tab separated listing of current git log.
|
43
43
|
Duffy::Git.count # => Count of git commits in current branch
|
44
|
+
Duffy::Git.email # => Local repo's git user.email or global if none.
|
44
45
|
```
|
45
46
|
|
47
|
+
CPU Detection:
|
48
|
+
Linux only for now, each method returns 1 on non-Linux hosts.
|
49
|
+
Example results for my dual core i5 with hyperthreading.
|
50
|
+
```ruby
|
51
|
+
Duffy::System.cpus # => 1
|
52
|
+
Duffy::System.cores # => 2
|
53
|
+
Duffy::System.threads # => 4
|
54
|
+
```
|
55
|
+
|
56
|
+
|
46
57
|
View Helpers:
|
47
58
|
This is a work in progress. I'm going to try to put all my generic helpers here.
|
48
59
|
```ruby
|
data/lib/duffy/git.rb
CHANGED
@@ -9,15 +9,23 @@ module Duffy
|
|
9
9
|
# Produce tab separated listing of current git log.
|
10
10
|
# Useful for displaying a development history page.
|
11
11
|
def log
|
12
|
-
`git log --pretty=format:"%ad%x09%an%x09%s" --date=short
|
12
|
+
`git log --pretty=format:"%ad%x09%an%x09%s" --date=short`.strip.presence
|
13
13
|
end
|
14
14
|
|
15
15
|
# I tend use the commit count / 1000.0 as a version for my applications.
|
16
16
|
# You wouldn't want to do that if you're building a gem used by others.
|
17
17
|
def count
|
18
|
-
`git rev-list HEAD --count
|
18
|
+
`git rev-list HEAD --count`.presence.to_i
|
19
19
|
end
|
20
20
|
|
21
|
+
# Read the git commiter's email.
|
22
|
+
# Uses local if present, otherwise global (git default procedure)
|
23
|
+
# nil if unset
|
24
|
+
def email
|
25
|
+
`git config --get user.email`.strip.presence
|
26
|
+
end
|
27
|
+
|
28
|
+
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/duffy/version.rb
CHANGED
data/lib/duffy.rb
CHANGED
data/spec/git_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Duffy::Git do
|
3
|
+
|
4
|
+
# These methods return per-host settings, so all I can think of to test is that they are there.
|
5
|
+
# This generates the documentation more than anything.
|
6
|
+
describe "log" do
|
7
|
+
it "returns the git log" do
|
8
|
+
defined?(Duffy::Git.log).should == "method"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "count" do
|
13
|
+
it "returns the git count" do
|
14
|
+
defined?(Duffy::Git.count).should == "method"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "email" do
|
19
|
+
it "returns the git user.email" do
|
20
|
+
defined?(Duffy::Git.email).should == "method"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/system_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Duffy::System do
|
3
|
+
|
4
|
+
# These methods return per-host settings, so all I can think of to test is that they return integers.
|
5
|
+
# This generates the documentation more than anything.
|
6
|
+
describe "cpus" do
|
7
|
+
it "returns the number of physical cpus" do
|
8
|
+
Duffy::System.cpus.should be_an(Integer)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "cores" do
|
13
|
+
it "returns the total number of CPU cores" do
|
14
|
+
Duffy::System.cores.should be_an(Integer)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "threads" do
|
19
|
+
it "returns the total number of threads" do
|
20
|
+
Duffy::System.threads.should be_an(Integer)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duffy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Duffy
|
@@ -104,8 +104,10 @@ files:
|
|
104
104
|
- lib/duffy/system.rb
|
105
105
|
- lib/duffy/version.rb
|
106
106
|
- spec/date_spec.rb
|
107
|
+
- spec/git_spec.rb
|
107
108
|
- spec/spec_helper.rb
|
108
109
|
- spec/string_spec.rb
|
110
|
+
- spec/system_spec.rb
|
109
111
|
- vendor/assets/stylesheets/duffy/print.css
|
110
112
|
- vendor/assets/stylesheets/duffy/reset.css
|
111
113
|
homepage: https://github.com/duffyjp/duffy
|
@@ -134,5 +136,7 @@ specification_version: 4
|
|
134
136
|
summary: Library of things
|
135
137
|
test_files:
|
136
138
|
- spec/date_spec.rb
|
139
|
+
- spec/git_spec.rb
|
137
140
|
- spec/spec_helper.rb
|
138
141
|
- spec/string_spec.rb
|
142
|
+
- spec/system_spec.rb
|