shepherd 0.3.0 → 0.3.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.
@@ -1,33 +1,37 @@
1
- # shepherd 0.3.0 (13-12-2011)
1
+ # shepherd 0.3.1 (17 Jan 2012)
2
+
3
+ + Listing all projects with `list` command and showing a specific project with `show`.
4
+
5
+ # shepherd 0.3.0 (13 Dec 2011)
2
6
 
3
7
  + Made the `update` command and added the `updated_at` column in the database.
4
8
  + `check` command finds the sheep by its name, not id.
5
9
 
6
- # shepherd 0.2.0 (12-12-2011)
10
+ # shepherd 0.2.0 (12 Dec 2011)
7
11
 
8
12
  + `check` command works.
9
13
 
10
- # shepherd 0.1.4 (24-11-2011)
14
+ # shepherd 0.1.4 (24 Nov 2011)
11
15
 
12
16
  + Ability to `rm` some sheeps.
13
17
 
14
- # shepherd 0.1.3 (18-09-2011)
18
+ # shepherd 0.1.3 (18 Sep 2011)
15
19
 
16
20
  + Now we can `show` some sheeps!
17
21
  + `init` command now saves the inited projects!
18
22
  + Provide setup utility.
19
23
 
20
- # shepherd 0.1.2 (18-07-2011)
24
+ # shepherd 0.1.2 (18 July 2011)
21
25
 
22
26
  + Make the `Counter` class
23
27
  + The `init` command works-but-not-really - it's not saving projects at the moment
24
28
  + Provide `Db` connector
25
29
 
26
- # shepherd 0.1.1 (04-07-2011)
30
+ # shepherd 0.1.1 (0 July 2011)
27
31
 
28
32
  + Ease in creating your own commands!
29
33
  + Let be t'e `Cli`!
30
34
 
31
- # shepherd 0.1.0 (18-06-2011)
35
+ # shepherd 0.1.0 (18 June 2011)
32
36
 
33
37
  + Birthday!
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 Szymon Urbaś
1
+ Copyright (c) 2011 - 2012 Szymon Urbaś
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,34 +2,34 @@ Shepherd
2
2
  ========
3
3
 
4
4
  <table>
5
- <tr>
6
- <td><b>Homepage</b></td>
7
- <td><a href="http://semahawk.github.com/shepherd">http://semahawk.github.com/shepherd</a></td>
8
- </tr>
9
- <tr>
10
- <td><b>Author</b></td>
11
- <td>Szymon Urbaś (szymon dot urbas at yahoo dot com)</td>
12
- </tr>
13
- <tr>
14
- <td><b>Copyright</b></td>
15
- <td>2011</td>
16
- </tr>
17
- <tr>
18
- <td><b>License</b></td>
19
- <td>MIT</td>
20
- </tr>
21
- <tr>
22
- <td><b>Latest version</b></td>
23
- <td>0.2.0</td>
24
- </tr>
25
- <tr>
26
- <td><b>Release date</b></td>
27
- <td>January 12th, 2011</td>
28
- </tr>
29
- <tr>
30
- <td><b>Stage</b></td>
31
- <td><i>Development</i></td>
32
- </tr>
5
+ <tr>
6
+ <td><b>Homepage</b></td>
7
+ <td><a href="http://semahawk.github.com/shepherd">http://semahawk.github.com/shepherd</a></td>
8
+ </tr>
9
+ <tr>
10
+ <td><b>Author</b></td>
11
+ <td>Szymon Urbaś (szymon dot urbas at yahoo dot com)</td>
12
+ </tr>
13
+ <tr>
14
+ <td><b>Copyright</b></td>
15
+ <td>2011 - 2012</td>
16
+ </tr>
17
+ <tr>
18
+ <td><b>License</b></td>
19
+ <td>MIT</td>
20
+ </tr>
21
+ <tr>
22
+ <td><b>Latest version</b></td>
23
+ <td>0.3.1</td>
24
+ </tr>
25
+ <tr>
26
+ <td><b>Release date</b></td>
27
+ <td>January 17th, 2012</td>
28
+ </tr>
29
+ <tr>
30
+ <td><b>Stage</b></td>
31
+ <td><i>Development</i></td>
32
+ </tr>
33
33
  </table>
34
34
 
35
35
  ## A bit about
@@ -39,6 +39,11 @@ You just know, if your project got few kilobytes more on weight, how many more f
39
39
 
40
40
  ## Features
41
41
 
42
+ + Files counting
43
+ + Lines counting
44
+ + Chars counting
45
+ + Bytes counting
46
+ + Project's weight in KB, MB ..
42
47
  + Easy own command creation.
43
48
 
44
49
  ## Dependencies
@@ -1,58 +1,58 @@
1
1
  module Shepherd
2
- ROOT = File.expand_path(File.dirname(__FILE__))
3
-
4
- autoload :Utils, "#{ROOT}/shepherd/utils"
5
- autoload :Setup, "#{ROOT}/shepherd/setup"
6
- autoload :Command, "#{ROOT}/shepherd/command"
7
- autoload :Counter, "#{ROOT}/shepherd/counter"
8
- autoload :Db, "#{ROOT}/shepherd/db"
9
- autoload :Cli, "#{ROOT}/shepherd/cli"
10
- autoload :Version, "#{ROOT}/shepherd/version"
11
-
12
- # Stay DRY
13
- extend Utils
14
-
15
- # Check if the setup was once done
16
- if !Dir.exists? "#{Dir.home}/.shepherd"
17
- # Setup was not done so we'll do it, but...
18
- Setup.new
19
- sleep 0.5
20
- puts "Hello there!"
21
- sleep 2
22
- puts "It's your first time using Shepherd, isn't it?"
23
- sleep 4
24
- puts "Knew it!"
25
- sleep 1.5
26
- puts "But before the first run, we would have to make some setup first..."
27
- sleep 4.5
28
- puts "Do you know who's the cousin of zebra?"
29
- sleep 3
30
- puts "You don't?? Phew.."
31
- sleep 2
32
- puts "Ghehe, I know, but I won't tell you.."
33
- sleep 2.8
34
- puts "Oh, no, the setup is *not* running now..."
35
- sleep 2
36
- puts "Okey, okey! Calm down and don't yell at me.."
37
- sleep 3
38
- puts "All right, as you wish, I am doing the setup. You have 10.."
39
- sleep 3.7
40
- puts "No, 5 seconds to abort."
41
- sleep 2
42
- print "5"; sleep 0.4; print "."; sleep 0.4; print "."; sleep 0.2; print " "
43
- print "4"; sleep 0.4; print "."; sleep 0.4; print "."; sleep 0.2; print " "
44
- print "3"; sleep 0.1; print "."; sleep 0.1; print "."; sleep 0.1; print " "
45
- puts "Too late!"
46
- sleep 10
47
- puts "Oh my gosh.. I forgot to click this big, red button which says 'Stop annoying people and do the setup'. Sorry.."
48
- sleep 6.5
49
- puts "Well, I suppose you actually are a human.."
50
- sleep 4
51
- puts "Okey, okey!\n\n"
52
- sleep 2.2
53
- puts "*click*\n\n"
54
- sleep 0.5
55
- # Ghehe :)
56
- # Setup.new
57
- end
2
+ ROOT = File.expand_path(File.dirname(__FILE__))
3
+
4
+ autoload :Utils, "#{ROOT}/shepherd/utils"
5
+ autoload :Setup, "#{ROOT}/shepherd/setup"
6
+ autoload :Command, "#{ROOT}/shepherd/command"
7
+ autoload :Counter, "#{ROOT}/shepherd/counter"
8
+ autoload :Db, "#{ROOT}/shepherd/db"
9
+ autoload :Cli, "#{ROOT}/shepherd/cli"
10
+ autoload :Version, "#{ROOT}/shepherd/version"
11
+
12
+ # Stay DRY
13
+ extend Utils
14
+
15
+ # Check if the setup was once done
16
+ if !Dir.exists? "#{Dir.home}/.shepherd"
17
+ # Setup was not done so we'll do it, but...
18
+ Setup.new
19
+ sleep 0.5
20
+ puts "Hello there!"
21
+ sleep 2
22
+ puts "It's your first time using Shepherd, isn't it?"
23
+ sleep 4
24
+ puts "Knew it!"
25
+ sleep 1.5
26
+ puts "But before the first run, we would have to make some setup first..."
27
+ sleep 4.5
28
+ puts "Do you know who's the cousin of zebra?"
29
+ sleep 3
30
+ puts "You don't?? Phew.."
31
+ sleep 2
32
+ puts "Ghehe, I know, but I won't tell you.."
33
+ sleep 2.8
34
+ puts "Oh, no, the setup is *not* running now..."
35
+ sleep 2
36
+ puts "Okey, okey! Calm down and don't yell at me.."
37
+ sleep 3
38
+ puts "All right, as you wish, I am doing the setup. You have 10.."
39
+ sleep 3.7
40
+ puts "No, 5 seconds to abort."
41
+ sleep 2
42
+ print "5"; sleep 0.4; print "."; sleep 0.4; print "."; sleep 0.2; print " "
43
+ print "4"; sleep 0.4; print "."; sleep 0.4; print "."; sleep 0.2; print " "
44
+ print "3"; sleep 0.1; print "."; sleep 0.1; print "."; sleep 0.1; print " "
45
+ puts "Too late!"
46
+ sleep 10
47
+ puts "Oh my gosh.. I forgot to click this big, red button which says 'Stop annoying people and do the setup'. Sorry.."
48
+ sleep 6.5
49
+ puts "Well, I suppose you actually are a human.."
50
+ sleep 4
51
+ puts "Okey, okey!\n\n"
52
+ sleep 2.2
53
+ puts "*click*\n\n"
54
+ sleep 0.5
55
+ # Ghehe :)
56
+ # Setup.new
57
+ end
58
58
  end
@@ -1,98 +1,98 @@
1
1
  require "trollop"
2
2
 
3
- module Shepherd
4
-
5
- # Command Line Interface class
6
- #
7
- # === Usage
8
- #
9
- # module Shepherd
10
- # Cli.new.run!
11
- # end
12
- #
13
- # or
14
- #
15
- # Shepherd::Cli.new.run!
16
- #
17
- # === Exit statuses
18
- #
19
- # - *0* Everything went just fine :)
20
- # - *1* User said ^C :]
21
- # - *2* User wanted a UnknownCommand
22
- # - *3* The database file was not found
23
- # - *4* User wanted to init another sheep/project with the same name and/or path
24
- # - *5* User wanted to init a project in a path that doesn't exist
25
- # - *6* User wanted to see a sheep that was not inited
26
- #
27
- class Cli
28
-
29
- # Kinda self explanatory
30
- class UnknownCommand < RuntimeError; end
31
-
32
- # A command which is about to be run
33
- attr_accessor :command
34
-
35
- # Require *all* command files
36
- # TODO: Is it possible to make it use autoload? It'd be cool! :)
37
- Dir[File.join(File.dirname(__FILE__), "commands", "*.rb")].each do |all_command_files|
38
- require all_command_files
39
- end
40
-
41
- # Handle the commands list
42
- #
43
- # @return [Array] all available commands
44
- COMMANDS = Command.constants.select { |c| Class === Command.const_get(c) }
45
-
46
- # Get a list of available commands to be printed. (Almost) every line is separated by new line mark - \n
47
- #
48
- # @return [String] list of all available commands
49
- def commands_list
50
- out = ""
51
- # If there are no commands set
52
- if COMMANDS.empty?
53
- out << " ooops! commands are not here!"
54
- else
55
- # Get the longest command's name, so we can output it nice 'n' clean
56
- # This '+ int' at the end is a distance (in spaces) from the longest
57
- # command to descriptions
58
- longest = COMMANDS.max_by(&:size).size + 8
59
- COMMANDS.each do |cmd|
60
- # Calc, calc.
61
- spaces = longest - cmd.size
62
- # Check if there is a 'desc' method
63
- desc = if eval "Command::#{cmd}.new.respond_to? 'desc'"
64
- # If there is - execute it
65
- eval "Command::#{cmd}.new.desc"
66
- else
67
- # If there is not
68
- "---"
69
- end
70
- out << " " << cmd.downcase.to_s << " " * spaces << desc
71
- # If this command is the last one, don't make a new line
72
- unless cmd == COMMANDS.last
73
- out << "\n"
74
- end
75
- end
76
- end
77
- out
78
- end # commands_list:Method
79
-
80
- # Check if command really exists
81
- #
82
- # @return [Boolean] whether the command exists or not
83
- def command_exists?
84
- COMMANDS.include? @command
85
- end
86
-
87
- # Rruns t'e Cli!
88
- def run!
89
-
90
- # Nice, cool 'n' AWESOME --options parsing with Trollop[http://trollop.rubyforge.org/]!
91
- #
92
- # @return [Hash] array full of options
93
- $opts = Trollop::options do
94
- version "shepherd version #{Version::STRING}"
95
- banner <<-EOB
3
+ module Shepherd
4
+
5
+ # Command Line Interface class
6
+ #
7
+ # === Usage
8
+ #
9
+ # module Shepherd
10
+ # Cli.new.run!
11
+ # end
12
+ #
13
+ # or
14
+ #
15
+ # Shepherd::Cli.new.run!
16
+ #
17
+ # === Exit statuses
18
+ #
19
+ # - *0* Everything went just fine :)
20
+ # - *1* User said ^C :]
21
+ # - *2* User wanted a UnknownCommand
22
+ # - *3* The database file was not found
23
+ # - *4* User wanted to init another sheep/project with the same name and/or path
24
+ # - *5* User wanted to init a project in a path that doesn't exist
25
+ # - *6* User wanted to see a sheep that was not inited
26
+ #
27
+ class Cli
28
+
29
+ # Kinda self explanatory
30
+ class UnknownCommand < RuntimeError; end
31
+
32
+ # A command which is about to be run
33
+ attr_accessor :command
34
+
35
+ # Require *all* command files
36
+ # TODO: Is it possible to make it use autoload? It'd be cool! :)
37
+ Dir[File.join(File.dirname(__FILE__), "commands", "*.rb")].each do |all_command_files|
38
+ require all_command_files
39
+ end
40
+
41
+ # Handle the commands list
42
+ #
43
+ # @return [Array] all available commands
44
+ COMMANDS = Command.constants.select { |c| Class === Command.const_get(c) }
45
+
46
+ # Get a list of available commands to be printed. (Almost) every line is separated by new line mark - \n
47
+ #
48
+ # @return [String] list of all available commands
49
+ def commands_list
50
+ out = ""
51
+ # If there are no commands set
52
+ if COMMANDS.empty?
53
+ out << " ooops! commands are not here!"
54
+ else
55
+ # Get the longest command's name, so we can output it nice 'n' clean
56
+ # This '+ int' at the end is a distance (in spaces) from the longest
57
+ # command to descriptions
58
+ longest = COMMANDS.max_by(&:size).size + 8
59
+ COMMANDS.each do |cmd|
60
+ # Calc, calc.
61
+ spaces = longest - cmd.size
62
+ # Check if there is a 'desc' method
63
+ desc = if eval "Command::#{cmd}.new.respond_to? 'desc'"
64
+ # If there is - execute it
65
+ eval "Command::#{cmd}.new.desc"
66
+ else
67
+ # If there is not
68
+ "---"
69
+ end
70
+ out << " " << cmd.downcase.to_s << " " * spaces << desc
71
+ # If this command is the last one, don't make a new line
72
+ unless cmd == COMMANDS.last
73
+ out << "\n"
74
+ end
75
+ end
76
+ end
77
+ out
78
+ end # commands_list:Method
79
+
80
+ # Check if command really exists
81
+ #
82
+ # @return [Boolean] whether the command exists or not
83
+ def command_exists?
84
+ COMMANDS.include? @command
85
+ end
86
+
87
+ # Rruns t'e Cli!
88
+ def run!
89
+
90
+ # Nice, cool 'n' AWESOME --options parsing with Trollop[http://trollop.rubyforge.org/]!
91
+ #
92
+ # @return [Hash] array full of options
93
+ $opts = Trollop::options do
94
+ version "shepherd version #{Version::STRING}"
95
+ banner <<-EOB
96
96
  usage: shep [options] <command>
97
97
 
98
98
  commands are:
@@ -104,40 +104,40 @@ commands are:
104
104
  options are:
105
105
  EOB
106
106
 
107
- opt :version, "show version and exit", :short => '-v'
108
- opt :help, "show me and exit", :short => '-h'
109
-
110
- stop_on COMMANDS.collect { |e| e.downcase.to_s }
111
- end
112
-
113
- # Get the command
114
- @command = ARGV.shift.capitalize.to_sym
115
-
116
- begin
117
- execute @command
118
- exit 0
119
- rescue UnknownCommand => e
120
- puts e.message
121
- exit 2
122
- rescue Db::DatabaseNotFound => e
123
- puts e.message
124
- exit 3
125
- rescue Interrupt
126
- puts "\n\n!# interrupted"
127
- exit 1
128
- end
129
- end # run!:Method
130
-
131
- # Executes a command
132
- #
133
- # @return [Object] command to execute
134
- # @raise [UnknownCommand] if there is no such a command
135
- def execute command
136
- if command_exists?
137
- eval "Command::#{command}.new.init"
138
- else
139
- raise UnknownCommand, "Error: unknown command '#{command.downcase.to_s}'.\nTry --help for help."
140
- end
141
- end # execute_command:Method
142
- end # Cli:Class
107
+ opt :version, "show version and exit", :short => '-v'
108
+ opt :help, "show me and exit", :short => '-h'
109
+
110
+ stop_on COMMANDS.collect { |e| e.downcase.to_s }
111
+ end
112
+
113
+ # Get the command
114
+ @command = ARGV.shift.capitalize.to_sym
115
+
116
+ begin
117
+ execute @command
118
+ exit 0
119
+ rescue UnknownCommand => e
120
+ puts e.message
121
+ exit 2
122
+ rescue Db::DatabaseNotFound => e
123
+ puts e.message
124
+ exit 3
125
+ rescue Interrupt
126
+ puts "\n\n!# interrupted"
127
+ exit 1
128
+ end
129
+ end # run!:Method
130
+
131
+ # Executes a command
132
+ #
133
+ # @return [Object] command to execute
134
+ # @raise [UnknownCommand] if there is no such a command
135
+ def execute command
136
+ if command_exists?
137
+ eval "Command::#{command}.new.init"
138
+ else
139
+ raise UnknownCommand, "Error: unknown command '#{command.downcase.to_s}'.\nTry --help for help."
140
+ end
141
+ end # execute_command:Method
142
+ end # Cli:Class
143
143
  end # Shepherd:Module