pivotal_angel 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pivotal_angel.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Steven Talcott Smith
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # PivotalAngel
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pivotal_angel'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pivotal_angel
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,51 @@
1
+ module PivotalAngel
2
+
3
+ class Label
4
+
5
+ class << self
6
+
7
+ def apply_to(stories, label)
8
+ stories.each do |s|
9
+ story = get_story(s)
10
+ labels = story.labels.split(',')
11
+ labels << label unless labels.include?(label)
12
+ story.update(:labels => labels.join(','))
13
+ end
14
+ end
15
+
16
+ def remove_from(stories, label)
17
+ stories.each do |s|
18
+ story = get_story(s)
19
+ labels = story.labels.split(',')
20
+ labels.delete label
21
+ story.update(:labels => labels.join(','))
22
+ end
23
+ end
24
+
25
+ def rename(project, old_label, new_label)
26
+ stories = project.stories.all(:label => old_label)
27
+ stories.each do |story|
28
+ labels = story.labels.split(',')
29
+ labels.delete(old_label)
30
+ labels << new_label
31
+ story.update(:labels => labels.join(','))
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ private
38
+
39
+ def self.get_story(story)
40
+ if story.is_a? Numeric
41
+ project.stories.all.find{|i| i.id == story }
42
+ elsif story.is_a? PivotalTracker::Story
43
+ story
44
+ else
45
+ raise "Invalid story record in stories array. All elements should either be a story ID or a PivotalTracker::Story"
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,37 @@
1
+ module PivotalAngel
2
+ class Project
3
+ class << self
4
+ def deep_clone(source_project, name)
5
+ new_project = source_project.clone
6
+ new_project.name = name
7
+ new_project.create
8
+
9
+ new_project = PivotalTracker::Project.all.detect { |document| document.name == new_project.name }
10
+
11
+ puts "Copying stories from #{source_project.name} to #{new_project.name}"
12
+ source_project.stories.all.each do |story|
13
+ new_story = story.clone
14
+ new_story.project_id = new_project.id
15
+ a_new_story = new_story.create
16
+
17
+ story.tasks.all.each do |task|
18
+ new_task = task.clone
19
+ new_task.story_id = a_new_story.id
20
+ new_task.project_id = new_project.id
21
+ new_task.create
22
+ end
23
+
24
+ story.notes.all.each do |note|
25
+ new_note = note.clone
26
+ new_note.story_id = a_new_story.id
27
+ new_note.project_id = new_project.id
28
+ new_note.create
29
+ end
30
+ putc "."
31
+ end
32
+ puts "Done"
33
+ new_project
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module PivotalAngel
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,3 @@
1
+ require "pivotal_angel/version"
2
+ require "pivotal_angel/label"
3
+ require "pivotal_angel/project"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pivotal_angel/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Rad Batnag","Cecille Manalang"]
6
+ gem.email = ["rad@aelogica.com","cecille@aelogica.com"]
7
+ gem.description = %q{Pivotal Tracker helpers for project and labels}
8
+ gem.summary = %q{Deep clone a project, add, remove and rename labels}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "pivotal_angel"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = PivotalAngel::VERSION
17
+
18
+ gem.add_development_dependency "rspec", "~> 2.6"
19
+
20
+ gem.add_dependency "pivotal-tracker"
21
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalAngel::Label do
4
+
5
+ let(:project) do
6
+ PivotalTracker::Project.find(504031)
7
+ end
8
+
9
+ context ".apply_to" do
10
+ it "should apply label to array of stories" do
11
+ stories = project.stories.all(:label => 'cart')
12
+ PivotalAngel::Label.apply_to(stories, 'kariton')
13
+
14
+ # Let the Pivotal Elves do the work first before we run our asserts
15
+ sleep(10)
16
+ stories_with_applied_labels = project.stories.all(:label => 'kariton')
17
+ stories_with_applied_labels.size.should == stories.size
18
+
19
+ # We should restore the labels so that future tests will also work
20
+ PivotalAngel::Label.remove_from(stories, 'kariton')
21
+ end
22
+ end
23
+
24
+ context ".remove_from" do
25
+ it "should remove label from a story" do
26
+ stories = project.stories.all(:label => 'cart')
27
+ PivotalAngel::Label.remove_from(stories, 'cart')
28
+
29
+ sleep(10)
30
+ stories_with_applied_labels = project.stories.all(:label => 'cart')
31
+ stories_with_applied_labels.should be_empty
32
+
33
+ PivotalAngel::Label.apply_to(stories, 'cart')
34
+ end
35
+ end
36
+
37
+ context ".rename" do
38
+ it "should rename labels of a project" do
39
+ PivotalAngel::Label.rename(project, 'shopping', 'splurging')
40
+
41
+ sleep(10)
42
+ stories = project.stories.all(:label => 'shopping')
43
+ stories.should be_empty
44
+
45
+ PivotalAngel::Label.rename(project, 'splurging', 'shopping')
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe PivotalAngel::Project do
4
+
5
+ let(:project) do
6
+ PivotalTracker::Project.find(504031)
7
+ end
8
+
9
+ context ".deep_clone" do
10
+ it "should clone the project including stories, tasks and notes" do
11
+ PivotalAngel::Project.deep_clone(project, "clone of #{project.name}")
12
+
13
+ sleep(10)
14
+ clone_project = PivotalTracker::Project.all.find{ |i| i.name == "clone of #{project.name}" }
15
+ clone_project.should_not be_nil
16
+ project.stories.all.size == clone_project.stories.all.size
17
+
18
+ # delete cloned project
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,4 @@
1
+ require 'pivotal_tracker'
2
+ require 'pivotal_angel'
3
+
4
+ PivotalTracker::Client.token = "072a3aee2dbbd0caf51f8c551954ce21"
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pivotal_angel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rad Batnag
9
+ - Cecille Manalang
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-03-16 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '2.6'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '2.6'
31
+ - !ruby/object:Gem::Dependency
32
+ name: pivotal-tracker
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ description: Pivotal Tracker helpers for project and labels
48
+ email:
49
+ - rad@aelogica.com
50
+ - cecille@aelogica.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/pivotal_angel.rb
61
+ - lib/pivotal_angel/label.rb
62
+ - lib/pivotal_angel/project.rb
63
+ - lib/pivotal_angel/version.rb
64
+ - pivotal_angel.gemspec
65
+ - spec/pivotal_angel/label_spec.rb
66
+ - spec/pivotal_angel/project_spec.rb
67
+ - spec/spec_helper.rb
68
+ homepage: ''
69
+ licenses: []
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.19
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: Deep clone a project, add, remove and rename labels
92
+ test_files:
93
+ - spec/pivotal_angel/label_spec.rb
94
+ - spec/pivotal_angel/project_spec.rb
95
+ - spec/spec_helper.rb