stockfolio 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/stockfolio.rb +5 -6
- data/lib/stockfolio/version.rb +1 -1
- metadata +3 -4
- data/lib/stockfolio/consolegraph.rb +0 -52
data/lib/stockfolio.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'data_mapper' # requires all the gems listed above
|
2
2
|
require 'dm-migrations'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require_relative 'stockfolio/formatters'
|
4
|
+
require File.join(File.dirname(__FILE__), 'stockfolio/portfolio')
|
5
|
+
require File.join(File.dirname(__FILE__), 'stockfolio/transaction')
|
6
|
+
require File.join(File.dirname(__FILE__), 'stockfolio/watchlist')
|
7
|
+
require File.join(File.dirname(__FILE__), 'stockfolio/formatters')
|
9
8
|
|
10
9
|
module StockFolio
|
11
10
|
autoload :Runner, 'stockfolio/runner'
|
@@ -20,7 +19,7 @@ rcfile = ENV['STOCKFOLIO_YML'] || Dir.home + '/.stockfolio.yml'
|
|
20
19
|
if File.exists?(rcfile)
|
21
20
|
config = YAML::load(File.open(rcfile))
|
22
21
|
ENV['STOCKFOLIO_DB'] = config['db'] || nil
|
23
|
-
if (config[:database])
|
22
|
+
if (config[:database])
|
24
23
|
ENV['STOCKFOLIO_DB'] = config[:database][:location] || nil
|
25
24
|
end
|
26
25
|
end
|
data/lib/stockfolio/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stockfolio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: boson
|
@@ -131,7 +131,6 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- lib/stockfolio/check.rb
|
134
|
-
- lib/stockfolio/consolegraph.rb
|
135
134
|
- lib/stockfolio/formatters.rb
|
136
135
|
- lib/stockfolio/portfolio.rb
|
137
136
|
- lib/stockfolio/runner.rb
|
@@ -162,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
161
|
version: '0'
|
163
162
|
requirements: []
|
164
163
|
rubyforge_project:
|
165
|
-
rubygems_version: 1.8.
|
164
|
+
rubygems_version: 1.8.25
|
166
165
|
signing_key:
|
167
166
|
specification_version: 3
|
168
167
|
summary: Track stock portfolio from the command line
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module StockFolio
|
2
|
-
class ConsoleGraph
|
3
|
-
|
4
|
-
def initialize(values)
|
5
|
-
@height = 25
|
6
|
-
@width = 120
|
7
|
-
|
8
|
-
min = nil
|
9
|
-
max = nil
|
10
|
-
values.each do |value|
|
11
|
-
value = value.to_f
|
12
|
-
min = nil == min ? value : min
|
13
|
-
max = nil == max ? value : max
|
14
|
-
|
15
|
-
min = value < min ? value : min
|
16
|
-
max = value > max ? value : max
|
17
|
-
end
|
18
|
-
|
19
|
-
heights = []
|
20
|
-
values.each do |value|
|
21
|
-
heights << (value.to_f * @height / max)
|
22
|
-
end
|
23
|
-
|
24
|
-
matrix = []
|
25
|
-
0.upto(@height) do |i|
|
26
|
-
j = 0
|
27
|
-
matrix[i] = []
|
28
|
-
heights.each do |height|
|
29
|
-
if height >= i
|
30
|
-
matrix[i][j] = true
|
31
|
-
else
|
32
|
-
matrix[i][j] = false
|
33
|
-
end
|
34
|
-
j = j + 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
# Draw now
|
40
|
-
puts ' ^'
|
41
|
-
matrix.reverse!
|
42
|
-
matrix.each do |row|
|
43
|
-
line = ' |' + row.map { |f| f ? "*" : " " }.join('')
|
44
|
-
puts line
|
45
|
-
end
|
46
|
-
puts ' +' + '-' * values.length + '>'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
#StockFolio::ConsoleGraph.new([1,2,3,4,5,6,7,8,9,10,9,8,7,7,6,5,4,3,2,1])
|