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 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.pop_argument!("Missing command, try help ;-)")
25
+ commandname = commandcontext.pop_command!("Missing command, try help ;-)")
28
26
 
29
- configuration = Configuration.new('.')
30
-
31
- # make sure that we are configured
32
- if commandname == 'init' || !configuration.has_globalconfiguration?
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 commandname == nil
39
- commandname = 'help'
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)
@@ -10,8 +10,8 @@ module Commands
10
10
  end
11
11
 
12
12
  def run(commandcontext)
13
- type = commandcontext.pop_argument! 'Missing type'
14
- status = commandcontext.pop_argument! 'Missing status'
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 :output_lambda, :prompt_lambda, :now_lambda
7
+ attr_accessor :options, :commands
8
8
 
9
9
  def initialize(arguments, onerror, onoutput, onprompt, onexit)
10
- @arguments = arguments
11
- @headless = (@arguments.any? { |arg| arg == '--headless' })
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 pop_argument!(text_when_missing = nil)
20
- if number_of_arguments == 0
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
- @arguments.shift
28
+ @commands.shift
25
29
  end
26
30
 
27
- def number_of_arguments
28
- @arguments.length
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
- @now_lambda.call
55
+ DateTime.now
52
56
  end
53
57
 
54
58
 
@@ -11,8 +11,8 @@ module Commands
11
11
  end
12
12
 
13
13
  def run(commandcontext)
14
- type = commandcontext.pop_argument! 'Missing type'
15
- pugspath_was = commandcontext.pop_argument! 'Missing path to pugs'
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
@@ -9,10 +9,10 @@ module Commands
9
9
  end
10
10
 
11
11
  def run(commandcontext)
12
- if commandcontext.number_of_arguments == 0
12
+ if commandcontext.number_of_commands == 0
13
13
  help(commandcontext)
14
14
  else
15
- commandname = commandcontext.pop_argument!("")
15
+ commandname = commandcontext.pop_command!("")
16
16
  command = Meta::command_from_name(commandname, @tracker)
17
17
  if command != nil
18
18
  command.help(commandcontext)
@@ -11,8 +11,8 @@ module Commands
11
11
  end
12
12
 
13
13
  def run(commandcontext)
14
- type = commandcontext.pop_argument!.downcase if commandcontext.number_of_arguments > 0
15
- status = commandcontext.pop_argument!.downcase if commandcontext.number_of_arguments > 0
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
@@ -1,3 +1,3 @@
1
1
  module Pug
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
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.1
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-02-26 00:00:00.000000000Z
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: 146984957
59
+ hash: 764089841
62
60
  requirements: []
63
61
  rubyforge_project:
64
62
  rubygems_version: 1.7.2
@@ -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