shepherd 0.2.0 → 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.
- data/CHANGELOG.md +9 -0
- data/README.md +2 -6
- data/lib/shepherd/commands/check.rb +12 -10
- data/lib/shepherd/commands/init.rb +5 -5
- data/lib/shepherd/commands/show.rb +1 -0
- data/lib/shepherd/commands/update.rb +44 -0
- data/lib/shepherd/setup.rb +3 -1
- data/lib/shepherd/version.rb +1 -1
- metadata +9 -8
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
# shepherd 0.3.0 (13-12-2011)
|
|
2
|
+
|
|
3
|
+
+ Made the `update` command and added the `updated_at` column in the database.
|
|
4
|
+
+ `check` command finds the sheep by its name, not id.
|
|
5
|
+
|
|
6
|
+
# shepherd 0.2.0 (12-12-2011)
|
|
7
|
+
|
|
8
|
+
+ `check` command works.
|
|
9
|
+
|
|
1
10
|
# shepherd 0.1.4 (24-11-2011)
|
|
2
11
|
|
|
3
12
|
+ Ability to `rm` some sheeps.
|
data/README.md
CHANGED
|
@@ -18,17 +18,13 @@ Shepherd
|
|
|
18
18
|
<td><b>License</b></td>
|
|
19
19
|
<td>MIT</td>
|
|
20
20
|
</tr>
|
|
21
|
-
<tr>
|
|
22
|
-
<td> </td>
|
|
23
|
-
<td> </td>
|
|
24
|
-
</tr>
|
|
25
21
|
<tr>
|
|
26
22
|
<td><b>Latest version</b></td>
|
|
27
|
-
<td>0.
|
|
23
|
+
<td>0.2.0</td>
|
|
28
24
|
</tr>
|
|
29
25
|
<tr>
|
|
30
26
|
<td><b>Release date</b></td>
|
|
31
|
-
<td>
|
|
27
|
+
<td>January 12th, 2011</td>
|
|
32
28
|
</tr>
|
|
33
29
|
<tr>
|
|
34
30
|
<td><b>Stage</b></td>
|
|
@@ -3,19 +3,19 @@ module Shepherd::Command
|
|
|
3
3
|
def init
|
|
4
4
|
@opts = Trollop::options do
|
|
5
5
|
banner <<-EOB
|
|
6
|
-
usage: shep check [
|
|
6
|
+
usage: shep check [sheep] [options]
|
|
7
7
|
EOB
|
|
8
8
|
opt :help, "show me and exit", :short => '-h'
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
if
|
|
12
|
-
|
|
11
|
+
if name = ARGV.shift
|
|
12
|
+
check_one name
|
|
13
13
|
else
|
|
14
|
-
|
|
14
|
+
check_all
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
18
|
+
def check_all
|
|
19
19
|
n = 0
|
|
20
20
|
Shepherd::Db.new.execute "select * from sheeps" do |sheep|
|
|
21
21
|
n += 1
|
|
@@ -25,10 +25,10 @@ EOB
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def
|
|
28
|
+
def check_one name
|
|
29
29
|
out = ""
|
|
30
30
|
|
|
31
|
-
sheep = Shepherd::Db.new.get_first_row "select * from sheeps where
|
|
31
|
+
sheep = Shepherd::Db.new.get_first_row "select * from sheeps where name = ?", name
|
|
32
32
|
if sheep
|
|
33
33
|
out += " name: \e[1;35m#{sheep[1]}\e[0;0m from \e[1;34m#{sheep[2]}\e[0;0m\n\n"
|
|
34
34
|
Shepherd::Counter.new(sheep[2]) do |count|
|
|
@@ -65,13 +65,15 @@ EOB
|
|
|
65
65
|
bytes = count.bytes - sheep[6]
|
|
66
66
|
if bytes < 0
|
|
67
67
|
bytes = bytes.to_s[1..-1].to_i
|
|
68
|
-
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m bytes (#{Shepherd::Utils.nice_bytes sheep[6]} \e[1;31m- #{Shepherd::Utils.nice_bytes bytes}\e[0;0m)"
|
|
68
|
+
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m bytes (#{Shepherd::Utils.nice_bytes sheep[6]} \e[1;31m- #{Shepherd::Utils.nice_bytes bytes}\e[0;0m)\n"
|
|
69
69
|
elsif bytes == 0
|
|
70
|
-
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m"
|
|
70
|
+
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m\n"
|
|
71
71
|
else
|
|
72
|
-
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m bytes (#{Shepherd::Utils.nice_bytes sheep[6]} \e[1;32m+ #{Shepherd::Utils.nice_bytes bytes}\e[0;0m)"
|
|
72
|
+
out += " \e[1;34m#{Shepherd::Utils.nice_bytes count.bytes}\e[0;0m bytes (#{Shepherd::Utils.nice_bytes sheep[6]} \e[1;32m+ #{Shepherd::Utils.nice_bytes bytes}\e[0;0m)\n"
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
out += "\n since: #{sheep[8]}"
|
|
76
|
+
|
|
75
77
|
puts "#{out}\n\n"
|
|
76
78
|
end
|
|
77
79
|
else
|
|
@@ -53,15 +53,15 @@ EOB
|
|
|
53
53
|
path: \e[1;34m#{@state[:path]}\e[0;0m
|
|
54
54
|
name: \e[1;32m#{@state[:name]}\e[0;0m
|
|
55
55
|
|
|
56
|
-
state: #{@state[:files]} files
|
|
57
|
-
#{@state[:lines]} lines
|
|
58
|
-
#{@state[:chars]} chars
|
|
56
|
+
state: #{@state[:files].to_nice} files
|
|
57
|
+
#{@state[:lines].to_nice} lines
|
|
58
|
+
#{@state[:chars].to_nice} chars
|
|
59
59
|
|
|
60
|
-
#{Shepherd::Utils.nice_bytes(@state[:bytes])} (#{@state[:bytes]} bytes)
|
|
60
|
+
#{Shepherd::Utils.nice_bytes(@state[:bytes])} (#{@state[:bytes].to_nice} bytes)
|
|
61
61
|
|
|
62
62
|
" unless @opts[:quiet]
|
|
63
63
|
|
|
64
|
-
Shepherd::Db.new.execute "insert into sheeps(id, name, path, files, lines, chars, bytes, inited_at) values(NULL, ?, ?, ?, ?, ?, ?, datetime())", @state[:name], @state[:path], @state[:files], @state[:lines], @state[:chars], @state[:bytes]
|
|
64
|
+
Shepherd::Db.new.execute "insert into sheeps(id, name, path, files, lines, chars, bytes, inited_at, updated_at) values(NULL, ?, ?, ?, ?, ?, ?, datetime(), datetime())", @state[:name], @state[:path], @state[:files], @state[:lines], @state[:chars], @state[:bytes]
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def desc
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Shepherd::Command
|
|
2
|
+
class Update
|
|
3
|
+
def init
|
|
4
|
+
@opts = Trollop::options do
|
|
5
|
+
banner <<-EOB
|
|
6
|
+
usage: shep update [sheep]
|
|
7
|
+
EOB
|
|
8
|
+
opt :help, "show me and exit", :short => '-h'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
if sheep = ARGV.shift
|
|
12
|
+
update_one sheep
|
|
13
|
+
else
|
|
14
|
+
update_all
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def update_all
|
|
19
|
+
puts "updat'd all"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def update_one name
|
|
23
|
+
sheep = Shepherd::Db.new.get_first_row "select * from sheeps where name = ?", name
|
|
24
|
+
|
|
25
|
+
state = {}
|
|
26
|
+
Shepherd::Counter.new(sheep[2]) do |count|
|
|
27
|
+
state[:files] = count.files
|
|
28
|
+
state[:lines] = count.lines
|
|
29
|
+
state[:chars] = count.chars
|
|
30
|
+
state[:bytes] = count.bytes
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if Shepherd::Db.new.execute "update sheeps set files = ?, lines = ?, chars = ?, bytes = ?, updated_at = datetime() where name = ?", state[:files], state[:lines], state[:chars], state[:bytes], name
|
|
34
|
+
puts "[shep] nice: #{name} was successfuly updated."
|
|
35
|
+
else
|
|
36
|
+
puts "[shep] error: something went wrong.."
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def desc
|
|
41
|
+
"update sheep's current state"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/shepherd/setup.rb
CHANGED
|
@@ -3,6 +3,7 @@ require "fileutils"
|
|
|
3
3
|
module Shepherd
|
|
4
4
|
class Setup
|
|
5
5
|
def initialize
|
|
6
|
+
puts "[shep] performing a setup:\n\n"
|
|
6
7
|
@schema = <<-EOS
|
|
7
8
|
create table if not exists sheeps (
|
|
8
9
|
id integer primary key autoincrement,
|
|
@@ -12,7 +13,8 @@ create table if not exists sheeps (
|
|
|
12
13
|
lines integer(7) not null,
|
|
13
14
|
chars integer(10) not null,
|
|
14
15
|
bytes integer(10) not null,
|
|
15
|
-
inited_at datetime not null
|
|
16
|
+
inited_at datetime not null,
|
|
17
|
+
updated_at datetime not null
|
|
16
18
|
);
|
|
17
19
|
EOS
|
|
18
20
|
|
data/lib/shepherd/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shepherd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-01-
|
|
12
|
+
date: 2012-01-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sqlite3
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &79597840 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 1.3.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *79597840
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: yard
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &79597580 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ~>
|
|
@@ -32,10 +32,10 @@ dependencies:
|
|
|
32
32
|
version: 0.7.2
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *79597580
|
|
36
36
|
- !ruby/object:Gem::Dependency
|
|
37
37
|
name: rspec
|
|
38
|
-
requirement: &
|
|
38
|
+
requirement: &79597330 !ruby/object:Gem::Requirement
|
|
39
39
|
none: false
|
|
40
40
|
requirements:
|
|
41
41
|
- - ~>
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
version: 2.6.0
|
|
44
44
|
type: :development
|
|
45
45
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *79597330
|
|
47
47
|
description: Check if/how your projects are growing up!
|
|
48
48
|
email:
|
|
49
49
|
- szymon.urbas@yahoo.com
|
|
@@ -66,6 +66,7 @@ files:
|
|
|
66
66
|
- lib/shepherd/commands/init.rb
|
|
67
67
|
- lib/shepherd/commands/rm.rb
|
|
68
68
|
- lib/shepherd/commands/show.rb
|
|
69
|
+
- lib/shepherd/commands/update.rb
|
|
69
70
|
- lib/shepherd/counter.rb
|
|
70
71
|
- lib/shepherd/db.rb
|
|
71
72
|
- lib/shepherd/setup.rb
|