horoscope 0.0.6 → 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +1 -0
- data/README.md +3 -0
- data/lib/horoscope.rb +33 -5
- data/lib/horoscope/version.rb +1 -1
- data/spec/horoscope_spec.rb +11 -0
- data/views/horoscope_chart_html.eruby +23 -0
- metadata +8 -13
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODE0NmM0NzI1NzlmODI1ZDEyMTY2ZjA5MzNlYjI1Y2MyYWEzZmRjYQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDg1NmIwNDUxZDA4NTk5MzI2OTE1MzUzYzgyNjY2MGI5MjVlMjhlZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjM2NjI1ZTcyNWIzYmQ2MWQ3N2Y3OTE0Yjc4MzY1ZTAxNDlmNzU1N2EyMDlk
|
10
|
+
ODUyMTdmZGE0ZDE0MTA1ZjM5MzAwODg3OGQ5MTI1OTRjMjM3YzBjNjdhM2Fl
|
11
|
+
Y2I5YjI2YWY3Njg4ZjcxMmYzODVkZTc0NGUxZTI4ZjUwNWViZTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZDA4ZGNmZjc2N2Q5NGEwZTA5M2NhYTljMWZkZmJiMzRmMjM1NzkxODk3M2Q2
|
14
|
+
N2NiY2IyOTUwNWRiZmQ3N2EzYTg2ZjQwNzNmNjJiYTgyYmVkNjVkNzM2MGMx
|
15
|
+
ZWJiZDRmYjFkMGQ5MmY1ZTk5OTg1MTYyODY1MDRhYmRlNDgyZmU=
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
horoscope
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-1.9.3-p484
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,7 @@ Calculate the accurate horoscope of a person using Vedic Horoscope technique giv
|
|
6
6
|
[](https://codeclimate.com/github/bragboy/horoscope)
|
7
7
|
[ ](https://gemnasium.com/bragboy/horoscope)
|
8
8
|
[](https://coveralls.io/r/bragboy/horoscope)
|
9
|
+
[](http://badge.fury.io/rb/horoscope)
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -33,6 +34,8 @@ Then you can start using this by passing a Time object along with latitude and l
|
|
33
34
|
|
34
35
|
h.create_chart #This will generate the horoscope chart to your working directory
|
35
36
|
|
37
|
+
h.create_chart format: :html #This will generate the horoscope chart as html text and can be embedded onto any html container
|
38
|
+
|
36
39
|

|
37
40
|
|
38
41
|
## Contributing
|
data/lib/horoscope.rb
CHANGED
@@ -2,8 +2,13 @@ require 'horoscope/version'
|
|
2
2
|
require 'horoscope/overrides/math_override'
|
3
3
|
require 'horoscope/planet'
|
4
4
|
require 'RMagick'
|
5
|
+
require 'erubis'
|
5
6
|
|
6
7
|
module Horoscope
|
8
|
+
def self.root
|
9
|
+
File.expand_path '../..', __FILE__
|
10
|
+
end
|
11
|
+
|
7
12
|
class Horo
|
8
13
|
|
9
14
|
PLANETS = ["As", "Su", "Mo", "Ma", "Me", "Ju", "Ve", "Sa", "Ra", "Ke"]
|
@@ -74,9 +79,25 @@ module Horoscope
|
|
74
79
|
return @positions
|
75
80
|
end
|
76
81
|
|
77
|
-
def create_chart(options={})
|
78
|
-
|
79
|
-
|
82
|
+
def create_chart(options= {})
|
83
|
+
compute unless @computed
|
84
|
+
case options[:format]
|
85
|
+
when :html
|
86
|
+
draw_chart_as_html
|
87
|
+
else
|
88
|
+
draw_chart_as_png
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def draw_chart_as_html
|
95
|
+
input = File.read('views/horoscope_chart_html.eruby')
|
96
|
+
eval Erubis::Eruby.new.convert(input)
|
97
|
+
end
|
98
|
+
|
99
|
+
def draw_chart_as_png
|
100
|
+
base_chart = Magick::ImageList.new("#{Horoscope.root}/assets/south_chart.png")
|
80
101
|
|
81
102
|
canvas = Magick::ImageList.new
|
82
103
|
canvas.new_image(IMG_SIZE, IMG_SIZE, Magick::TextureFill.new(base_chart))
|
@@ -108,8 +129,6 @@ module Horoscope
|
|
108
129
|
x = canvas.write('output.png')
|
109
130
|
end
|
110
131
|
|
111
|
-
private
|
112
|
-
|
113
132
|
def validate_values
|
114
133
|
@errors = []
|
115
134
|
@errors << ERRORS[:Date] if @datetime.nil? || !@datetime.is_a?(Time) || @datetime.year > 2300 || @datetime.year < 1600
|
@@ -119,5 +138,14 @@ module Horoscope
|
|
119
138
|
@errors
|
120
139
|
end
|
121
140
|
|
141
|
+
def get_planets_at(position)
|
142
|
+
@positions_rev[position].join('<br/>')
|
143
|
+
end
|
144
|
+
|
145
|
+
def date_time_info
|
146
|
+
"#{ @datetime.strftime('%d %b %Y') } <br/> \
|
147
|
+
#{ @datetime.strftime('%I:%M %p') } <br/> \
|
148
|
+
Lat: #{@lat.round(1)}, Lon: #{@lon.round(1)}"
|
149
|
+
end
|
122
150
|
end
|
123
151
|
end
|
data/lib/horoscope/version.rb
CHANGED
data/spec/horoscope_spec.rb
CHANGED
@@ -74,4 +74,15 @@ describe Horoscope do
|
|
74
74
|
h.create_chart
|
75
75
|
expect(File).to exist("output.png")
|
76
76
|
end
|
77
|
+
|
78
|
+
it "can generate chart as html" do
|
79
|
+
h = Horoscope::Horo.new(:datetime => Time.utc(1973, 4, 24, 14, 25), :zone => 5.5, :lat => 18.60, :lon => -72.50)
|
80
|
+
h.compute
|
81
|
+
chart_html = h.create_chart format: :html
|
82
|
+
chart_html.should match("<td style = \"width:25%\" cell_index = \"0\">Su<br/>Ve</td>")
|
83
|
+
chart_html.should match("<td style = \"width:25%\" cell_index = \"4\">As</td>")
|
84
|
+
chart_html.should match("<td style = \"width:25%\" cell_index = \"11\">Me</td>")
|
85
|
+
chart_html.should match("<td style = \"width:25%\" cell_index = \"1\">Sa</td>")
|
86
|
+
chart_html.should match("<td style = \"width:25%\" cell_index = \"8\">Mo<br/>Ra</td>")
|
87
|
+
end
|
77
88
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<table style = "text-align:center;width:100%;height:100%;" border = "1">
|
2
|
+
<tr>
|
3
|
+
<td style = "width:25%" cell_index = "11"><%= get_planets_at(11) %></td>
|
4
|
+
<td style = "width:25%" cell_index = "0"><%= get_planets_at(0) %></td>
|
5
|
+
<td style = "width:25%" cell_index = "1"><%= get_planets_at(1) %></td>
|
6
|
+
<td style = "width:25%" cell_index = "2"><%= get_planets_at(2) %></td>
|
7
|
+
</tr>
|
8
|
+
<tr>
|
9
|
+
<td style = "width:25%" cell_index = "10"><%= get_planets_at(10) %></td>
|
10
|
+
<td colspan = "2" rowspan = "2"><%= date_time_info %></td>
|
11
|
+
<td style = "width:25%" cell_index = "3"><%= get_planets_at(3) %></td>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td style = "width:25%" cell_index = "9"><%= get_planets_at(9) %></td>
|
15
|
+
<td style = "width:25%" cell_index = "4"><%= get_planets_at(4) %></td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td style = "width:25%" cell_index = "8"><%= get_planets_at(8) %></td>
|
19
|
+
<td style = "width:25%" cell_index = "7"><%= get_planets_at(7) %></td>
|
20
|
+
<td style = "width:25%" cell_index = "6"><%= get_planets_at(6) %></td>
|
21
|
+
<td style = "width:25%" cell_index = "5"><%= get_planets_at(5) %></td>
|
22
|
+
</tr>
|
23
|
+
</table>
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: horoscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: '1.0'
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- bragboy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: debugger
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rmagick
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -69,6 +62,8 @@ files:
|
|
69
62
|
- .coveralls.yml
|
70
63
|
- .gitignore
|
71
64
|
- .rspec
|
65
|
+
- .ruby-gemset
|
66
|
+
- .ruby-version
|
72
67
|
- .travis.yml
|
73
68
|
- Gemfile
|
74
69
|
- LICENSE.txt
|
@@ -90,29 +85,29 @@ files:
|
|
90
85
|
- lib/horoscope/version.rb
|
91
86
|
- spec/horoscope_spec.rb
|
92
87
|
- spec/spec_helper.rb
|
88
|
+
- views/horoscope_chart_html.eruby
|
93
89
|
homepage: https://github.com/bragboy/horoscope
|
94
90
|
licenses: []
|
91
|
+
metadata: {}
|
95
92
|
post_install_message:
|
96
93
|
rdoc_options: []
|
97
94
|
require_paths:
|
98
95
|
- lib
|
99
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
97
|
requirements:
|
102
98
|
- - ! '>='
|
103
99
|
- !ruby/object:Gem::Version
|
104
100
|
version: '0'
|
105
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
102
|
requirements:
|
108
103
|
- - ! '>='
|
109
104
|
- !ruby/object:Gem::Version
|
110
105
|
version: '0'
|
111
106
|
requirements: []
|
112
107
|
rubyforge_project:
|
113
|
-
rubygems_version:
|
108
|
+
rubygems_version: 2.2.1
|
114
109
|
signing_key:
|
115
|
-
specification_version:
|
110
|
+
specification_version: 4
|
116
111
|
summary: Calculate the accurate horoscope of a person using Vedic Horoscope technique
|
117
112
|
given the birth time and birth place of the subject.
|
118
113
|
test_files:
|