-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
53 lines (41 loc) · 1.44 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'pivotal-tracker'
require 'csv'
PivotalTracker::Client.token = ENV['TRACKER_TOKEN']
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
autoload :RailsKoans, 'rails_koans'
namespace :rails_koans do
task :check_pivotal_tracker do
begin
PivotalTracker::Client.connection
rescue PivotalTracker::Client::NoToken
puts <<EOF
You need to obtain a Pivotal Tracker API Token and export it in your environment
as TRACKER_TOKEN.
curl -u $USERNAME:$PASSWORD -X GET https://www.pivotaltracker.com/services/v3/tokens/active
Copy the guid field and export it
export TRACKER_TOKEN='c93f12c71bec27843c1d84b3bdd547f3'
Then run your rake command again
EOF
exit
end
end
desc "Create project to walk through Rails Tutorial (http://ruby.railstutorial.org/)"
task :rails_tutorial => :check_pivotal_tracker do
project = RailsKoans.create_project(:name => "Rails Koans ##{rand(1000000).to_i}")
stories = CSV.read("projects/rails_tutorial_demo_app.csv")
# Shift to get rid of the header row
stories.shift
stories.reverse.each do |row|
name = row.shift
description = row.join(' ')
next if name == ''
project.stories.create(
:name => name,
:description => description,
:story_type => 'feature',
:estimate => 1
)
end
puts "\n\n\nYour Koan is available at https://www.pivotaltracker.com/projects/#{project.id}\n\n\n"
end
end