fund_raise_abr 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 194946567342e2e382ef0d17b87fcda84968b8ea
4
+ data.tar.gz: 1aacfe0001be1c2969322d922be675f0e46e2db0
5
+ SHA512:
6
+ metadata.gz: d577e3967e935d6919d0bb41c68ddcdf300045e61d0d6f1f3c2361f04b32d199f625e11551a78e06e1f6b2b1c60f2e51a5c34f106c2c0996b671c89357f578c7
7
+ data.tar.gz: 137c8d312c6f52fd83ea582cbf5a25d1b3d229ccf61377f083aedeec95b84baf4ffe5111fd53f32c01bf0665dfcd1e38d3b617e27d0f2c92e45a89e9950351e2
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2016 [ABR Co.]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1 @@
1
+ This gems allow created projects receive pledges and funds to increase funding towards a goal.
@@ -0,0 +1,32 @@
1
+ require_relative 'project'
2
+ require_relative 'fund_request'
3
+ require_relative 'grant_project'
4
+ require_relative 'match_project'
5
+
6
+ my_project = FundRaise::FundRequest.new("VC-Friendly Start-up Projects")
7
+
8
+ grant1 = FundRaise::ProjectGrant.new("Grant A", 5000, 1000)
9
+ match1 = FundRaise::ProjectMatch.new("Match A", 5000, 1000)
10
+
11
+ my_project.add_project(grant1)
12
+ my_project.add_project(match1)
13
+
14
+ default_project_file = File.join(File.dirname(__FILE__), 'project.csv')
15
+ my_project.load_projects(ARGV.shift || default_project_file)
16
+
17
+ loop do
18
+ puts "How many rounds? ('quit' to exit)"
19
+ num_rounds = gets.chomp.downcase
20
+ case num_rounds
21
+ when /^\d+$/
22
+ puts"\nEnjoy your #{num_rounds} rounds.\n"
23
+ my_project.request_funding(num_rounds.to_i)
24
+ when 'quit', 'exit'
25
+ my_project.print_stats
26
+ break
27
+ else
28
+ puts "Please enter a number or 'quit'"
29
+ end
30
+ end
31
+
32
+ my_project.save_under_funded
data/bin/fund_raise ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/fund_raise/project'
4
+ require_relative '../lib/fund_raise/fund_request'
5
+ require_relative '../lib/fund_raise/grant_project'
6
+ require_relative '../lib/fund_raise/match_project'
7
+
8
+ my_project = FundRaise::FundRequest.new("VC-Friendly Start-up Projects")
9
+
10
+ grant1 = FundRaise::ProjectGrant.new("Grant A", 5000, 1000)
11
+ match1 = FundRaise::ProjectMatch.new("Match A", 5000, 1000)
12
+
13
+ my_project.add_project(grant1)
14
+ my_project.add_project(match1)
15
+
16
+ default_project_file = File.join(File.dirname(__FILE__), 'project.csv')
17
+ my_project.load_projects(ARGV.shift || default_project_file)
18
+
19
+ loop do
20
+ puts "How many rounds? ('quit' to exit)"
21
+ num_rounds = gets.chomp.downcase
22
+ case num_rounds
23
+ when /^\d+$/
24
+ puts"\nEnjoy your #{num_rounds} rounds.\n"
25
+ my_project.request_funding(num_rounds.to_i)
26
+ when 'quit', 'exit'
27
+ my_project.print_stats
28
+ break
29
+ else
30
+ puts "Please enter a number or 'quit'"
31
+ end
32
+ end
33
+
34
+ my_project.save_under_funded
35
+
36
+ default_underfunded_file = File.join(File.dirname(__FILE__), 'underfunded_project')
37
+ my_project.save_under_funded(default_underfunded_file)
@@ -0,0 +1,32 @@
1
+ require_relative '../../lib/fund_raise/project'
2
+ require_relative '../../lib/fund_raise/fund_request'
3
+ require_relative '../../lib/fund_raise/grant_project'
4
+ require_relative '../../lib/fund_raise/match_project'
5
+
6
+ my_project = FundRaise::FundRequest.new("VC-Friendly Start-up Projects")
7
+
8
+ grant1 = FundRaise::ProjectGrant.new("Grant A", 5000, 1000)
9
+ match1 = FundRaise::ProjectMatch.new("Match A", 5000, 1000)
10
+
11
+ my_project.add_project(grant1)
12
+ my_project.add_project(match1)
13
+
14
+ default_project_file = File.join(File.dirname(__FILE__), 'project.csv')
15
+ my_project.load_projects(ARGV.shift || default_project_file)
16
+
17
+ loop do
18
+ puts "How many rounds? ('quit' to exit)"
19
+ num_rounds = gets.chomp.downcase
20
+ case num_rounds
21
+ when /^\d+$/
22
+ puts"\nEnjoy your #{num_rounds} rounds.\n"
23
+ my_project.request_funding(num_rounds.to_i)
24
+ when 'quit', 'exit'
25
+ my_project.print_stats
26
+ break
27
+ else
28
+ puts "Please enter a number or 'quit'"
29
+ end
30
+ end
31
+
32
+ my_project.save_under_funded
data/bin/fund_raise~ ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/fund_raise/project'
4
+ require_relative '../lib/fund_raise/fund_request'
5
+ require_relative '../lib/fund_raise/grant_project'
6
+ require_relative '../lib/fund_raise/match_project'
7
+
8
+ my_project = FundRaise::FundRequest.new("VC-Friendly Start-up Projects")
9
+
10
+ grant1 = FundRaise::ProjectGrant.new("Grant A", 5000, 1000)
11
+ match1 = FundRaise::ProjectMatch.new("Match A", 5000, 1000)
12
+
13
+ my_project.add_project(grant1)
14
+ my_project.add_project(match1)
15
+
16
+ default_project_file = File.join(File.dirname(__FILE__), 'project.csv')
17
+ my_project.load_projects(ARGV.shift || default_project_file)
18
+
19
+ loop do
20
+ puts "How many rounds? ('quit' to exit)"
21
+ num_rounds = gets.chomp.downcase
22
+ case num_rounds
23
+ when /^\d+$/
24
+ puts"\nEnjoy your #{num_rounds} rounds.\n"
25
+ my_project.request_funding(num_rounds.to_i)
26
+ when 'quit', 'exit'
27
+ my_project.print_stats
28
+ break
29
+ else
30
+ puts "Please enter a number or 'quit'"
31
+ end
32
+ end
33
+
34
+ my_project.save_under_funded
35
+
36
+ default_underfunded_file = File.join(File.dirname(__FILE__), 'underfunded_project')
37
+ my_project.save_underfunded_projects(default_underfunded_file)
data/bin/project.csv ADDED
@@ -0,0 +1,3 @@
1
+ Project1,5000,1000
2
+ Project2,5000,1000
3
+ Project3,5000,1000
data/bin/project.csv~ ADDED
@@ -0,0 +1,3 @@
1
+ Project1,75,25
2
+ Project2,5000,1000
3
+ Project3,5000,1000
@@ -0,0 +1,6 @@
1
+ VC-Friendly Start-up Projects's Under-funded projects:
2
+ Grant A............. $3675 needed
3
+ Project1............ $3730 needed
4
+ Project2............ $3805 needed
5
+ Project3............ $3805 needed
6
+ Match A............. $4950 needed
@@ -0,0 +1,17 @@
1
+ module FundRaise
2
+ class Die
3
+ attr_reader :number
4
+
5
+ def initialize
6
+ roll
7
+ end
8
+
9
+ def roll
10
+ @number = rand(1..6)
11
+ end
12
+ end
13
+
14
+ if __FILE__ == $0
15
+ puts "this is the first argument passed to the program"
16
+ end
17
+ end
@@ -0,0 +1,106 @@
1
+ module FundRaise
2
+
3
+ require_relative '../../lib/fund_raise/project'
4
+ require_relative '../../lib/fund_raise/funding_round'
5
+ require_relative '../../lib/fund_raise/die'
6
+ require_relative '../../lib/fund_raise/pledge_pool'
7
+
8
+ class FundRequest
9
+ attr_accessor :name
10
+ attr_reader :projects_ar
11
+
12
+ def initialize (mylistname)
13
+ @name = mylistname
14
+ @projects_ar = []
15
+ end
16
+
17
+ def add_project(project)
18
+ @projects_ar.push(project)
19
+ end
20
+
21
+ def load_projects(from_file)
22
+ File.readlines(from_file).each do |line|
23
+ add_project(Project.from_csv(line))
24
+ end
25
+ end
26
+
27
+ def request_funding(rounds)
28
+ PledgePool::print_pledges_available
29
+ puts "Project List: #{@name}:"
30
+
31
+ 1.upto(rounds) do |round|
32
+ puts"\nRound #{round}"
33
+ @projects_ar.each do |project|
34
+ puts project
35
+ FundingRound.one_round(project)
36
+ puts "#{project}\n\n"
37
+ end
38
+ end
39
+ end
40
+
41
+ def save_under_funded(to_file="under_funded.txt")
42
+ File.open(to_file, "w") do |file|
43
+ file.puts "#{@name}'s Under-funded projects:"
44
+
45
+ @projects_ar.sort.each do |p|
46
+ if !p.fully_funded?
47
+ file.puts underfunded_entry(p)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def underfunded_entry(project)
54
+ formatted_name = project.name.ljust(20, '.')
55
+ "#{formatted_name} $#{project.funding_left} needed"
56
+ end
57
+
58
+ def print_stats
59
+ fully, not_fully = @projects_ar.partition { |project| project.fully_funded? }
60
+
61
+ puts "\n#{@name}'s funding:"
62
+
63
+ @projects_ar.sort.each do |p|
64
+ puts "\n#{p.name}'s total funding is $#{p.total_funding}"
65
+ p.each_given_pledge do |pl|
66
+ puts "#{pl.value} total #{pl.name} points"
67
+ end
68
+ end
69
+
70
+ puts "\nThese projects are fully funded:"
71
+ fully.sort.each do |p|
72
+ puts "#{p.name}"
73
+ end
74
+
75
+ puts "\n#{not_fully.size} projects are not fully funded:"
76
+ not_fully.sort.each do |p|
77
+ puts "#{p.name} ($#{p.current_funding})"
78
+ end
79
+
80
+ puts "\n#{not_fully.size} project(s) still need your help:"
81
+ not_fully.sort.each do |p|
82
+ puts "#{p.name} needs #{p.needed_funding} dollars."
83
+ end
84
+ end
85
+
86
+ def to_s
87
+ "There are #{@projects_ar.size} projects in #{@name}."
88
+ end
89
+ end
90
+
91
+ if __FILE__ == $0
92
+ project1 = Project.new("Project ABC", 3000, 500)
93
+ project2 = Project.new("Project LMN", 225, 25)
94
+ project3 = Project.new("Project XYZ", 100, 110)
95
+
96
+
97
+ my_project = FundRequest.new("VC-Friendly Start-up Projects.")
98
+
99
+ my_project.add_project(project1)
100
+ my_project.add_project(project2)
101
+ my_project.add_project(project3)
102
+
103
+ my_project.request_funding
104
+
105
+ end
106
+ end
@@ -0,0 +1,105 @@
1
+ module FundRaise
2
+
3
+ require_relative '../../lib/fund_raise/project'
4
+ require_relative '../../lib/fund_raise/funding_round'
5
+ require_relative '../../lib/fund_raise/die'
6
+ require_relative '../../lib/fund_raise/pledge_pool'
7
+
8
+ class FundRequest
9
+ attr_accessor :name
10
+ attr_reader :projects_ar
11
+
12
+ def initialize (mylistname)
13
+ @name = mylistname
14
+ @projects_ar = []
15
+ end
16
+
17
+ def add_project(project)
18
+ @projects_ar.push(project)
19
+ end
20
+
21
+ def load_projects(from_file)
22
+ File.readlines(from_file).each do |line|
23
+ add_project(Project.from_csv(line))
24
+ end
25
+ end
26
+
27
+ def request_funding(rounds)
28
+ PledgePool::print_pledges_available
29
+ puts "Project List: #{@name}:"
30
+
31
+ 1.upto(rounds) do |round|
32
+ puts"\nRound #{round}"
33
+ @projects_ar.each do |project|
34
+ puts project
35
+ FundingRound.one_round(project)
36
+ puts "#{project}\n\n"
37
+ end
38
+ end
39
+ end
40
+
41
+ def save_under_funded(to_file="under_funded.txt")
42
+ File.open(to_file, "w") do |file|
43
+ file.puts "#{@name}'s Under-funded projects:"
44
+
45
+ @projects_ar.sort.each do |p|
46
+ if !p.fully_funded?
47
+ file.puts underfunded_entry(p)
48
+ end
49
+ end
50
+ end
51
+
52
+ def underfunded_entry(project)
53
+ formatted_name = project.name.ljust(20, '.')
54
+ "#{formatted_name} $#{project.funding_left} needed"
55
+ end
56
+
57
+ def print_stats
58
+ fully, not_fully = @projects_ar.partition { |project| project.fully_funded? }
59
+
60
+ puts "\n#{@name}'s funding:"
61
+
62
+ @projects_ar.sort.each do |p|
63
+ puts "\n#{p.name}'s total funding is $#{p.total_funding}"
64
+ p.each_given_pledge do |pl|
65
+ puts "#{pl.value} total #{pl.name} points"
66
+ end
67
+ end
68
+
69
+ puts "\nThese projects are fully funded:"
70
+ fully.sort.each do |p|
71
+ puts "#{p.name}"
72
+ end
73
+
74
+ puts "\n#{not_fully.size} projects are not fully funded:"
75
+ not_fully.sort.each do |p|
76
+ puts "#{p.name} ($#{p.current_funding})"
77
+ end
78
+
79
+ puts "\n#{not_fully.size} project(s) still need your help:"
80
+ not_fully.sort.each do |p|
81
+ puts "#{p.name} needs #{p.needed_funding} dollars."
82
+ end
83
+ end
84
+
85
+ def to_s
86
+ "There are #{@projects_ar.size} projects in #{@name}."
87
+ end
88
+ end
89
+
90
+ if __FILE__ == $0
91
+ project1 = Project.new("Project ABC", 3000, 500)
92
+ project2 = Project.new("Project LMN", 225, 25)
93
+ project3 = Project.new("Project XYZ", 100, 110)
94
+
95
+
96
+ my_project = FundRequest.new("VC-Friendly Start-up Projects.")
97
+
98
+ my_project.add_project(project1)
99
+ my_project.add_project(project2)
100
+ my_project.add_project(project3)
101
+
102
+ my_project.request_funding
103
+
104
+ end
105
+ end
@@ -0,0 +1,21 @@
1
+ module FundRaise
2
+ module Fundable
3
+ def add_funds(add_funding=25, pledge=false)
4
+ @current_funding += add_funding
5
+ "#{@name} got more funds"
6
+ end
7
+
8
+ def remove_funds(reduce_funding=15)
9
+ @current_funding -= reduce_funding
10
+ "#{@name} lost some funds"
11
+ end
12
+
13
+ def funding_left
14
+ @target_funding - @current_funding
15
+ end
16
+
17
+ def fully_funded?
18
+ funding_left <= 0
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ module FundRaise
2
+
3
+ require_relative '../../lib/fund_raise/fund_request'
4
+ require_relative '../../lib/fund_raise/die'
5
+ require_relative '../../lib/fund_raise/project'
6
+ require_relative '../../lib/fund_raise/pledge_pool'
7
+
8
+ module FundingRound
9
+
10
+ def self.one_round(project)
11
+ die_r = Die.new()
12
+ number = die_r.number
13
+ if number.odd?
14
+ project.remove_funds
15
+ else
16
+ project.add_funds
17
+ end
18
+ project.pledge_received(PledgePool.random)
19
+ end
20
+ end
21
+
22
+ end