pug 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pug.rb +9 -16
- data/lib/commands/addcommand.rb +2 -2
- data/lib/commands/commandcontext.rb +14 -10
- data/lib/commands/diffcommand.rb +2 -2
- data/lib/commands/helpcommand.rb +2 -2
- data/lib/commands/listcommand.rb +2 -2
- data/lib/pugversion.rb +1 -1
- metadata +3 -5
- data/lib/commands/initcommand.rb +0 -22
- data/lib/configuration.rb +0 -47
data/bin/pug.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "pug"
|
3
3
|
require "tracker"
|
4
|
-
require "configuration"
|
5
4
|
require "commands/commandcontext"
|
6
|
-
require "commands/initcommand"
|
7
5
|
require "commands/addcommand"
|
8
6
|
require "commands/helpcommand"
|
9
7
|
require "commands/diffcommand"
|
@@ -24,25 +22,20 @@ onexit = lambda do |x|
|
|
24
22
|
end
|
25
23
|
|
26
24
|
commandcontext = Commands::CommandContext.new(ARGV, onerror, onoutput, onprompt, onexit)
|
27
|
-
commandname = commandcontext.
|
25
|
+
commandname = commandcontext.pop_command!("Missing command, try help ;-)")
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
puts "There is no configuration available, please provide me with some info..." if commandname != "init"
|
34
|
-
Commands::InitCommand.new(configuration).run commandcontext
|
35
|
-
exit 0 if commandname == 'init'
|
27
|
+
if commandname == 'help'
|
28
|
+
command = Meta::command_from_name('help', nil)
|
29
|
+
command.run commandcontext
|
30
|
+
exit(0)
|
36
31
|
end
|
37
32
|
|
38
|
-
if
|
39
|
-
|
33
|
+
if commandcontext.options.has_key?'pugs'
|
34
|
+
pugspath = commandcontext.options['pugs']
|
35
|
+
else
|
36
|
+
pugspath = File.join('.', 'pugs')
|
40
37
|
end
|
41
38
|
|
42
|
-
globalconfiguration = configuration.get_globalconfiguration()
|
43
|
-
|
44
|
-
# path to directory should be read from .pug_global
|
45
|
-
pugspath = globalconfiguration.pugspath
|
46
39
|
tracker = Tracker.new(pugspath)
|
47
40
|
|
48
41
|
command = Meta::command_from_name(commandname, tracker)
|
data/lib/commands/addcommand.rb
CHANGED
@@ -10,8 +10,8 @@ module Commands
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def run(commandcontext)
|
13
|
-
type = commandcontext.
|
14
|
-
status = commandcontext.
|
13
|
+
type = commandcontext.pop_command! 'Missing type'
|
14
|
+
status = commandcontext.pop_command! 'Missing status'
|
15
15
|
|
16
16
|
title = commandcontext.prompt "Enter a title"
|
17
17
|
|
@@ -4,28 +4,32 @@ require "commands/headlesscommandcontext"
|
|
4
4
|
|
5
5
|
module Commands
|
6
6
|
class CommandContext
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :options, :commands
|
8
8
|
|
9
9
|
def initialize(arguments, onerror, onoutput, onprompt, onexit)
|
10
|
-
@
|
11
|
-
@
|
10
|
+
@commands = arguments.select { |a| !a.start_with?'-' }
|
11
|
+
@options = Hash[arguments
|
12
|
+
.select { |a| a.start_with?'-' }
|
13
|
+
.map {|o|
|
14
|
+
parsed = Parse::option_to_name_and_value(o)
|
15
|
+
[parsed[:name], parsed[:value]]
|
16
|
+
}]
|
12
17
|
@onerror = onerror
|
13
18
|
@onexit = onexit
|
14
19
|
@onoutput = onoutput
|
15
20
|
@onprompt = onprompt
|
16
|
-
@now_lambda = lambda {|| DateTime.now }
|
17
21
|
end
|
18
22
|
|
19
|
-
def
|
20
|
-
if
|
23
|
+
def pop_command!(text_when_missing = nil)
|
24
|
+
if @commands.length == 0
|
21
25
|
@onerror.call(text_when_missing)
|
22
26
|
@onexit.call(1)
|
23
27
|
end
|
24
|
-
@
|
28
|
+
@commands.shift
|
25
29
|
end
|
26
30
|
|
27
|
-
def
|
28
|
-
@
|
31
|
+
def number_of_commands
|
32
|
+
@commands.length
|
29
33
|
end
|
30
34
|
|
31
35
|
def output(s)
|
@@ -48,7 +52,7 @@ module Commands
|
|
48
52
|
#end
|
49
53
|
|
50
54
|
def get_now
|
51
|
-
|
55
|
+
DateTime.now
|
52
56
|
end
|
53
57
|
|
54
58
|
|
data/lib/commands/diffcommand.rb
CHANGED
@@ -11,8 +11,8 @@ module Commands
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run(commandcontext)
|
14
|
-
type = commandcontext.
|
15
|
-
pugspath_was = commandcontext.
|
14
|
+
type = commandcontext.pop_command! 'Missing type'
|
15
|
+
pugspath_was = commandcontext.pop_command! 'Missing path to pugs'
|
16
16
|
tracker_was = Tracker.new(pugspath_was)
|
17
17
|
DeltaTracker.new().get(type, @tracker_is, tracker_was){|d| commandcontext.output(d) }
|
18
18
|
end
|
data/lib/commands/helpcommand.rb
CHANGED
@@ -9,10 +9,10 @@ module Commands
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run(commandcontext)
|
12
|
-
if commandcontext.
|
12
|
+
if commandcontext.number_of_commands == 0
|
13
13
|
help(commandcontext)
|
14
14
|
else
|
15
|
-
commandname = commandcontext.
|
15
|
+
commandname = commandcontext.pop_command!("")
|
16
16
|
command = Meta::command_from_name(commandname, @tracker)
|
17
17
|
if command != nil
|
18
18
|
command.help(commandcontext)
|
data/lib/commands/listcommand.rb
CHANGED
@@ -11,8 +11,8 @@ module Commands
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run(commandcontext)
|
14
|
-
type = commandcontext.
|
15
|
-
status =
|
14
|
+
type = commandcontext.options['type']
|
15
|
+
status = commandcontext.options['status']
|
16
16
|
|
17
17
|
@tracker.all {|x|
|
18
18
|
if (x.type.downcase == type || type == nil) && (x.status.downcase == status || status == nil)
|
data/lib/pugversion.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-06 00:00:00.000000000Z
|
14
14
|
dependencies: []
|
15
15
|
description: Pug is a simple light-weight distributed issue tracker, main purpose
|
16
16
|
is to automatically create release reports.
|
@@ -26,9 +26,7 @@ files:
|
|
26
26
|
- lib/commands/diffcommand.rb
|
27
27
|
- lib/commands/headlesscommandcontext.rb
|
28
28
|
- lib/commands/helpcommand.rb
|
29
|
-
- lib/commands/initcommand.rb
|
30
29
|
- lib/commands/listcommand.rb
|
31
|
-
- lib/configuration.rb
|
32
30
|
- lib/deltatracker.rb
|
33
31
|
- lib/format.rb
|
34
32
|
- lib/meta.rb
|
@@ -58,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
56
|
version: '0'
|
59
57
|
segments:
|
60
58
|
- 0
|
61
|
-
hash:
|
59
|
+
hash: 764089841
|
62
60
|
requirements: []
|
63
61
|
rubyforge_project:
|
64
62
|
rubygems_version: 1.7.2
|
data/lib/commands/initcommand.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
$:.unshift(File.expand_path('../../', __FILE__))
|
2
|
-
|
3
|
-
require "configuration"
|
4
|
-
|
5
|
-
module Commands
|
6
|
-
class InitCommand
|
7
|
-
def initialize(configuration)
|
8
|
-
@configuration = configuration
|
9
|
-
end
|
10
|
-
|
11
|
-
def run(commandcontext)
|
12
|
-
globalconfiguration = GlobalConfiguration.new
|
13
|
-
globalconfiguration.pugspath = commandcontext.prompt "Enter full path to where pugs will be placed"
|
14
|
-
@configuration.set_globalconfiguration(globalconfiguration)
|
15
|
-
end
|
16
|
-
|
17
|
-
def help(commandcontext)
|
18
|
-
commandcontext.output 'Use pug init'
|
19
|
-
commandcontext.output 'Configures settings file'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/configuration.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require "yaml"
|
2
|
-
|
3
|
-
class GlobalConfiguration
|
4
|
-
attr_accessor :pugspath
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@pugspath = ''
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Configuration
|
12
|
-
def initialize(path)
|
13
|
-
@path = path
|
14
|
-
end
|
15
|
-
|
16
|
-
def _globalconfiguration_filename()
|
17
|
-
File.join(@path, '.pug_global')
|
18
|
-
end
|
19
|
-
|
20
|
-
def has_globalconfiguration?
|
21
|
-
File.exists?(_globalconfiguration_filename)
|
22
|
-
end
|
23
|
-
|
24
|
-
def set_globalconfiguration(model)
|
25
|
-
content = model.to_yaml
|
26
|
-
begin
|
27
|
-
file = File.new(_globalconfiguration_filename, 'w')
|
28
|
-
file.write(content)
|
29
|
-
ensure
|
30
|
-
file.close
|
31
|
-
end
|
32
|
-
|
33
|
-
if !Dir.exists?(model.pugspath)
|
34
|
-
Dir.mkdir(model.pugspath)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_globalconfiguration()
|
39
|
-
begin
|
40
|
-
file = File.open(_globalconfiguration_filename)
|
41
|
-
model = YAML::load(file) if file != nil
|
42
|
-
model
|
43
|
-
ensure
|
44
|
-
file.close if file != nil
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|