crowdfund_alf 1.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: b67560beb0702e435c7b1f13897b2b55b0a4a1c7
4
+ data.tar.gz: 7f46a742986c74af55b746ad0e7af19840f83047
5
+ SHA512:
6
+ metadata.gz: aa550d70b1208c7d9796bd7bf4a0af9d3c043bd89613b1411d14f757f25bb8d0165444e66ec102e67cf7bffde58b73bb2fa4b4d348c6783a0427cca6d4db39d7
7
+ data.tar.gz: 67ae48e2f8259f60252d3546df32158d51fc3194cb84f3a47bdbb46f73d97d6e60512e092ee5b3d17bae969ed8dbe20a3cc6380c6b2fbee549303ff4a1c61b57
data/LICENSE ADDED
@@ -0,0 +1 @@
1
+ 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
+ Crowdfunding project
data/bin/crowdfund ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/crowdfund/vc'
4
+ require_relative '../lib/crowdfund/grand_project'
5
+
6
+ # project1 = Project.new("XYZ", 500, 5000, 10000)
7
+ # project2 = Project.new("LMN", 200, 25000, 50000)
8
+ # project3 = Project.new("ABC", 1200, 500, 1000)
9
+
10
+ vc = Crowdfund::VentureCapital.new("alf's")
11
+ default_load_path = File.join(File.dirname(__FILE__), 'user_projects.csv')
12
+
13
+ vc.load_projects( ARGV.shift || default_load_path)
14
+
15
+ grand = Crowdfund::GrandProject.new("YYY", 0, 500, 1000)
16
+ vc.add_project(grand)
17
+
18
+
19
+ loop do
20
+ puts "Please enter how many rounds of funding ('quit' to exit)"
21
+ response = gets.chomp
22
+ case response
23
+ when /^\d+$/
24
+ vc.request_funding(response.to_i)
25
+ vc.print_stats
26
+ when 'exit', 'quit'
27
+ break
28
+ else
29
+ puts "Please enter a number or quit"
30
+ end
31
+ end
32
+
33
+ vc.save_projects('projects_funding.csv')
34
+
35
+
@@ -0,0 +1,42 @@
1
+ require 'crowdfund/pledge_fund'
2
+
3
+ module Crowdfund
4
+ describe Pledge do
5
+ before do
6
+ @initial_name = "Gold"
7
+ @initial_amount = 1000
8
+ @pledge = Pledge.new(@initial_name, @initial_amount)
9
+ end
10
+
11
+ it "has a name attribute" do
12
+ expect(@pledge.name).to eq(@initial_name)
13
+ end
14
+
15
+ it "has an amount attribute" do
16
+ expect(@pledge.amount).to eq(@initial_amount)
17
+ end
18
+ end
19
+
20
+ describe PledgeFund do
21
+
22
+ it "gold inside pledges worth $1000" do
23
+ expect(PledgeFund::PLEDGES[0].amount).to eq(1000)
24
+ end
25
+
26
+ it "silver inside pledges worth $500" do
27
+ expect(PledgeFund::PLEDGES[1].amount).to eq(500)
28
+ end
29
+
30
+ it "bronze inside pledges worth $250" do
31
+ expect(PledgeFund::PLEDGES[2].amount).to eq(250)
32
+ end
33
+
34
+ it "generate random pledge successfuly" do
35
+ pledge = PledgeFund.random
36
+ expect(PledgeFund::PLEDGES).to include(pledge)
37
+ end
38
+
39
+
40
+
41
+ end
42
+ end
@@ -0,0 +1,69 @@
1
+ require 'crowdfund/project'
2
+
3
+ module Crowdfund
4
+ describe Project do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ @initial_funds = 500
9
+ @initial_minimum = 2000
10
+ @initial_target = 5000
11
+ @project = Project.new("XYZ", @initial_funds, @initial_minimum, @initial_target)
12
+ end
13
+
14
+ it "Has an initial value of funds" do
15
+ expect(@project.funds).to eq(@initial_funds)
16
+ end
17
+
18
+ it "has a string representation" do
19
+ expect(@project.to_s).to eq("Project #{@project.name} has $#{@project.funds} towards a goal of $#{@project.target}")
20
+ end
21
+
22
+ it "has a total amount of fund still needed" do
23
+ expect(@project.funding_still_needed).to eq(@initial_target - @initial_funds)
24
+
25
+ end
26
+
27
+ it "Increase the funding by 25 when adding fund" do
28
+ @project.add_funds
29
+ expect(@project.funds).to eq(@initial_funds + 25)
30
+
31
+ end
32
+
33
+ it "Decrease the funding by 15 when deleting fund" do
34
+ @project.remove_funds
35
+ expect(@project.funds).to eq(@initial_funds - 15)
36
+ end
37
+
38
+ context "Project with default parameter" do
39
+ before do
40
+ @project = Project.new("XYZ", 500, 1000)
41
+ end
42
+
43
+ it "Has an default funding of 0" do
44
+ expect(@project.funds).to eq(0)
45
+ end
46
+ end
47
+
48
+ context "Project with parameters of funded" do
49
+ before do
50
+ @project = Project.new("XYZ", 1000, 500, 1000)
51
+ end
52
+
53
+ it "is funded" do
54
+ expect(@project).to be_fully_funded
55
+ end
56
+ end
57
+
58
+ context "Project with parameters of not funded" do
59
+ before do
60
+ @project = Project.new("RYZ", 0, 100, 5000)
61
+ end
62
+
63
+ it "is not funded" do
64
+ expect(@project).not_to be_fully_funded
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,33 @@
1
+ require 'crowdfund/vc'
2
+
3
+ module Crowdfund
4
+ describe VentureCapital do
5
+ before do
6
+ $stdout = StringIO.new
7
+ @vc = VentureCapital.new("Alf's")
8
+ @initial_funds = 0
9
+ @project = Project.new("XYZ", @initial_funds, 500, 10000)
10
+ @vc.add_project(@project)
11
+ end
12
+
13
+ it "increase the funding of a project when high number is rolled" do
14
+ expect_any_instance_of(Die).to receive(:roll).and_return(5)
15
+ @vc.request_funding
16
+ expect(@project.funds).to eq(@initial_funds + 25)
17
+ end
18
+
19
+ it "skips the funding of a project when the medium number is rolled" do
20
+ expect_any_instance_of(Die).to receive(:roll).and_return(3)
21
+ @vc.request_funding
22
+ expect(@project.funds).to eq(@initial_funds)
23
+ end
24
+
25
+ it "decrease the funding of a project when low number is rolled" do
26
+ expect_any_instance_of(Die).to receive(:roll).and_return(1)
27
+ @vc.request_funding
28
+ expect(@project.funds).to eq(@initial_funds - 15)
29
+ end
30
+
31
+
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crowdfund_alf
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Alfian Losari
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-16 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: Crowdfunding project
28
+ email: alfian@losari.org
29
+ executables:
30
+ - crowdfund
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README
36
+ - bin/crowdfund
37
+ - spec/crowdfund/pledge_fund_spec.rb
38
+ - spec/crowdfund/project_spec.rb
39
+ - spec/crowdfund/vc_spec.rb
40
+ homepage: http://www.thebytestech.com
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '1.9'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.2.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Crowdfund
64
+ test_files:
65
+ - spec/crowdfund/pledge_fund_spec.rb
66
+ - spec/crowdfund/project_spec.rb
67
+ - spec/crowdfund/vc_spec.rb