my-crowdfund 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a50a83a58519a738dd1861b3dba3df55f21d650a
4
+ data.tar.gz: da08ca649f69d82eb1059f3d84c2d67489a4a876
5
+ SHA512:
6
+ metadata.gz: aad08076e73bad494c811fdaaf78bf3f15adc93000c14541669d1ec1b3960b4a5de673212d094593467e8df072ef6e9ed75ee3b48c67086cc363995dea6a238c
7
+ data.tar.gz: f68de3e2d502a114803e537a4344b834cf4ee82cca5438e34b2fddf0ad86d02ba083920e31655f8228e3379e42b7076b067ab93daf06214d9ff927c7f16b9483
data/LICENCE ADDED
File without changes
data/README ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ VC-FRIENDLY START-UP PROJECTS Croudfund Stats :
2
+ GRT___________________________6635.0
3
+ PROJECT1______________________8075
4
+ PROJECT2______________________8395
5
+ PROJECT3______________________9300
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/crowdfund/project'
4
+ require_relative '../lib/crowdfund/fundrequest'
5
+ require_relative '../lib/crowdfund/grant_project'
6
+
7
+ # project1 = Project.new('LMN', 500, 3000)
8
+ # project2 = Project.new('XYZ', 25, 75)
9
+ # project3 = Project.new('FGH', 300, 700)
10
+ # project4 = Project.new('MNO', 200, 1100)
11
+
12
+ holding = CrowdFund::FundRequest.new('VC-Friendly Start-up Projects')
13
+
14
+ # holding.add_project(project1)
15
+ # holding.add_project(project2)
16
+ # holding.add_project(project3)
17
+ # holding.add_project(project4)
18
+ # holding.request_funding(100) do
19
+ # holding.total_rewards >= 10000 # the only returned value => will be yielded to the method request funding
20
+ # end
21
+ # holding.print_stats
22
+
23
+ # holding.load_project(ARGV.shift || 'projects.csv')
24
+
25
+ default_player_file = File.join(File.dirname(__FILE__), 'projects.csv')
26
+ holding.load_project(ARGV.shift || default_player_file)
27
+
28
+ grant_pr = CrowdFund::GrantProject.new('grt', 700, 4000, 0.6)
29
+ holding.add_project(grant_pr)
30
+
31
+ loop do
32
+ puts "\nHow many croudfund weeks? (type 'quit' to exit)"
33
+ answer = gets.chomp.downcase
34
+ case answer
35
+ when /^\d+$/
36
+ holding.request_funding(Integer(answer))
37
+ when 'quit', 'exit'
38
+ holding.print_stats
39
+ break
40
+ else
41
+ puts "Please enter a valid number or 'quit'"
42
+ end
43
+ end
44
+
45
+ holding.save_fund_stats('Croudfund stats.txt')
@@ -0,0 +1,43 @@
1
+ require_relative '../lib/crowdfund/project'
2
+ require_relative '../lib/crowdfund/fundrequest'
3
+ require_relative '../lib/crowdfund/grant_project'
4
+
5
+ # project1 = Project.new('LMN', 500, 3000)
6
+ # project2 = Project.new('XYZ', 25, 75)
7
+ # project3 = Project.new('FGH', 300, 700)
8
+ # project4 = Project.new('MNO', 200, 1100)
9
+
10
+ holding = CrowdFund::FundRequest.new('VC-Friendly Start-up Projects')
11
+
12
+ # holding.add_project(project1)
13
+ # holding.add_project(project2)
14
+ # holding.add_project(project3)
15
+ # holding.add_project(project4)
16
+ # holding.request_funding(100) do
17
+ # holding.total_rewards >= 10000 # the only returned value => will be yielded to the method request funding
18
+ # end
19
+ # holding.print_stats
20
+
21
+ # holding.load_project(ARGV.shift || 'projects.csv')
22
+
23
+ default_player_file = File.join(File.dirname(__FILE__), 'projects.csv')
24
+ holding.load_project(ARGV.shift || default_player_file)
25
+
26
+ grant_pr = CrowdFund::GrantProject.new('grt', 700, 4000, 0.6)
27
+ holding.add_project(grant_pr)
28
+
29
+ loop do
30
+ puts "\nHow many croudfund weeks? (type 'quit' to exit)"
31
+ answer = gets.chomp.downcase
32
+ case answer
33
+ when /^\d+$/
34
+ holding.request_funding(Integer(answer))
35
+ when 'quit', 'exit'
36
+ holding.print_stats
37
+ break
38
+ else
39
+ puts "Please enter a valid number or 'quit'"
40
+ end
41
+ end
42
+
43
+ holding.save_fund_stats('Croudfund stats.txt')
@@ -0,0 +1,3 @@
1
+ Project1,100,0
2
+ Project2,500,50
3
+ Project3,1000,100
@@ -0,0 +1,8 @@
1
+ require_relative '../lib/crowdfund/school_project'
2
+
3
+ junior_project = CrowdFund::SchoolProject.new('juniors', 10, 100)
4
+ senior_project = CrowdFund::SchoolProject.new('seniors', 20, 500)
5
+
6
+ junior_project.gained
7
+ puts junior_project.need
8
+ senior_project.lost
@@ -0,0 +1,14 @@
1
+ module CrowdFund
2
+ class Die
3
+
4
+ attr_reader :number
5
+
6
+ def initialize
7
+ roll
8
+ end
9
+
10
+ def roll
11
+ rand(1..6)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ module CrowdFund
2
+
3
+ module Fundable
4
+
5
+ def gained
6
+ self.fund += 25
7
+ puts "Project #{name} got more funds!"
8
+ end
9
+
10
+ def lost
11
+ self.fund -= 15
12
+ puts "Project #{name} lost some funds!"
13
+ end
14
+
15
+ def need
16
+ goal - fund
17
+ end
18
+
19
+ def funded?
20
+ fund >= goal
21
+ end
22
+
23
+ def <=>(other)
24
+ other.need <=> need
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'crowdfund/pledge'
2
+ require 'crowdfund/die'
3
+ require 'crowdfund/project'
4
+
5
+ module CrowdFund
6
+
7
+ module FundingRound
8
+
9
+ def self.take_fund(project)
10
+ die = Die.new
11
+ number_rolled = die.roll
12
+
13
+ if number_rolled.even?
14
+ project.gained
15
+ else
16
+ project.lost
17
+ end
18
+
19
+ pledge_recieved = PledgePool.random
20
+ project.earn_pledge(pledge_recieved)
21
+ #puts "Project #{project.name} recieve a #{pledge_recieved.name} pledge worth $#{pledge_recieved.amount}"
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,96 @@
1
+ require 'crowdfund/project'
2
+ require 'crowdfund/die'
3
+ require 'crowdfund/funding_round'
4
+ require 'crowdfund/pledge'
5
+ require 'csv'
6
+
7
+ module CrowdFund
8
+
9
+ class FundRequest
10
+ def initialize(name)
11
+ @name = name.upcase
12
+ @projects = []
13
+ end
14
+
15
+ def add_project(project)
16
+ @projects << project
17
+ end
18
+
19
+ def load_project(from_file)
20
+ CSV.foreach(from_file) do |line|
21
+ project = Project.new(line[0], Integer(line[1]), Integer(line[2]))
22
+ add_project(project)
23
+ end
24
+ end
25
+
26
+ def save_fund_stats(to_file='fund_stats.txt')
27
+ File.open(to_file, 'w') do |file|
28
+ file.puts "#{@name} Croudfund Stats :"
29
+ @projects.sort.each do |project|
30
+ file.puts project_and_fund(project)
31
+ end
32
+ end
33
+ end
34
+
35
+ def total_rewards
36
+ @projects.reduce(0) { |sum, project| sum + project.rewards }
37
+ end
38
+
39
+ def request_funding(weeks)
40
+ puts "The current projects are :"
41
+ @projects.each do |project|
42
+ puts project
43
+ end
44
+ pledges = PledgePool::PLEDGES
45
+ puts "\nThere are #{pledges.size} possible pledge amounts:"
46
+ pledges.each { |pledge| puts "A #{pledge.name} pledge is worth $#{pledge.amount}"}
47
+ 1.upto(weeks) do |week|
48
+
49
+ if block_given?
50
+ break if yield
51
+ end
52
+
53
+ puts "\nFund raising week #{week}:"
54
+ @projects.each do |project|
55
+ FundingRound.take_fund(project)
56
+ puts project
57
+ end
58
+ end
59
+ end
60
+
61
+ def print_stats
62
+ fully_funded_projects, under_funded_projects = @projects.partition { |project| project.funded? }
63
+ puts "\nFully funded projects (funds):"
64
+ fully_funded_projects.each { |project| puts project_and_fund(project) }
65
+ puts "\nUnder funded projects (funds):"
66
+ under_funded_projects.each { |project| puts project_and_fund(project) }
67
+ puts "\nStill needing funds projects (needs):"
68
+ under_funded_projects.sort.each { |project| puts "#{project.name.ljust(30, '_')}#{project.need}" }
69
+
70
+ puts "\nThe projects have collected a total amouts of $#{total_rewards} from pledges:"
71
+
72
+ @projects.each do |project|
73
+ puts "\n#{project.name}'s total rewards:"
74
+ project.each_earned_pledge do |pledge|
75
+ puts "$#{pledge.amount} total #{pledge.name} amount"
76
+ end
77
+ puts "$#{project.rewards} grand total pledges"
78
+ end
79
+
80
+ end
81
+
82
+ def project_and_fund(project)
83
+ "#{project.name.ljust(30, '_')}#{project.fund}"
84
+ end
85
+ end
86
+
87
+ if __FILE__ == $PROGRAM_NAME
88
+ project1 = Project.new('myproject1', 500, 3000)
89
+ project2 = Project.new('myproject1', 250, 750)
90
+
91
+ myrequest = FundRequest.new('my fund equest')
92
+ myrequest.add_project(project1)
93
+ myrequest.add_project(project2)
94
+ myrequest.request_funding
95
+ end
96
+ end
@@ -0,0 +1,67 @@
1
+ module CrowdFund
2
+ class Project
3
+ attr_accessor :name
4
+ attr_reader :fund, :goal
5
+
6
+ def initialize(name, fund, goal)
7
+ @name = name
8
+ @fund = fund
9
+ @goal = goal
10
+ end
11
+
12
+ def gained
13
+ @fund += 25
14
+ puts "Project #{@name} got more funds!"
15
+ end
16
+
17
+ def lost
18
+ @fund -= 15
19
+ puts "Project #{@name} lost some funds!"
20
+ end
21
+
22
+ def need
23
+ @goal - @fund
24
+ end
25
+
26
+ def to_s
27
+ "Project #{@name} has $#{@fund} in fundinfg towards a goal of $#{@goal} => still need $#{need}"
28
+ end
29
+ end
30
+
31
+ end
32
+ project1 = Project.new('LMN', 500, 3000)
33
+ project2 = Project.new('XYZ', 25, 75)
34
+ # project1.lost
35
+ # project2.gained
36
+ # puts project1
37
+ # puts project2
38
+
39
+ # project1.name = 'the new LMN'
40
+ # puts project1.name
41
+ # puts project1.fund
42
+ # puts project1.goal
43
+ # puts project1.need
44
+
45
+ # Arrays
46
+ project3 = Project.new('FGH', 300, 700)
47
+ project4 = Project.new('MNO', 200, 1100)
48
+
49
+ projects = [project1, project2, project3]
50
+
51
+ projects.each do |project|
52
+ puts "#{project.name.ljust(20,'.')}>#{project.goal}"
53
+ end
54
+
55
+ projects.pop
56
+ projects.push(project4)
57
+
58
+ projects.each do |project|
59
+ puts project
60
+ end
61
+
62
+ projects.each do |project|
63
+ project.lost
64
+ project.lost
65
+ project.gained
66
+ puts project
67
+ end
@@ -0,0 +1,30 @@
1
+ require 'crowdfund/project'
2
+
3
+ module CrowdFund
4
+ class GrantProject < Project
5
+
6
+ def initialize(name, fund, goal, charity_ratio=0.5)
7
+ super(name, fund, goal)
8
+ @charity_ratio = charity_ratio
9
+ end
10
+
11
+ def secured?
12
+ # project is secured when it has accumulated more thant half of its goal
13
+ @fund > (goal / 2)
14
+ end
15
+
16
+ def lost
17
+ puts "#{@name} is a Grant Poject : funds cannot be removed!"
18
+ end
19
+
20
+ def earn_pledge(pledge)
21
+ if secured?
22
+ puts "#{@name} is secured and gives #{@charity_ratio} of #{pledge.name} to charity."
23
+ shared_amount = pledge.amount * @charity_ratio
24
+ pledge = Pledge.new(pledge.name, shared_amount)
25
+ end
26
+ super(pledge)
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,15 @@
1
+ Pledge = Struct.new(:name, :amount)
2
+
3
+ module CrowdFund
4
+ module PledgePool
5
+ PLEDGES = [
6
+ Pledge.new(:bronze, 50),
7
+ Pledge.new(:silver, 75),
8
+ Pledge.new(:gold, 100)
9
+ ]
10
+ def self.random
11
+ PLEDGES.sample
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,69 @@
1
+ require 'crowdfund/pledge'
2
+ require 'crowdfund/fundable'
3
+
4
+ module CrowdFund
5
+
6
+ class Project
7
+ include Fundable
8
+
9
+ attr_accessor :name, :fund
10
+ attr_reader :goal
11
+
12
+ def initialize(name, fund, goal)
13
+ @name = name.upcase
14
+ @fund = fund
15
+ @goal = goal
16
+ @earned_pledges = Hash.new(0)
17
+ end
18
+
19
+ def earn_pledge(pledge)
20
+ @earned_pledges[pledge.name] += pledge.amount
21
+ @fund += pledge.amount
22
+ puts "#{@name} earned a #{pledge.name} pledge worth $#{pledge.amount}"
23
+ puts "#{@name}'s pledges: #{@earned_pledges}"
24
+ end
25
+
26
+ def each_earned_pledge
27
+ @earned_pledges.each do |name, amount|
28
+ yield Pledge.new(name, amount)
29
+ end
30
+ end
31
+
32
+ def rewards
33
+ @earned_pledges.values.reduce(0, :+)
34
+ end
35
+
36
+ # Moved to fundable
37
+ # def gained
38
+ # @fund += 25
39
+ # puts "Project #{@name} got more funds!"
40
+ # end
41
+ # def lost
42
+ # @fund -= 15
43
+ # puts "Project #{@name} lost some funds!"
44
+ # end
45
+ # def need
46
+ # @goal - @fund
47
+ # end
48
+ # def funded?
49
+ # @fund >= @goal
50
+ # end
51
+ # def <=>(other_project)
52
+ # other_project.need <=> need
53
+ # end
54
+
55
+ def to_s
56
+ "Project #{@name} has $#{@fund} in fundinfg towards a goal of $#{@goal} => still need $#{need}"
57
+ end
58
+
59
+
60
+ end
61
+ end
62
+
63
+ if __FILE__ == $PROGRAM_NAME
64
+ project1 = Project.new('project1', 100, 500)
65
+ puts project1
66
+ project1.gained
67
+ project1.lost
68
+ puts project1
69
+ end
@@ -0,0 +1,41 @@
1
+ # Project funding program
2
+
3
+ # fund = 1000
4
+ # project = "ABC"
5
+
6
+ # puts "Project #{project} has $#{fund} in funding."
7
+
8
+ # project1 = 'ABC'
9
+ # project2 = 'DEF'
10
+ # project3 = 'GHI'
11
+ # puts "Projects : \n\t#{project1}\n\t#{project2}\n\t#{project3}"
12
+
13
+ # fund1 = 2000
14
+ # fund2 = 1500
15
+ # fund3 = 3500
16
+
17
+ # puts "#{project1.upcase} has a fund of #{fund1}.".center(50,'-')
18
+
19
+ # puts "#{project2.capitalize.ljust(20,'_')} #{fund2} fund"
20
+
21
+ # puts "#{project3.center(8,'$')} has a fund of #{fund3}."
22
+
23
+ def now
24
+ Time.new.strftime('%A %y-%m-%d at %H.%M.%S')
25
+ end
26
+
27
+ def presentation(project,fund = 1500)
28
+ "#{now} : #{project.capitalize.ljust(20,'.')} #{fund} fund."
29
+ end
30
+
31
+ project1 = 'kids charity'
32
+ project2 = 'moon visit'
33
+ project3 = 'clean planet'
34
+
35
+ fund1 = 2000
36
+ fund2 = 1500
37
+ fund3 = 3500
38
+
39
+ puts presentation(project1, fund1)
40
+ puts presentation(project2)
41
+ puts presentation(project3, fund3)
@@ -0,0 +1,18 @@
1
+ require 'crowdfund/fundable'
2
+
3
+ module CrowdFund
4
+ class SchoolProject
5
+
6
+ include Fundable
7
+
8
+ attr_accessor :name, :fund
9
+ attr_reader :goal
10
+
11
+ def initialize(name, fund=0, goal=100)
12
+ @name = name
13
+ @fund = fund
14
+ @goal = goal
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,65 @@
1
+ module CrowdFund
2
+ class Project
3
+ attr_accessor :name
4
+ attr_reader :fund, :goal
5
+
6
+ def initialize(name, fund, goal)
7
+ @name = name
8
+ @fund = fund
9
+ @goal = goal
10
+ end
11
+
12
+ def gained
13
+ @fund += 25
14
+ puts "Project #{@name} got more funds!"
15
+ end
16
+
17
+ def lost
18
+ @fund -= 15
19
+ puts "Project #{@name} lost some funds!"
20
+ end
21
+
22
+ def need
23
+ @goal - @fund
24
+ end
25
+
26
+ def to_s
27
+ "Project #{@name} has $#{@fund} in fundinfg towards a goal of $#{@goal} => still need $#{need}"
28
+ end
29
+ end
30
+
31
+ class Community
32
+ def initialize(name)
33
+ @name = name.upcase
34
+ @projects = []
35
+ end
36
+
37
+ def add_project(project)
38
+ @projects << project
39
+ end
40
+
41
+ def request_funding
42
+ puts "The current projects are :"
43
+ @projects.each do |project|
44
+ puts project
45
+ end
46
+ @projects.each do |project|
47
+ project.lost
48
+ project.gained
49
+ puts project
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ project1 = Project.new('LMN', 500, 3000)
56
+ project2 = Project.new('XYZ', 25, 75)
57
+ project3 = Project.new('FGH', 300, 700)
58
+ project4 = Project.new('MNO', 200, 1100)
59
+
60
+ holding = Community.new('VC-Friendly Start-up Projects')
61
+ holding.add_project(project1)
62
+ holding.add_project(project2)
63
+ holding.add_project(project3)
64
+ holding.add_project(project4)
65
+ holding.request_funding
@@ -0,0 +1,51 @@
1
+ require 'crowdfund/fundrequest'
2
+ require 'crowdfund/pledge'
3
+
4
+ module CrowdFund
5
+
6
+ describe FundRequest do
7
+
8
+ before do
9
+ @fundrequest = FundRequest.new('contest')
10
+ @fund = 50
11
+ @goal = 100
12
+ @project = Project.new('abc', @fund, @goal)
13
+ @fundrequest.add_project(@project)
14
+ $stdout = StringIO.new
15
+ end
16
+
17
+ it 'raises funds if an even number is rolled' do
18
+ Die.any_instance.stub(:roll).and_return(2)
19
+ @fundrequest.request_funding(3)
20
+ @project.fund.should == @fund + @project.rewards + ( 25 * 3 )
21
+ end
22
+
23
+ it 'loses funds if an odd number is rolled' do
24
+ Die.any_instance.stub(:roll).and_return(1)
25
+ @fundrequest.request_funding(3)
26
+ @project.fund.should == @fund + @project.rewards - (15 * 3)
27
+ end
28
+
29
+ context 'calculate total rewards' do
30
+
31
+ before do
32
+ @contest = FundRequest.new('competition')
33
+ end
34
+
35
+ it 'initial total rewards is zero' do
36
+ @contest.total_rewards.should == 0
37
+ end
38
+
39
+ it 'calculates to total amount of pledges' do
40
+ @project1 = Project.new('abc', 100, 1000)
41
+ @project2 = Project.new('def', 200, 1500)
42
+ @project1.earn_pledge(Pledge.new(:gold, 100))
43
+ @project1.earn_pledge(Pledge.new(:bronze, 25))
44
+ @contest.add_project(@project1)
45
+ @contest.add_project(@project2)
46
+
47
+ @contest.total_rewards.should == 125
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,37 @@
1
+ require 'crowdfund/pledge'
2
+
3
+ module CrowdFund
4
+ describe Pledge do
5
+ before do
6
+ @pledge = Pledge.new(:metal, 40)
7
+ end
8
+
9
+ it 'has a name attribute' do
10
+ @pledge.name.should == :metal
11
+ end
12
+
13
+ it 'has an amount attribute' do
14
+ @pledge.amount.should == 40
15
+ end
16
+ end
17
+
18
+ describe PledgePool do
19
+
20
+ it 'has 3 pledges' do
21
+ PledgePool::PLEDGES.size.should == 3
22
+ end
23
+
24
+ it 'has a bronze pledge' do
25
+ PledgePool::PLEDGES[0].should == Pledge.new(:bronze, 50)
26
+ end
27
+
28
+ it 'has a silver pledge' do
29
+ PledgePool::PLEDGES[1].should == Pledge.new(:silver, 75)
30
+ end
31
+
32
+ it 'has a gold pledge' do
33
+ PledgePool::PLEDGES[2].should == Pledge.new(:gold, 100)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,95 @@
1
+ require 'crowdfund/project'
2
+
3
+ module CrowdFund
4
+
5
+ describe Project do
6
+
7
+ before do
8
+ @initial_fund = 100
9
+ @goal = 500
10
+ @project = Project.new("abc", @initial_fund, @goal)
11
+ $stdout = StringIO.new #changed gloabal variable stdout to a new one in this script, to avoit puts commands
12
+ end
13
+
14
+ it 'has an upcase name' do
15
+ @project.name.should == 'ABC'
16
+ end
17
+
18
+ it 'has an initial fund' do
19
+ @project.fund.should == 100
20
+ end
21
+
22
+ it 'has a string representation' do
23
+ @project.to_s.should == 'Project ABC has $100 in fundinfg towards a goal of $500 => still need $400'
24
+ end
25
+
26
+ it 'computes a score as the sum of its health and length of name' do
27
+ @project.need.should == (500 - 100)
28
+ end
29
+
30
+ it 'increases fund by 25 when gained' do
31
+ @project.gained
32
+ @project.fund.should == @initial_fund + 25
33
+ end
34
+
35
+ it 'decreases fund by 15 when lost' do
36
+ @project.lost
37
+ @project.fund.should == @initial_fund - 15
38
+ end
39
+
40
+ context 'has enough funds' do
41
+ before do
42
+ @project = Project.new('abc', 100, 100)
43
+ end
44
+
45
+ it 'is funded' do
46
+ @project.should be_funded
47
+ end
48
+ end
49
+
50
+ context 'has not enough funds' do
51
+ before do
52
+ @project = Project.new('abc', 50, 100)
53
+ end
54
+
55
+ it 'is not funded' do
56
+ @project.should_not be_funded
57
+ end
58
+ end
59
+
60
+ it "calculate the amount of pledges" do
61
+ @project.rewards.should == 0
62
+ @project.earn_pledge(Pledge.new(:bronze, 50))
63
+ @project.rewards.should == 50
64
+ @project.earn_pledge(Pledge.new(:silver, 75))
65
+ @project.rewards.should == 125
66
+ @project.earn_pledge(Pledge.new(:gold, 100))
67
+ @project.rewards.should == 225
68
+ end
69
+
70
+ it "yields each earned pledge and its total amount" do
71
+ @project.earn_pledge(Pledge.new(:bronze, 50))
72
+ @project.earn_pledge(Pledge.new(:bronze, 50))
73
+ @project.earn_pledge(Pledge.new(:bronze, 50))
74
+ @project.earn_pledge(Pledge.new(:silver, 75))
75
+ @project.earn_pledge(Pledge.new(:gold, 100))
76
+ @project.earn_pledge(Pledge.new(:gold, 100))
77
+ @project.earn_pledge(Pledge.new(:gold, 100))
78
+ @project.earn_pledge(Pledge.new(:gold, 100))
79
+
80
+
81
+ yielded = []
82
+ @project.each_earned_pledge do |pledge|
83
+ yielded << pledge
84
+ end
85
+
86
+
87
+ yielded.should == [
88
+ Pledge.new(:bronze, 150),
89
+ Pledge.new(:silver, 75),
90
+ Pledge.new(:gold, 400)
91
+ ]
92
+ end
93
+
94
+ end
95
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: my-crowdfund
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aymen Chetoui
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: ''
28
+ email: aymen.chetoui@gmail.com
29
+ executables:
30
+ - crowdfund
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/Croudfund stats.txt
35
+ - bin/crowdfund
36
+ - bin/crowdfund.rb
37
+ - bin/projects.csv
38
+ - bin/schoolfund.rb
39
+ - lib/crowdfund/die.rb
40
+ - lib/crowdfund/fundable.rb
41
+ - lib/crowdfund/funding_round.rb
42
+ - lib/crowdfund/fundrequest.rb
43
+ - lib/crowdfund/funds.rb
44
+ - lib/crowdfund/grant_project.rb
45
+ - lib/crowdfund/pledge.rb
46
+ - lib/crowdfund/project.rb
47
+ - lib/crowdfund/projects.rb
48
+ - lib/crowdfund/school_project.rb
49
+ - lib/crowdfund/startups.rb
50
+ - spec/crowdfund/fundrequest_spec.rb
51
+ - spec/crowdfund/pledge_spec.rb
52
+ - spec/crowdfund/project_spec.rb
53
+ - LICENCE
54
+ - README
55
+ homepage: ''
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '1.9'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.0.14
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Fund projects contest
79
+ test_files:
80
+ - spec/crowdfund/fundrequest_spec.rb
81
+ - spec/crowdfund/pledge_spec.rb
82
+ - spec/crowdfund/project_spec.rb