artifacts 2.0.1 → 2.0.2

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.
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{A console based ticket (bug/feature) tracker who's data travels inside your repository}
13
13
  s.description = %q{A console based ticket (bug/feature) tracker who's data travels inside your repository}
14
14
 
15
- s.add_dependency "yaml-model", ">= 1.3.1"
15
+ s.add_dependency "yaml-model", ">= 1.3.2"
16
16
 
17
17
  s.add_development_dependency "bundler", ">= 1.0.0"
18
18
  s.add_development_dependency "rspec", ">= 1.3.0"
@@ -26,17 +26,18 @@ class Artifacts
26
26
  end
27
27
 
28
28
  def to_s
29
- "%#{YAML_Model.next_oid.to_s.length}d #{created.strftime('%Y-%m-%d')} #{creator} [#{tags.join(',')}] (#{dependants.size}:#{dependees.size})\n#{' '*YAML_Model.next_oid.to_s.length} %s"%[id,summary]
29
+ "%#{YAML_Model.next_oid.to_s.length}d #{summary}"%[id]
30
30
  end
31
31
 
32
32
  def inspect
33
- spaces = YAML_Model.next_oid.to_s.length + 2
33
+ indentation = ' '*(YAML_Model.next_oid.to_s.length + 1)
34
34
  "#{to_s}\n" +
35
- ' '*spaces + 'created : ' + created.to_s + "\n" +
36
- ( closed ? (' '*spaces + 'closed : ' + closed.to_s + "\n" ) : '' ) +
37
- ( dependees.size > 0 ? (' '*spaces + 'dependees : [' + dependees.map{|n|n.id}.join(',') + "]\n" ) : '' ) +
38
- ( dependants.size > 0 ? (' '*spaces + 'dependants : [' + dependants.map{|n|n.id}.join(',') + "]\n" ) : '' ) +
39
- ( comments.size > 0 ? (' '*spaces + "comments :\n" + comments.join("\n")) : '' )
35
+ indentation + 'created : ' + created.to_s + "\n" +
36
+ ( closed ? (indentation + 'closed : ' + closed.to_s + "\n" ) : '' ) +
37
+ ( tags.size > 0 ? (indentation + 'tags : [' + tags.map{|n|n.name}.join(',') + "]\n" ) : '' ) +
38
+ ( dependees.size > 0 ? (indentation + 'dependees : [' + dependees.map{|n|n.id}.join(',') + "]\n" ) : '' ) +
39
+ ( dependants.size > 0 ? (indentation + 'dependants : [' + dependants.map{|n|n.id}.join(',') + "]\n" ) : '' ) +
40
+ ( comments.size > 0 ? (indentation + "comments :\n" + comments.join("\n")) : '' )
40
41
  end
41
42
 
42
43
  end
@@ -32,9 +32,17 @@ class Artifacts
32
32
  end
33
33
 
34
34
  @artifacts = []
35
- while args.first =~ /^\d+$/
36
- @artifacts << Artifact[ args.shift.to_i ]
35
+ while match = args.first && args.first.match( /^(?:(\d+)|#(#{Tag::VALID_NAME}))$/ )
36
+ if match[1]
37
+ @artifacts << Artifact[ args.shift.to_i ]
38
+ elsif match[2]
39
+ args.shift
40
+ tag = Tag.select{|n|n.name == match[2]}.first
41
+ @artifacts << tag.artifacts if tag
42
+ end
37
43
  end
44
+ @artifacts.flatten!
45
+ @artifacts.uniq!
38
46
 
39
47
  command = args.shift
40
48
  command ||= :help
@@ -79,9 +87,8 @@ class Artifacts
79
87
 
80
88
  def closed
81
89
  @artifacts = @artifacts.select{|n|n.closed}
82
- if @artifacts.empty?
83
- @artifacts = Artifact.select{|a|a.closed != nil}.sort{|a,b|a.closed<=>b.closed}
84
- end
90
+ @artifacts = Artifact.select{|a|a.closed} if @artifacts.empty?
91
+ @artifacts = @artifacts.sort{|a,b|a.closed<=>b.closed}
85
92
  list
86
93
  end
87
94
 
@@ -124,6 +131,24 @@ class Artifacts
124
131
  end
125
132
  end
126
133
 
134
+ def untag( *args )
135
+ args.each do |tag_name|
136
+ tag = Tag.select{|n|n.name == tag_name}.first
137
+ @artifacts.each do |artifact|
138
+ artifact.remove_tag( tag )
139
+ end
140
+ end
141
+ end
142
+
143
+ def prune
144
+ Tag.all.sort{|a,b|a.name <=> b.name}.each do |tag|
145
+ if tag.artifacts.size == 0
146
+ puts "Pruning tag: #{tag.name}"
147
+ tag.delete
148
+ end
149
+ end
150
+ end
151
+
127
152
  def tags( *args )
128
153
  Tag.all.each do |tag|
129
154
  puts tag.inspect
@@ -2,7 +2,11 @@ class Artifacts
2
2
 
3
3
  Artifact ||= Class.new( YAML_Model )
4
4
  class Tag < YAML_Model
5
- type :name, String
5
+ InvalidName = Class.new( Exception )
6
+ VALID_NAME = '[-a-z]+'
7
+ type :name, String do |value|
8
+ raise InvalidName unless value =~ /^#{VALID_NAME}$/
9
+ end
6
10
  has :artifacts, Artifact, :many_to_many => true
7
11
  init :name
8
12
  def to_s
@@ -1,3 +1,3 @@
1
1
  class Artifacts
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 0
8
- - 1
9
- version: 2.0.1
8
+ - 2
9
+ version: 2.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Clive Crous
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-14 00:00:00 +02:00
17
+ date: 2011-02-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 1
29
29
  - 3
30
- - 1
31
- version: 1.3.1
30
+ - 2
31
+ version: 1.3.2
32
32
  type: :runtime
33
33
  prerelease: false
34
34
  version_requirements: *id001
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- hash: 517004353
117
+ hash: -44831437
118
118
  segments:
119
119
  - 0
120
120
  version: "0"
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
- hash: 517004353
126
+ hash: -44831437
127
127
  segments:
128
128
  - 0
129
129
  version: "0"