artifacts 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ vendor/*
6
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in artifacts.gemspec
4
+ gemspec
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "artifacts/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "artifacts"
7
+ s.version = Artifacts::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Clive Crous"]
10
+ s.email = ["clive@crous.co.za"]
11
+ s.homepage = "http://www.darkarts.co.za/artifacts"
12
+ s.summary = %q{A console based ticket (bug/feature) tracker who's data travels inside your repository}
13
+ s.description = %q{A console based ticket (bug/feature) tracker who's data travels inside your repository}
14
+
15
+ s.add_dependency "yaml-model", ">= 1.3.1"
16
+
17
+ s.add_development_dependency "bundler", ">= 1.0.0"
18
+ s.add_development_dependency "rspec", ">= 1.3.0"
19
+ s.add_development_dependency "rake", ">= 0.8.7"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'artifacts/executable'
3
+ Artifacts::Executable.new( ARGV )
@@ -0,0 +1,35 @@
1
+ require 'yaml-model'
2
+
3
+ require 'artifacts/version'
4
+ require 'artifacts/exception'
5
+
6
+ require 'artifacts/artifact'
7
+ require 'artifacts/artifact_artifact'
8
+ require 'artifacts/tag'
9
+ require 'artifacts/comment'
10
+
11
+ class Artifacts
12
+
13
+ FILENAME = '.artifacts'
14
+ REPOSITORY_DIRECTORIES = %w|.git _darcs|
15
+
16
+ def self.guess_path
17
+ directory = Dir.pwd
18
+ until directory.empty? do
19
+ path = File.join( directory, FILENAME )
20
+ return directory if File.exists?( path )
21
+ REPOSITORY_DIRECTORIES.each do |repo|
22
+ return directory if File.exists?( File.join( directory, repo ) )
23
+ end
24
+ previous_directory = directory
25
+ directory = File.join( File.split( directory )[0..-2] )
26
+ break if directory == previous_directory
27
+ end
28
+ raise UnableToLocatePath
29
+ end
30
+
31
+ def initialize( path = self.class.guess_path )
32
+ YAML_Model.filename = File.join( path, FILENAME )
33
+ end
34
+
35
+ end
@@ -0,0 +1,44 @@
1
+ class Artifacts
2
+
3
+ Comment ||= Class.new( YAML_Model )
4
+ Tag ||= Class.new( YAML_Model )
5
+ ArtifactArtifact ||= Class.new( YAML_Model )
6
+ class Artifact < YAML_Model
7
+ type :creator, String
8
+ type :summary, String
9
+
10
+ type :created, Time, :default => Time.now
11
+ type :closed, [NilClass,Time], :default => nil
12
+
13
+ has :dependee_references, ArtifactArtifact, ArtifactArtifact => :dependee
14
+ has :dependant_references, ArtifactArtifact, ArtifactArtifact => :dependant
15
+
16
+ has :tags, Tag, :many_to_many => true
17
+ has :comments, Comment
18
+ init :creator, :summary
19
+
20
+ def dependants
21
+ dependee_references.map{|n|n.dependant}
22
+ end
23
+
24
+ def dependees
25
+ dependant_references.map{|n|n.dependee}
26
+ end
27
+
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]
30
+ end
31
+
32
+ def inspect
33
+ spaces = YAML_Model.next_oid.to_s.length + 2
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")) : '' )
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,8 @@
1
+ class Artifacts
2
+ Artifact ||= Class.new( YAML_Model )
3
+ class ArtifactArtifact < YAML_Model
4
+ type :dependee, Artifact
5
+ type :dependant, Artifact
6
+ init :dependee, :dependant
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ class Artifacts
2
+
3
+ Artifact ||= Class.new( YAML_Model )
4
+ class Comment < YAML_Model
5
+ type :artifact, Artifact
6
+ type :created, Time, :default => Time.now
7
+ type :author, String
8
+ type :text, String
9
+
10
+ init :artifact, :author, :text
11
+
12
+ def to_s
13
+ spaces = ' '*(YAML_Model.next_oid.to_s.length+1)
14
+ "#{spaces}#{created.strftime('%Y-%m-%d')} #{author}\n#{spaces}#{text}"
15
+ end
16
+
17
+ def inspect
18
+ to_s
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,6 @@
1
+ class Artifacts
2
+ Exception = Class.new( ::Exception )
3
+ %w|UnableToLocatePath|.each do |exception|
4
+ class_eval( "#{exception} = Class.new( Exception )" )
5
+ end
6
+ end
@@ -0,0 +1,148 @@
1
+ require 'artifacts'
2
+
3
+ class Artifacts
4
+
5
+ def self.username
6
+ "#{`git config user.name`.strip} <#{`git config user.email`.strip}>"
7
+ end
8
+
9
+ class Executable
10
+
11
+ def self.stub( method, default )
12
+ define_method method do |*args|
13
+ command = args.shift
14
+ command ||= default
15
+ send( "#{method}__#{command}".to_sym, *args )
16
+ end
17
+ end
18
+
19
+ def initialize( args )
20
+ if args.first == 'init'
21
+ args.shift
22
+ path = args.shift
23
+ Artifacts.new( path )
24
+ puts "Artifacts repository created at: #{path}"
25
+ exit 0
26
+ end
27
+ begin
28
+ Artifacts.new
29
+ rescue Artifacts::UnableToLocatePath
30
+ puts "Unable to locate artifacts data file!"
31
+ raise
32
+ end
33
+
34
+ @artifacts = []
35
+ while args.first =~ /^\d+$/
36
+ @artifacts << Artifact[ args.shift.to_i ]
37
+ end
38
+
39
+ command = args.shift
40
+ command ||= :help
41
+
42
+ send( command.to_sym, *args )
43
+ end
44
+
45
+ def method_missing( method, *args )
46
+ puts "Unknown command: #{method.to_s.gsub('__',' ')}"
47
+ end
48
+
49
+ def help_command( command, description )
50
+ puts( "%-10s : %s"%[command,description] )
51
+ end
52
+
53
+ def help__help( *args )
54
+ help_command :help, 'Display this message. For more information on a specific command use `help <command>` eg: `help tag`'
55
+ end
56
+
57
+ def help__list( *args )
58
+ help__help
59
+ help_command :tag, 'Tagging'
60
+ help_command :create, 'Create a new artifact'
61
+ help_command :list, 'List artifacts'
62
+ end
63
+
64
+ def self.default_list_filter( list )
65
+ list.select{|a|a.closed == nil && a.dependees.size == 0}
66
+ end
67
+
68
+ def list
69
+ ( @artifacts.empty? ? self.class.default_list_filter(Artifact.all) : @artifacts ).each do |artifact|
70
+ puts artifact
71
+ end
72
+ end
73
+
74
+ def show( *args )
75
+ ( @artifacts.empty? ? self.class.default_list_filter(Artifact.all) : @artifacts ).each do |artifact|
76
+ puts artifact.inspect
77
+ end
78
+ end
79
+
80
+ def closed
81
+ @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
85
+ list
86
+ end
87
+
88
+ def create( *args )
89
+ artifact = Artifact.create( Artifacts.username, args.join(' ') )
90
+ puts "Created artifact #{artifact.id}."
91
+ end
92
+
93
+ def close
94
+ @artifacts.each do |artifact|
95
+ artifact.closed = Time.now
96
+ end
97
+ puts "Closed artifacts:"
98
+ list
99
+ end
100
+
101
+ def version
102
+ puts "\nArtifacts: #{Artifacts::VERSION}"
103
+ end
104
+
105
+ stub :help, :list
106
+
107
+ def depends( *args )
108
+ args.shift if args.first == 'on' # optional syntax sugar
109
+ dependees = args.map{|id|Artifact[id.to_i]}
110
+ @artifacts.each do |artifact|
111
+ dependees.each do |dependee|
112
+ ArtifactArtifact.create( dependee, artifact )
113
+ end
114
+ end
115
+ end
116
+
117
+ def tag( *args )
118
+ args.each do |tag_name|
119
+ tag = Tag.select{|n|n.name == tag_name}.first
120
+ tag ||= Tag.create( tag_name )
121
+ @artifacts.each do |artifact|
122
+ artifact.add_tag( tag )
123
+ end
124
+ end
125
+ end
126
+
127
+ def tags( *args )
128
+ Tag.all.each do |tag|
129
+ puts tag.inspect
130
+ end
131
+ end
132
+
133
+ def comment( *args )
134
+ text = args.join(' ')
135
+ author = Artifacts.username
136
+ @artifacts.each do |artifact|
137
+ Comment.create( artifact, author, text )
138
+ end
139
+ puts "Commends added to:"
140
+ list
141
+ end
142
+
143
+ def tag__create( tag )
144
+ Tag.create( tag )
145
+ end
146
+
147
+ end
148
+ end
@@ -0,0 +1,16 @@
1
+ class Artifacts
2
+
3
+ Artifact ||= Class.new( YAML_Model )
4
+ class Tag < YAML_Model
5
+ type :name, String
6
+ has :artifacts, Artifact, :many_to_many => true
7
+ init :name
8
+ def to_s
9
+ name
10
+ end
11
+ def inspect
12
+ "#{to_s}: #{artifacts.map{|n|n.id}.join(',')}"
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ class Artifacts
2
+ VERSION = "2.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: artifacts
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 0
8
+ - 0
9
+ version: 2.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Clive Crous
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-13 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: yaml-model
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 3
30
+ - 1
31
+ version: 1.3.1
32
+ type: :runtime
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 1
44
+ - 0
45
+ - 0
46
+ version: 1.0.0
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 3
60
+ - 0
61
+ version: 1.3.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rake
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ - 8
75
+ - 7
76
+ version: 0.8.7
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *id004
80
+ description: A console based ticket (bug/feature) tracker who's data travels inside your repository
81
+ email:
82
+ - clive@crous.co.za
83
+ executables:
84
+ - artifacts
85
+ extensions: []
86
+
87
+ extra_rdoc_files: []
88
+
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - Rakefile
93
+ - artifacts.gemspec
94
+ - bin/artifacts
95
+ - lib/artifacts.rb
96
+ - lib/artifacts/artifact.rb
97
+ - lib/artifacts/artifact_artifact.rb
98
+ - lib/artifacts/comment.rb
99
+ - lib/artifacts/exception.rb
100
+ - lib/artifacts/executable.rb
101
+ - lib/artifacts/tag.rb
102
+ - lib/artifacts/version.rb
103
+ has_rdoc: true
104
+ homepage: http://www.darkarts.co.za/artifacts
105
+ licenses: []
106
+
107
+ post_install_message:
108
+ rdoc_options: []
109
+
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 678615055
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 678615055
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ requirements: []
131
+
132
+ rubyforge_project:
133
+ rubygems_version: 1.3.7
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: A console based ticket (bug/feature) tracker who's data travels inside your repository
137
+ test_files: []
138
+