Skip to content

Commit

Permalink
getting started
Browse files Browse the repository at this point in the history
  • Loading branch information
Arafat M committed Feb 12, 2011
1 parent 3ef3cc5 commit 030c9d5
Show file tree
Hide file tree
Showing 31 changed files with 988 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions arafatm-fable.bkp-8a34e77/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
*.swp
db/*.db
*.log
20 changes: 20 additions & 0 deletions arafatm-fable.bkp-8a34e77/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
= Make up stories

= TODO:

- depoloy to heroku
- json CRUD Feature
- Mark Release as complete
- Color code Story Status (Not Ready, Ready, IP, Verify, Done)
- json CRUD Release
- json to CRUD Story
- Color code Release as DONE
- Story History
- Summary of incomplete/complete in Feature and Release headers of map
- Allow delay of release
- Option to increment all subsequent releases by same timespan

= DONE =

- View only Story map
- Refactor Task -> Story
30 changes: 30 additions & 0 deletions arafatm-fable.bkp-8a34e77/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
require 'dm-is-list'
require 'dm-validations'
require 'dm-serializer'

require 'sinatra'
require 'logger'

Dir.glob('lib/models/*.rb') do |model|
require model
end

DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/db/fable.db")
DataMapper.auto_upgrade!

class App < Sinatra::Base
configure do
LOGGER = Logger.new("sinatra.log")
end

helpers do
def logger
LOGGER
end
end
end


217 changes: 217 additions & 0 deletions arafatm-fable.bkp-8a34e77/client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
#!/usr/bin/ruby

# TODO: Verify server is running

require 'rubygems'
require 'httparty'
require 'shellwords'


class Fable
include HTTParty
base_uri 'localhost:4567'
end

def print_help
helps = <<-END
Valid Inputs:
--
f :id
get /feature/:id
--
f :id s
get /feature/:id/stories
--
f -c "some description"
post /feature/ {description: "some description"}
--
f -u :id "some description"
post /feature/:id {description: "some description"}
--
f -d :id
delete /feature/:id
--
r :id
get /release/:id
--
r :id s
get /release/:id/stories
--
r -c "some description" "2010-01-01"
post /release/ {description: "some description", date: "2010-01-01"}
--
r -ud :id "some description"
post /release/:id {description: "some description"}
--
r -ut :id 2010-01-01
post /release/:id {date: 2010-01-01}
--
r -d :id
delete /release/:id
END
puts helps
end

def get_feature(id)
output = Fable.get("/feature/#{id}")
if output == nil
puts 'Invalid feature id provided'
else
puts output.to_yaml
end
end

def get_feature_stories(id)
output = Fable.get("/feature/#{id}/stories")
if output == nil
puts 'Invalid feature id provided'
else
puts output.to_yaml
end
end

def new_feature(description)
puts description
feature = Fable.post("/feature",
{:body => {:description => description}})
puts feature.to_yaml
end

def update_feature(id, description)
puts id, description
feature = Fable.post("/feature/#{id}",
{:body => {:description => description}})
puts feature.to_yaml
end

def delete_feature(id)
puts "Deleting Feature(#{id})"
resp = Fable.delete("/feature/#{id}")
puts resp
end

def get_release(id)
output = Fable.get("/release/#{id}")
if output == nil
puts 'Invalid release id provided'
else
puts output.to_yaml
end
end

def get_release_stories(id)
output = Fable.get("/release/#{id}/stories")
if output == nil
puts 'Invalid release id provided'
else
puts output.to_yaml
end
end

def new_release(description)
puts description
release = Fable.post("/release",
{:body => {:description => description}})
puts release.to_yaml
end

def update_release_description(id, description)
puts id, description
release = Fable.post("/release/#{id}",
{:body => {:description => description}})
puts release.to_yaml
end
def update_release_date(id, date)
puts id, date
release = Fable.post("/release/#{id}",
{:body => {:date => date}})
puts release.to_yaml
end

def delete_release(id)
puts "Deleting Release(#{id})"
resp = Fable.delete("/release/#{id}")
puts resp
end

print '> '
while input = STDIN.gets
puts '------------'
args = Shellwords.shellwords(input)

if args[0] == 'q'
exit
elsif args[0] == 'f'
if args[1] == nil
print_help
elsif args[1].to_i != 0
if args[2] == nil
get_feature(args[1])
elsif args[2] == 's'
get_feature_stories args[1]
end
elsif args[1] == '-c'
if args[2] == nil
print_help
else
new_feature args[2]
end
elsif args[1] == '-u'
if args[2] == nil || args[2].to_i == 0 || args[3] == nil
print_help
else
update_feature(args[2], args[3])
end
elsif args[1] == '-d'
if args[2] == nil
print_help
else
delete_feature args[2]
end
else
print_help
end
elsif args[0] == 'r'
if args[1] == nil
print_help
elsif args[1].to_i != 0
if args[2] == nil
get_release(args[1])
elsif args[2] == 's'
get_release_stories args[1]
end
elsif args[1] == '-c'
if args[2] == nil
print_help
else
new_release args[2]
end
elsif args[1] == '-ud'
if args[2] == nil || args[2].to_i == 0 || args[3] == nil
print_help
else
update_release_description(args[2], args[3])
end
elsif args[1] == '-ut'
if args[2] == nil || args[2].to_i == 0 || args[3] == nil
print_help
else
update_release_date(args[2], args[3])
end
elsif args[1] == '-d'
if args[2] == nil
print_help
else
delete_release args[2]
end
else
print_help
end
else
print_help
end
puts '============'
print '> '
end
38 changes: 38 additions & 0 deletions arafatm-fable.bkp-8a34e77/db/seed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'application.rb'

DataMapper::Model.descendants.each {|m| m.all.destroy!}

statuses = ['Ready', 'In Progress', 'Verify', 'Done']
points = [0, 1, 2, 3, 5, 8, 13, 20, 40, 60, 100]

d = Date.today
(1..10).each do |i|
r = Release.new(:description => "Release #{i}",
:date => (d + 14*i))
if !r.save
puts r.errors.to_yml
return
end
end

(1..20).each do |i|
f = Feature.new(:description => "Feature #{i}")
puts f.errors unless f.save
if !f.save
puts f.errors.to_yml
return
end

(5..rand(20)).each do |j|
r = Release.all[rand(Release.all.length)]
t = Story.new(:description => "Story #{i} #{j}",
:points => points[rand(points.length)],
:status => statuses[rand(statuses.length)],
:feature => f,
:release => r)
if !t.save
puts t.errors.to_yml
return
end
end
end
38 changes: 38 additions & 0 deletions arafatm-fable.bkp-8a34e77/db/seedsmall.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'application.rb'

DataMapper::Model.descendants.each {|m| m.all.destroy!}

statuses = ['Ready', 'In Progress', 'Verify', 'Done']
points = [0, 1, 2, 3, 5, 8, 13, 20, 40, 60, 100]

d = Date.today
(1..5).each do |i|
r = Release.new(:description => "Release #{i}",
:date => (d + 14*i))
if !r.save
puts r.errors.to_yml
return
end
end

(1..5).each do |i|
f = Feature.new(:description => "Feature #{i}")
puts f.errors unless f.save
if !f.save
puts f.errors.to_yml
return
end

(5..rand(20)).each do |j|
r = Release.all[rand(Release.all.length)]
t = Story.new(:description => "Story #{i} #{j}",
:points => points[rand(points.length)],
:status => statuses[rand(statuses.length)],
:feature => f,
:release => r)
if !t.save
puts t.errors.to_yml
return
end
end
end
1 change: 1 addition & 0 deletions arafatm-fable.bkp-8a34e77/docs/gems
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo gem install sinatra haml do_sqlite3 dm-core dm-is-list dm-validations dm-serializer data_objects bacon watchr dm-migrations dm-sqlite-adapter shotgun
Loading

0 comments on commit 030c9d5

Please sign in to comment.