prayer_times 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc0996688ff5201c4e183a45361a1a4f5beb66d1
4
- data.tar.gz: 086cf6bc3b0c3ca73152ae665c67d0a2545eb45e
3
+ metadata.gz: 9e89b6c2230b659b3b2fd707ba5a3c194d65033b
4
+ data.tar.gz: faa3a09be325715ae026b46db68843e541621e28
5
5
  SHA512:
6
- metadata.gz: 6bbf9b0ab8fa8ce1e41a0b9bbef676b9165bf51c341de57882acee751c68f1675093609336086215b3da02f24ca5b7131f26f9467611ad6dfc491d7f6035f59d
7
- data.tar.gz: d2815e18826c25882274f407532b2aa0e2e684b59898f37b2484d6c944466ab1bb8216410c26ee4a1c4896e7cf2738af558d1d067321af41f0e7bad2a518a38a
6
+ metadata.gz: 8e9e13fe01d692a5cd75b7ee19f3a88073828a2a434c3968bb3db95412dac5b043e8f972cee7090440ce93f5dd2c4e981f8050b766376ff654bb615d2e978c6d
7
+ data.tar.gz: c8a69236937c91491578b4f27d54e7807c106c6ac1603dfa7512a959407e09d5100a0ec9f029a4082ebe1e162494757f22580624f3173273f133bb59db7c22ce
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # PrayerTimes
1
+ PrayerTimes [![Build Status](https://travis-ci.org/Startappz/prayer_times.png?branch=master)](https://travis-ci.org/Startappz/prayer_times) [![Dependency Status](https://gemnasium.com/Startappz/prayer_times.png)](https://gemnasium.com/Startappz/prayer_times) [![Coverage Status](https://coveralls.io/repos/Startappz/prayer_times/badge.png)](https://coveralls.io/r/Startappz/prayer_times)
2
+ ===
2
3
 
3
4
  Flexible and configurable calculation for Muslim prayers times.
4
5
 
@@ -22,9 +23,9 @@ Or install it yourself as:
22
23
 
23
24
  ```ruby
24
25
  require 'prayer_times'
25
- pt = PrayerTimes.new("Makkah")
26
- times = pt.get_times(Date.today(), [31,36], 3)
27
- puts times.inspect
26
+ pt = PrayerTimes.new("Makkah") # there are several calculation methods, check adding more methods
27
+ times = pt.get_times(Date.today, [31,36], 3)
28
+ p times
28
29
  ```
29
30
 
30
31
  ### Global configuration
@@ -5,8 +5,13 @@ module PrayerTimes
5
5
  extend Forwardable
6
6
  include MathHelpers
7
7
 
8
+ SunPosition = Struct.new(:declination, :equation)
9
+
10
+ MINUTE = 60
11
+ DEGREES_PER_HOUR = 15.0
12
+
8
13
  def_delegators :@calculator, :time_suffixes, :time_format, :invalid_time, :iterations_count, :times_offsets
9
-
14
+
10
15
  # Gets the prayers times
11
16
  # @param [PrayTime] calculator parent class
12
17
  # @param [Date] date the desired date
@@ -19,45 +24,45 @@ module PrayerTimes
19
24
  self.lng = coords[1]
20
25
  self.elv = coords.size > 2 ? coords[2] : 0
21
26
  self.time_zone = time_zone
22
- date = Date.new(date[0], date[1], date[2]) unless date.is_a? Date
23
- self.jdate = date.ajd.to_f - lng / (15 * 24.0)
24
- end
27
+ self.jdate = julian_date(date) - lng / (360.0)
28
+ self.times = {
29
+ imsak: 5, fajr: 5, sunrise: 6, dhuhr: 12, asr: 13,
30
+ sunset: 18, maghrib: 18, isha: 18
31
+ }
32
+ end
25
33
 
26
34
  # Compute prayer times
27
35
  # @return [Hash] times
28
36
  def compute
29
- times = {
30
- imsak: 5, fajr: 5, sunrise: 6, dhuhr: 12,
31
- asr: 13, sunset: 18, maghrib: 18, isha: 18
32
- }
33
37
  # main iterations
34
- iterations_count.times{times = compute_prayer_times(times)}
35
- times = adjust_times(times)
38
+ iterations_count.times{compute_prayer_times}
36
39
 
37
- # add midnight time
38
- if method_settings[:midnight] == 'Jafari'
39
- times[:midnight] = times[:sunset] + time_diff(times[:sunset], times[:fajr]) / 2
40
- else
41
- times[:midnight] = times[:sunset] + time_diff(times[:sunset], times[:sunrise]) / 2
42
- end
40
+ adjust_times
41
+
42
+ tune_times
43
+
44
+ modify_formats
43
45
 
44
- times = tune_times(times)
45
- modify_formats(times)
46
- set_names(times)
47
- end
46
+ set_names
47
+ end
48
48
 
49
- private
49
+ private
50
50
 
51
- attr_accessor :calculator, :time_zone, :lat, :lng, :elv, :jdate
51
+ attr_accessor :calculator, :time_zone, :lat, :lng, :elv, :jdate, :times
52
52
 
53
+ # get julian date of date object or array
54
+ def julian_date(date)
55
+ date_obj = date.is_a?(Date) ? date : Date.new(date[0], date[1], date[2])
56
+ date_obj.ajd.to_f
57
+ end
53
58
 
54
59
  # convert float time to the given format (see time_formats)
55
60
  def get_formatted_time(time)
56
61
  return invalid_time if time.nan?
57
62
  return time if time_format == 'Float'
58
- time = fix_hour(time + 0.5 / 60) # add 0.5 minutes to round
63
+ time = fix_hour(time + 0.5 / self.class::MINUTE) # add 0.5 minutes to round
59
64
  hours = time.floor
60
- minutes = ((time - hours) * 60).floor
65
+ minutes = ((time - hours) * self.class::MINUTE).floor
61
66
  suffix = time_format == '12h' ? time_suffixes[hours < 12 ? :am : :pm ] : ''
62
67
  formatted_time = (time_format == "24h") ? ("%02d:%02d" % [hours, minutes]) : "%d:%02d" % [((hours + 11) % 12)+1, minutes]
63
68
  formatted_time + suffix
@@ -65,15 +70,15 @@ module PrayerTimes
65
70
 
66
71
  # compute mid-day time
67
72
  def mid_day(time)
68
- eqt = sun_position(jdate + time)[1]
69
- fix_hour(12 - eqt)
73
+ eqt = sun_position(jdate + time).equation
74
+ fix_hour(12 - eqt)
70
75
  end
71
-
72
- # compute the time at which sun reaches a specific angle below horizon
76
+
77
+ # compute the time at which sun reaches a specific angle below horizon
73
78
  def sun_angle_time(angle, time, direction = nil)
74
- decl = sun_position(jdate + time)[0]
79
+ decl = sun_position(jdate + time).declination
75
80
  noon = mid_day(time)
76
- t = 1/15.0 * darccos((-rsin(angle)- rsin(decl)* rsin(lat))/
81
+ t = 1.0 / self.class::DEGREES_PER_HOUR * darccos((-rsin(angle)- rsin(decl)* rsin(lat))/
77
82
  (rcos(decl) * rcos(lat)))
78
83
  return noon + (direction == 'ccw' ? -t : t)
79
84
  rescue
@@ -81,16 +86,16 @@ module PrayerTimes
81
86
  end
82
87
 
83
88
  # compute asr time
84
- def asr_time(factor, time)
85
- decl = sun_position(jdate + time)[0]
89
+ def asr_time(factor, time)
90
+ decl = sun_position(jdate + time).declination
86
91
  angle = -darccot(factor + rtan(lat - decl).abs)
87
- sun_angle_time(angle, time)
92
+ sun_angle_time(angle, time)
88
93
  end
89
94
 
90
95
  # compute declination angle of sun and equation of time
91
96
  # Ref: http://aa.usno.navy.mil/faq/docs/SunApprox.php
92
- def sun_position(jd)
93
- d = jd - 2451545.0
97
+ def sun_position(julian_date)
98
+ d = julian_date - 2451545.0
94
99
  g = fix_angle(357.529 + 0.98560028 * d)
95
100
  q = fix_angle(280.459 + 0.98564736 * d)
96
101
  l = fix_angle(q + 1.915* rsin(g) + 0.020* rsin(2*g))
@@ -98,51 +103,71 @@ module PrayerTimes
98
103
  #r = 1.00014 - 0.01671 * cos(g) - 0.00014 * cos(2*g)
99
104
  e = 23.439 - 0.00000036 * d
100
105
 
101
- ra = darctan2(rcos(e)* rsin(l), rcos(l))/ 15.0
102
- eqt = q / 15.0 - fix_hour(ra)
103
- decl = darcsin(rsin(e)* rsin(l))
106
+ ra = darctan2(rcos(e)* rsin(l), rcos(l))/ self.class::DEGREES_PER_HOUR
107
+ equation = q / self.class::DEGREES_PER_HOUR - fix_hour(ra) # equation of time
108
+ declination = darcsin(rsin(e)* rsin(l)) # declination of the Sun
104
109
 
105
- [decl, eqt]
110
+ SunPosition.new(declination,equation)
106
111
  end
107
112
 
108
113
 
109
114
  # compute prayer times at given julian date
110
- def compute_prayer_times(times)
111
- day_portion(times)
112
- {
113
- imsak: sun_angle_time(method_settings[:imsak].to_f, times[:imsak], 'ccw'),
114
- fajr: sun_angle_time(method_settings[:fajr].to_f, times[:fajr], 'ccw'),
115
- sunrise: sun_angle_time(rise_set_angle(elv), times[:sunrise], 'ccw'),
116
- dhuhr: mid_day(times[:dhuhr]),
117
- asr: asr_time(asr_factor(method_settings[:asr]), times[:asr]),
118
- sunset: sun_angle_time(rise_set_angle(elv), times[:sunset]),
119
- maghrib: sun_angle_time(method_settings[:maghrib].to_f, times[:maghrib]),
120
- isha: sun_angle_time(method_settings[:isha].to_f, times[:isha])
121
- }
115
+ def compute_prayer_times
116
+ day_portion
117
+
118
+ initial_computation
119
+ end
120
+
121
+ # make the primary calculations
122
+ def initial_computation
123
+ times.merge!(
124
+ imsak: sun_angle_time(method_settings[:imsak].to_f, times[:imsak], 'ccw'),
125
+ fajr: sun_angle_time(method_settings[:fajr].to_f, times[:fajr], 'ccw'),
126
+ sunrise: sun_angle_time(rise_set_angle(elv), times[:sunrise], 'ccw'),
127
+ dhuhr: mid_day(times[:dhuhr]),
128
+ asr: asr_time(asr_factor(method_settings[:asr]), times[:asr]),
129
+ sunset: sun_angle_time(rise_set_angle(elv), times[:sunset]),
130
+ maghrib: sun_angle_time(method_settings[:maghrib].to_f, times[:maghrib]),
131
+ isha: sun_angle_time(method_settings[:isha].to_f, times[:isha])
132
+ )
122
133
  end
123
134
 
124
135
  # adjust times in a prayer time array
125
- def adjust_times(times)
126
- tz_adjust = time_zone - lng / 15.0
127
- times.keys.each{|k| times[k] += tz_adjust}
136
+ def adjust_times
137
+
138
+ adjust_time_zones
139
+
128
140
  if !method_settings[:high_lats].nil?
129
- times = adjust_high_lats(times)
141
+ adjust_high_lats
130
142
  end
131
143
 
132
144
  if minute?(method_settings[:imsak])
133
- times[:imsak] = times[:fajr] - method_settings[:imsak].to_f / 60.0
145
+ times[:imsak] = times[:fajr] - method_settings[:imsak].to_f / self.class::MINUTE
134
146
  end
147
+
135
148
  # need to ask about 'min' settings
136
149
  if minute?(method_settings[:maghrib])
137
- times[:maghrib] = times[:sunset] + method_settings[:maghrib].to_f / 60.0
150
+ times[:maghrib] = times[:sunset] + method_settings[:maghrib].to_f / self.class::MINUTE
138
151
  end
152
+
139
153
  if minute?(method_settings[:isha])
140
- times[:isha] = times[:maghrib] + method_settings[:isha].to_f / 60.0
154
+ times[:isha] = times[:maghrib] + method_settings[:isha].to_f / self.class::MINUTE
141
155
  end
142
156
 
143
- times[:dhuhr] += method_settings[:dhuhr].to_f / 60.0
157
+ times[:dhuhr] += method_settings[:dhuhr].to_f / self.class::MINUTE
144
158
 
145
- return times
159
+ # add midnight time
160
+ if method_settings[:midnight] == 'Jafari'
161
+ times[:midnight] = times[:sunset] + time_diff(times[:sunset], times[:fajr]) / 2
162
+ else
163
+ times[:midnight] = times[:sunset] + time_diff(times[:sunset], times[:sunrise]) / 2
164
+ end
165
+ end
166
+
167
+ # adjust time zones
168
+ def adjust_time_zones
169
+ tz_adjust = time_zone - lng / self.class::DEGREES_PER_HOUR
170
+ times.keys.each{|k| times[k] += tz_adjust}
146
171
  end
147
172
 
148
173
  # get asr shadow factor
@@ -157,29 +182,28 @@ module PrayerTimes
157
182
  end
158
183
 
159
184
  # apply offsets to the times
160
- def tune_times(times)
161
- times.each{|k,_| times[k] += (method_offsets[k] + times_offsets[k]) / 60.0}
185
+ def tune_times
186
+ times.each{|k,_| times[k] += (method_offsets[k] + times_offsets[k]).to_f / self.class::MINUTE}
162
187
  end
163
188
 
164
189
  # convert times to given time format
165
- def modify_formats(times)
190
+ def modify_formats
166
191
  times.each{|k,_| times[k] = get_formatted_time(times[k])}
167
192
  end
168
-
169
- def set_names(times)
193
+
194
+ def set_names
170
195
  res = {}
171
196
  calculator.times_names.each{|k,v| res[v] = times[k]}
172
197
  res
173
198
  end
174
199
 
175
200
  # adjust times for locations in higher latitudes
176
- def adjust_high_lats(times)
201
+ def adjust_high_lats
177
202
  night_time = time_diff(times[:sunset], times[:sunrise]) # sunset to sunrise
178
203
  times[:imsak] = adjust_hl_time(times[:imsak], times[:sunrise], method_settings[:imsak].to_f, night_time, 'ccw')
179
204
  times[:fajr] = adjust_hl_time(times[:fajr], times[:sunrise], method_settings[:fajr].to_f, night_time, 'ccw')
180
205
  times[:isha] = adjust_hl_time(times[:isha], times[:sunset], method_settings[:isha].to_f, night_time)
181
206
  times[:maghrib] = adjust_hl_time(times[:maghrib], times[:sunset], method_settings[:maghrib].to_f, night_time)
182
- times
183
207
  end
184
208
 
185
209
  # adjust a time for higher latitudes
@@ -195,27 +219,25 @@ module PrayerTimes
195
219
  # the night portion used for adjusting times in higher latitudes
196
220
  def night_portion(angle, night)
197
221
  hl_method = method_settings[:high_lats]
198
- portion = 1/2.0 # midnight
199
- portion = 1/60.0 * angle if hl_method == 'AngleBased'
200
- portion = 1/7.0 if hl_method == 'OneSeventh'
201
- portion * night
202
- end
222
+ portion = 1.0 / 2 # midnight
223
+ portion = 1.0 / self.class::MINUTE * angle if hl_method == 'AngleBased'
224
+ portion = 1.0 / 7 if hl_method == 'OneSeventh'
225
+ portion * night
226
+ end
203
227
 
204
228
  # convert hours to day portions
205
- def day_portion(times)
229
+ def day_portion
206
230
  times.each{|k,v| times[k] = times[k] / 24.0}
207
231
  end
208
-
232
+
209
233
  # compute the difference between two times
210
234
  def time_diff(time1, time2); fix_hour(time2 - time1); end
211
235
 
212
-
213
236
  # detect if input contains 'min'
214
237
  def minute?(arg); arg.to_s.include? "min"; end
215
238
 
216
239
  def fix_hour(hour); fix(hour, 24.0) ; end
217
240
 
218
-
219
241
  def fix_angle(angle); fix(angle, 360.0) ; end
220
242
 
221
243
  def fix(a, mode)
@@ -223,15 +245,15 @@ module PrayerTimes
223
245
  a = a - mode * (a / mode).floor
224
246
  a < 0 ? a + mode : a
225
247
  end
226
-
248
+
227
249
  def method_settings
228
250
  @m_settings ||= calculator.calculation_method.settings
229
251
  end
230
-
252
+
231
253
  def method_offsets
232
254
  @m_offsets ||= calculator.calculation_method.offsets
233
255
  end
234
256
 
235
257
  end
236
258
 
237
- end
259
+ end
@@ -4,7 +4,7 @@ module PrayerTimes
4
4
  class CalculationMethod
5
5
  attr_reader :name, :description, :settings, :offsets
6
6
  attr_writer :description
7
-
7
+
8
8
  # Default settings
9
9
  def self.default_settings
10
10
  {
@@ -16,28 +16,28 @@ module PrayerTimes
16
16
  high_lats: 'NightMiddle'
17
17
  }
18
18
  end
19
-
19
+
20
20
  # Initializer
21
21
  # @param [String] name
22
- # @param [String] description
23
- # @param [Hash] settings
22
+ # @param [String] description
23
+ # @param [Hash] settings
24
24
  # @option settings [String] :imsak
25
25
  # @option settings [String] :fajr
26
26
  # @option settings [String] :sunrise
27
27
  # @option settings [String] :dhuhr
28
28
  # @option settings [String] :asr Asr Juristic Methods:
29
- # 'Standard': Shafi`i, Maliki, Ja`fari and Hanbali,
29
+ # 'Standard': Shafi`i, Maliki, Ja`fari and Hanbali,
30
30
  # 'Hanafi': Hanafi
31
31
  # @option settings [String] :sunset
32
32
  # @option settings [String] :maghrib
33
33
  # @option settings [String] :isha
34
34
  # @option settings [String] :midnight Midnight Mode:
35
- # 'Standard': Mid Sunset to Sunrise,
36
- # 'Jafari': Mid Sunset to Fajr
35
+ # 'Standard': Mid Sunset to Sunrise,
36
+ # 'Jafari': Mid Sunset to Fajr
37
37
  # @option settings [String] :high_lights Adjust Methods for Higher Latitudes:
38
- # 'NightMiddle': middle of night,
39
- # 'AngleBased': angle/60th of night,
40
- # 'OneSeventh': 1/7th of night,
38
+ # 'NightMiddle': middle of night,
39
+ # 'AngleBased': angle/60th of night,
40
+ # 'OneSeventh': 1/7th of night,
41
41
  # 'None'
42
42
  # @param [Hash] offsets
43
43
  # @option offsets [String] :imsak
@@ -55,32 +55,33 @@ module PrayerTimes
55
55
  self.settings = settings
56
56
  self.offsets = offsets
57
57
  end
58
-
58
+
59
59
  # Sets times settings
60
60
  # @param [Hash] settings
61
- # Check the initializer
61
+ # Check the initializer
62
62
  def settings=(settings)
63
63
  s = settings.reject{|k,v| !(Constants.times_names.key?(k))} rescue {}
64
- @settings = self.class.default_settings.merge(s)
64
+ @settings = self.class.default_settings.merge(s)
65
65
  end
66
-
66
+
67
67
  # Sets times offsets
68
68
  # @param [Hash] offsets
69
- # Check the initializer
69
+ # Check the initializer
70
70
  def offsets=(offsets)
71
71
  s = offsets.reject{|k,v| !(Constants.times_offsets.key?(k) and v.is_a?(Numeric))} rescue {}
72
- @offsets = Constants.times_offsets.merge(s)
72
+ s[:sunset] = s[:maghrib] if s[:maghrib]
73
+ @offsets = Constants.times_offsets.merge(s)
73
74
  end
74
-
75
-
75
+
76
+
76
77
  # @return readable representation of this object
77
78
  def to_s
78
79
  name
79
80
  end
80
-
81
+
81
82
  private
82
-
83
+
83
84
  attr_writer :name
84
-
85
+
85
86
  end
86
- end
87
+ end
@@ -4,7 +4,7 @@ module PrayerTimes
4
4
  class CalculationMethods
5
5
  extend Forwardable
6
6
  def_delegators :@hash, :[], :length, :each, :key?, :keys, :delete, :to_s
7
-
7
+
8
8
  # default methods defined in this gem
9
9
  # Methods MWL, ISNA, Egypt, Makkah, Karachi, Tehran and Jafari are accurate
10
10
  # Other methods need validation. Your help is appreciated.
@@ -14,7 +14,7 @@ module PrayerTimes
14
14
  desc: 'Muslim World League',
15
15
  settings: {fajr: 18, isha: 17}
16
16
  },
17
- 'ISNA' => {
17
+ 'ISNA' => {
18
18
  desc: 'Islamic Society of North America (ISNA)',
19
19
  settings: {fajr: 15, isha: 15}
20
20
  },
@@ -23,24 +23,24 @@ module PrayerTimes
23
23
  settings: {fajr: 19.5, isha: 17.5}
24
24
  },
25
25
  'Makkah' => {
26
- desc: 'Umm Al-Qura University, Makkah',
27
- settings: {fajr: 18.5, isha: '90 min'} # fajr was 19 degrees before 1430 hijri
26
+ desc: 'Umm Al-Qura University, Makkah',
27
+ settings: {fajr: 18.5, isha: '90 min'} # fajr was 19 degrees before 1430 hijri
28
28
  },
29
29
  'Karachi' => {
30
30
  desc: 'University of Islamic Sciences, Karachi',
31
- settings: {fajr: 18, isha: 18}
31
+ settings: {fajr: 18, asr: 'Hanafi', isha: 18}
32
32
  },
33
33
  'Tehran' => {
34
34
  desc: 'Institute of Geophysics, University of Tehran',
35
35
  settings: {fajr: 17.7, maghrib: 4.5, isha: 14, midnight: 'Jafari'} # isha is not explicitly specified in this method
36
36
  },
37
- 'Jafari' => {
37
+ 'Jafari' => {
38
38
  desc: 'Shia Ithna-Ashari, Leva Institute, Qum',
39
39
  settings: {fajr: 16, maghrib: 4, isha: 14, midnight: 'Jafari'}
40
40
  },
41
- 'UOIF' =>{
41
+ 'UOIF' =>{
42
42
  desc: "UNION DES ORGANISATIONS ISLAMIQUES DE FRANCE",
43
- settings: {fajr: 19, maghrib: '0 min', isha: 17}
43
+ settings: {fajr: 19, maghrib: '0 min', isha: 17}
44
44
  },
45
45
  'Algeria' =>{
46
46
  desc: "Algeria",
@@ -63,11 +63,11 @@ module PrayerTimes
63
63
  },
64
64
  'Jordan' =>{
65
65
  desc: "General Iftaa' Department, The Hashemite Kingdom of Jordan",
66
- settings: {fajr: 18, maghrib: '0 min', isha: 18}
66
+ settings: {fajr: 18, maghrib: '0 min', isha: 18}
67
67
  },
68
68
  'Kuwait' =>{
69
69
  desc: "Kuwait",
70
- settings: {fajr: 18, maghrib: '0 min', isha: 17.5}
70
+ settings: {fajr: 18, maghrib: '0 min', isha: 17.5}
71
71
  },
72
72
  'Libya' =>{
73
73
  desc: "Libya",
@@ -110,14 +110,14 @@ module PrayerTimes
110
110
  }
111
111
  }
112
112
  end
113
-
113
+
114
114
  # Initializer
115
115
  # it populates a hash with predefined set of methods
116
116
  def initialize
117
117
  self.hash = {}
118
118
  populate
119
119
  end
120
-
120
+
121
121
  # @param [String] name
122
122
  # @param [String] description
123
123
  # @param [Hash] settings
@@ -126,20 +126,20 @@ module PrayerTimes
126
126
  def add(name, description, settings={}, offsets={})
127
127
  hash[name] = CalculationMethod.new(name, description, settings, offsets)
128
128
  end
129
-
129
+
130
130
  # Names of the available methods
131
131
  # @return [Array] list of names
132
132
  def names
133
133
  keys
134
134
  end
135
-
135
+
136
136
  private
137
-
137
+
138
138
  attr_accessor :hash
139
-
139
+
140
140
  def populate
141
141
  self.class.default_methods.each {|k,v| add(k, v[:desc], v[:settings], v[:offsets])}
142
- end
143
-
142
+ end
143
+
144
144
  end
145
- end
145
+ end
@@ -3,9 +3,9 @@ module PrayerTimes
3
3
  # This is main interface class
4
4
  class Calculator
5
5
  include Setters
6
-
6
+
7
7
  attr_reader :calculation_method, :time_format, :times_names, :time_suffixes, :invalid_time, :iterations_count, :times_offsets
8
-
8
+
9
9
  # Initializer
10
10
  # @param [String] calc_method the calculation method to use
11
11
  # @param [Hash] opts formatting options
@@ -32,7 +32,7 @@ module PrayerTimes
32
32
  self.iterations_count = opts[:iterations_count]
33
33
  end
34
34
 
35
-
35
+
36
36
 
37
37
  # Gets the prayers times
38
38
  # @param [Date] date the date
@@ -42,17 +42,17 @@ module PrayerTimes
42
42
  # @return [Hash] times
43
43
  def get_times(date, coords, time_zone, dst = nil)
44
44
  Calculation.new(self,
45
- date,
46
- coords,
45
+ date,
46
+ coords,
47
47
  time_zone + (dst.nil? ? 0 : 1)).
48
- compute
48
+ compute
49
49
  end
50
-
50
+
51
51
  private
52
-
52
+
53
53
  def const_class
54
54
  PrayerTimes
55
55
  end
56
56
 
57
57
  end
58
- end
58
+ end
@@ -1,28 +1,28 @@
1
1
  # encoding: UTF-8
2
2
  module PrayerTimes
3
3
  # General constants. Don't try to change their values.
4
- # You have flexible general and instance configurations.
4
+ # You have flexible general and instance configurations.
5
5
  module Constants
6
6
  # Used internally in the algorithm. Don't change unless you know
7
7
  # What you are doing
8
8
  # 0 < iterations_count < 6
9
9
  @iterations_count = 1
10
-
11
- # Determines the accepted values for iterations count
10
+
11
+ # Determines the accepted values for iterations count
12
12
  @accepted_iterations_count_range = 1..5
13
13
 
14
14
  # Times names to be displayed
15
15
  @times_names = {
16
- imsak: 'Imsak',
17
- fajr: 'Fajr',
18
- sunrise: 'Sunrise',
19
- dhuhr: 'Dhuhr',
20
- asr: 'Asr',
21
- sunset: 'Sunset',
22
- maghrib: 'Maghrib',
23
- isha: 'Isha',
24
- midnight: 'Midnight'
25
- }
16
+ imsak: 'Imsak',
17
+ fajr: 'Fajr',
18
+ sunrise: 'Sunrise',
19
+ dhuhr: 'Dhuhr',
20
+ asr: 'Asr',
21
+ sunset: 'Sunset',
22
+ maghrib: 'Maghrib',
23
+ isha: 'Isha',
24
+ midnight: 'Midnight'
25
+ }
26
26
 
27
27
  # The option time_format takes the following values:
28
28
  # '24h': 24-hour format,
@@ -30,8 +30,8 @@ module PrayerTimes
30
30
  # '12hNS': 12-hour format with no suffix,
31
31
  # 'Float': floating point number
32
32
  @time_format = '24h'
33
-
34
- # Determines the accepted time format values
33
+
34
+ # Determines the accepted time format values
35
35
  @accepted_time_formats = ['12h','24h','12hNS','Float']
36
36
 
37
37
  # Times suffixes names to be displayed
@@ -42,11 +42,11 @@ module PrayerTimes
42
42
 
43
43
  # Time offsets
44
44
  @times_offsets = @times_names.keys.inject({}){ |h,k| h.merge!(k => 0)}
45
-
45
+
46
46
  class << self
47
- attr_reader :iterations_count, :times_names,
48
- :time_format, :time_suffixes,:times_offsets,:invalid_time,
49
- :accepted_iterations_count_range, :accepted_time_formats
47
+ attr_reader :iterations_count, :times_names,
48
+ :time_format, :time_suffixes,:times_offsets,:invalid_time,
49
+ :accepted_iterations_count_range, :accepted_time_formats
50
50
  end
51
51
  end
52
- end
52
+ end
@@ -53,4 +53,4 @@ module PrayerTimes
53
53
  # @return [Float]
54
54
  def darctan2(y, x); degrees Math.atan2(y, x) ; end
55
55
  end
56
- end
56
+ end
@@ -1,19 +1,19 @@
1
1
  # encoding: UTF-8
2
2
  module PrayerTimes
3
- # General setters
3
+ # General setters
4
4
  module Setters
5
-
5
+
6
6
  # Sets iterations c
7
7
  # @param [Integer] num
8
8
  # 0 < num < 6
9
9
  def iterations_count=(num)
10
10
  @iterations_count = if (Constants.accepted_iterations_count_range).include?(num)
11
11
  num
12
- else
13
- const_class.iterations_count
14
- end
12
+ else
13
+ const_class.iterations_count
14
+ end
15
15
  end
16
-
16
+
17
17
  # Sets time format
18
18
  # @param [String] format
19
19
  # '24h': 24-hour format,
@@ -23,7 +23,7 @@ module PrayerTimes
23
23
  def time_format=(format)
24
24
  @time_format = if Constants.accepted_time_formats.include?(format)
25
25
  format
26
- else
26
+ else
27
27
  const_class.time_format
28
28
  end
29
29
  end
@@ -52,7 +52,7 @@ module PrayerTimes
52
52
  # @param [Hash] offsets
53
53
  def times_offsets=(offsets)
54
54
  s = offsets.reject{|k,v| !(const_class.times_offsets.key?(k) and v.is_a?(Numeric))} rescue {}
55
- @times_offsets = const_class.times_offsets.merge(s)
55
+ @times_offsets = const_class.times_offsets.merge(s)
56
56
  end
57
57
 
58
58
  # Sets calculation method and the corresponding settings
@@ -63,10 +63,11 @@ module PrayerTimes
63
63
  else
64
64
  PrayerTimes.calculation_method
65
65
  end
66
- end
67
-
66
+ end
67
+
68
68
  def const_class #:nodoc:
69
- raise "Please override this method"
69
+ raise NotImplementedError,
70
+ "You must implement #const_class to define which class to get the default attributes from"
70
71
  end
71
72
  end
72
- end
73
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  module PrayerTimes
3
3
  # Determines the version of this gem
4
- VERSION = "0.1.1"
5
- end
4
+ VERSION = "0.1.2"
5
+ end
data/lib/prayer_times.rb CHANGED
@@ -15,8 +15,8 @@ module PrayerTimes #:nodoc:
15
15
  include Setters
16
16
 
17
17
  attr_reader :iterations_count, :times_names, :calculation_methods,
18
- :calculation_method,:time_format, :time_suffixes,:times_offsets,
19
- :invalid_time
18
+ :calculation_method,:time_format, :time_suffixes,:times_offsets,
19
+ :invalid_time
20
20
  # @see Calculator initializer
21
21
  def new(calc_method=@calucation_method,opts={})
22
22
  PrayerTimes::Calculator.new(calc_method, opts)
@@ -28,7 +28,7 @@ module PrayerTimes #:nodoc:
28
28
 
29
29
  def set_attributes
30
30
  attrs = [:iterations_count, :times_names, :time_format,
31
- :time_suffixes,:times_offsets, :invalid_time]
31
+ :time_suffixes,:times_offsets, :invalid_time]
32
32
  attrs.each {|attr| self.send "#{attr}=", nil}
33
33
 
34
34
  @calculation_methods = CalculationMethods.new
data/prayer_times.gemspec CHANGED
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "coveralls"
24
25
 
25
26
  end
@@ -2,10 +2,10 @@
2
2
  require_relative '../../test_helper'
3
3
 
4
4
  describe PrayerTimes::CalculationMethod do
5
-
5
+
6
6
  let(:method_name){"Medina"}
7
7
  let(:description){"Medina testing methods"}
8
-
8
+
9
9
  describe "Object" do
10
10
  subject{PrayerTimes::CalculationMethod.new(method_name, description,{})}
11
11
  it {subject.must_respond_to :description}
@@ -15,44 +15,44 @@ describe PrayerTimes::CalculationMethod do
15
15
  it {subject.must_respond_to :offsets}
16
16
  it {subject.must_respond_to :offsets=}
17
17
  end
18
-
18
+
19
19
  describe "#initialize" do
20
20
  context "when method_name and description are provided" do
21
21
  subject{PrayerTimes::CalculationMethod.new(method_name, description)}
22
22
  it {subject.name.must_equal(method_name)}
23
23
  it {subject.description.must_equal(description)}
24
24
  end
25
-
25
+
26
26
  context "when settings are not provided" do
27
27
  subject{PrayerTimes::CalculationMethod.new(method_name, description, {})}
28
28
  it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings)}
29
29
  end
30
-
30
+
31
31
  context "when settings are provided" do
32
32
  let(:opts){{
33
- fajr: 18,
34
- asr: 'Hanafi',
35
- isha: 18
33
+ fajr: 18,
34
+ asr: 'Hanafi',
35
+ isha: 18
36
36
  }}
37
37
  subject{PrayerTimes::CalculationMethod.new(method_name, description,opts)}
38
38
  it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings.merge opts)}
39
- end
40
-
39
+ end
40
+
41
41
  context "when offsets are not provided" do
42
42
  subject{PrayerTimes::CalculationMethod.new(method_name, description, {}, {})}
43
43
  it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets)}
44
44
  end
45
-
45
+
46
46
  context "when offsets are provided" do
47
47
  let(:opts){{
48
- fajr: 3,
49
- asr: -1,
50
- isha: 6
48
+ fajr: 3,
49
+ asr: -1,
50
+ isha: 6
51
51
  }}
52
52
  subject{PrayerTimes::CalculationMethod.new(method_name, description,{},opts)}
53
53
  it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets.merge opts)}
54
- end
55
-
54
+ end
55
+
56
56
  end
57
57
 
58
58
  end
@@ -12,9 +12,9 @@ describe PrayerTimes::CalculationMethods do
12
12
  it {subject.must_respond_to :key?}
13
13
  it {subject.must_respond_to :delete}
14
14
  end
15
-
16
15
 
17
-
16
+
17
+
18
18
  describe "#add" do
19
19
  before do
20
20
  @subject = PrayerTimes::CalculationMethods.new
@@ -32,7 +32,7 @@ describe PrayerTimes::CalculationMethods do
32
32
  it {@subject["Test"].offsets[:asr].must_equal -1}
33
33
  it {@subject["Test"].offsets[:isha].must_equal 3}
34
34
  end
35
-
35
+
36
36
  describe "#names" do
37
37
  subject{PrayerTimes::CalculationMethods.new}
38
38
  it{subject.names.must_equal subject.keys}
@@ -7,118 +7,153 @@ describe PrayerTimes::Calculation do
7
7
  describe '#compute' do
8
8
  context 'when method is MWL' do
9
9
  context 'when date is 2011/2/9, location is Waterloo/Canada and timezone -5' do
10
- let(:pt){PrayerTimes.new}
11
- subject{pt.get_times([2011,2,9], [43, -80], -5)}
12
- let(:expected){{
13
- 'Imsak' => '05:40',
14
- 'Fajr' => '05:50',
15
- 'Sunrise' => '07:26',
16
- 'Dhuhr' => '12:34',
17
- 'Asr' => '15:18' ,
18
- 'Sunset' => '17:43' ,
19
- 'Maghrib' => '17:43' ,
20
- 'Isha' => '19:14' ,
21
- 'Midnight' => '00:35' }}
22
- it{subject.must_equal expected}
10
+ let(:pt){PrayerTimes.new}
11
+ subject{pt.get_times([2011,2,9], [43, -80], -5)}
12
+ let(:expected){{
13
+ 'Imsak' => '05:40',
14
+ 'Fajr' => '05:50',
15
+ 'Sunrise' => '07:26',
16
+ 'Dhuhr' => '12:34',
17
+ 'Asr' => '15:18' ,
18
+ 'Sunset' => '17:43' ,
19
+ 'Maghrib' => '17:43' ,
20
+ 'Isha' => '19:14' ,
21
+ 'Midnight' => '00:35' }}
22
+ it{subject.must_equal expected}
23
23
  end
24
24
  end
25
-
25
+
26
26
  context 'when method is Makkah' do
27
27
  let(:method_name){'Makkah'}
28
-
29
- context 'time format is 24h and other settings are default' do
28
+
29
+ context 'time format is 24h and other settings are default' do
30
30
  context 'when date is 2013/12/16, location is Amman/Jordan and timezone 3' do
31
- let(:pt){PrayerTimes.new method_name}
32
- subject{pt.get_times([2013,12,16], [31,36], 3)}
33
- let(:expected){{
34
- 'Imsak' => '05:48',
35
- 'Fajr' => '05:58',
36
- 'Sunrise' => '07:27',
37
- 'Dhuhr' => '12:32',
38
- 'Asr' => '15:18' ,
39
- 'Sunset' => '17:36' ,
40
- 'Maghrib' => '17:36' ,
41
- 'Isha' => '19:06' ,
42
- 'Midnight' => '00:32' }}
43
- it{subject.must_equal expected}
31
+ let(:pt){PrayerTimes.new method_name}
32
+ subject{pt.get_times([2013,12,16], [31,36], 3)}
33
+ let(:expected){{
34
+ 'Imsak' => '05:48',
35
+ 'Fajr' => '05:58',
36
+ 'Sunrise' => '07:27',
37
+ 'Dhuhr' => '12:32',
38
+ 'Asr' => '15:18' ,
39
+ 'Sunset' => '17:36' ,
40
+ 'Maghrib' => '17:36' ,
41
+ 'Isha' => '19:06' ,
42
+ 'Midnight' => '00:32' }}
43
+ it{subject.must_equal expected}
44
44
  end
45
45
  end
46
-
47
- context 'time format is 24h, offsets are custom and other settings are default' do
46
+
47
+ context 'time format is 24h, offsets are custom and other settings are default' do
48
48
  context 'when date is 2013/12/16, location is Amman/Jordan and timezone 3' do
49
- let(:pt){PrayerTimes.new method_name, times_offsets: {fajr: 4, dhuhr: 2, midnight: 1}}
50
- subject{pt.get_times([2013,12,16], [31,36], 3)}
51
- let(:expected){{
52
- 'Imsak' => '05:48',
53
- 'Fajr' => '06:02',
54
- 'Sunrise' => '07:27',
55
- 'Dhuhr' => '12:34',
56
- 'Asr' => '15:18' ,
57
- 'Sunset' => '17:36' ,
58
- 'Maghrib' => '17:36' ,
59
- 'Isha' => '19:06' ,
60
- 'Midnight' => '00:33' }}
61
- it{subject.must_equal expected}
49
+ let(:pt){PrayerTimes.new method_name, times_offsets: {fajr: 4, dhuhr: 2, midnight: 1}}
50
+ subject{pt.get_times([2013,12,16], [31,36], 3)}
51
+ let(:expected){{
52
+ 'Imsak' => '05:48',
53
+ 'Fajr' => '06:02',
54
+ 'Sunrise' => '07:27',
55
+ 'Dhuhr' => '12:34',
56
+ 'Asr' => '15:18' ,
57
+ 'Sunset' => '17:36' ,
58
+ 'Maghrib' => '17:36' ,
59
+ 'Isha' => '19:06' ,
60
+ 'Midnight' => '00:33' }}
61
+ it{subject.must_equal expected}
62
62
  end
63
63
  end
64
-
65
-
66
-
67
- context 'time format is 24h, times names are custom and settings are default' do
64
+
65
+
66
+
67
+ context 'time format is 24h, times names are custom and settings are default' do
68
68
  context 'when date is 2013/12/16, location is Amman/Jordan and timezone 3' do
69
- let(:pt){PrayerTimes.new method_name, times_names: {asr: "Aser", isha: "Ishaa"}}
70
- subject{pt.get_times([2013,12,16], [31,36], 3)}
71
- let(:expected){{
72
- 'Imsak' => '05:48',
73
- 'Fajr' => '05:58',
74
- 'Sunrise' => '07:27',
75
- 'Dhuhr' => '12:32',
76
- 'Aser' => '15:18' ,
77
- 'Sunset' => '17:36' ,
78
- 'Maghrib' => '17:36' ,
79
- 'Ishaa' => '19:06' ,
80
- 'Midnight' => '00:32' }}
81
- it{subject.must_equal expected}
69
+ let(:pt){PrayerTimes.new method_name, times_names: {asr: "Aser", isha: "Ishaa"}}
70
+ subject{pt.get_times([2013,12,16], [31,36], 3)}
71
+ let(:expected){{
72
+ 'Imsak' => '05:48',
73
+ 'Fajr' => '05:58',
74
+ 'Sunrise' => '07:27',
75
+ 'Dhuhr' => '12:32',
76
+ 'Aser' => '15:18' ,
77
+ 'Sunset' => '17:36' ,
78
+ 'Maghrib' => '17:36' ,
79
+ 'Ishaa' => '19:06' ,
80
+ 'Midnight' => '00:32' }}
81
+ it{subject.must_equal expected}
82
82
  end
83
83
  end
84
-
85
- context 'time format is 12h, suffixes are custom and other settings are default' do
84
+
85
+ context 'time format is 12h, suffixes are custom and other settings are default' do
86
86
  context 'when date is 2013/12/16, location is Amman/Jordan and timezone 3' do
87
- let(:pt){PrayerTimes.new method_name, time_format: '12h', time_suffixes: {:am => ' صباحا', :pm => ' مساءا'}}
88
- subject{pt.get_times([2013,12,16], [31,36], 3)}
89
- let(:expected){{
90
- 'Imsak' => '5:48 صباحا',
91
- 'Fajr' => '5:58 صباحا',
92
- 'Sunrise' => '7:27 صباحا',
93
- 'Dhuhr' => '12:32 مساءا',
94
- 'Asr' => '3:18 مساءا' ,
95
- 'Sunset' => '5:36 مساءا' ,
96
- 'Maghrib' => '5:36 مساءا' ,
97
- 'Isha' => '7:06 مساءا' ,
98
- 'Midnight' => '12:32 صباحا' }}
99
- it{subject.must_equal expected}
87
+ let(:pt){PrayerTimes.new method_name, time_format: '12h', time_suffixes: {:am => ' صباحا', :pm => ' مساءا'}}
88
+ subject{pt.get_times([2013,12,16], [31,36], 3)}
89
+ let(:expected){{
90
+ 'Imsak' => '5:48 صباحا',
91
+ 'Fajr' => '5:58 صباحا',
92
+ 'Sunrise' => '7:27 صباحا',
93
+ 'Dhuhr' => '12:32 مساءا',
94
+ 'Asr' => '3:18 مساءا' ,
95
+ 'Sunset' => '5:36 مساءا' ,
96
+ 'Maghrib' => '5:36 مساءا' ,
97
+ 'Isha' => '7:06 مساءا' ,
98
+ 'Midnight' => '12:32 صباحا' }}
99
+ it{subject.must_equal expected}
100
100
  end
101
101
  end
102
102
  end
103
-
104
- context 'when method is Turkey' do
103
+
104
+ context 'when method is Turkey' do
105
105
  context 'when date is 2013/12/17, location is Fatih/Istanbul/Turkey and timezone +2' do
106
- let(:pt){PrayerTimes.new "Turkey", time_format: '12h'}
107
- subject{pt.get_times([2013,12,17], [41.02,28.94], 2)}
108
- let(:expected){{
109
- 'Imsak' => '5:34AM',
110
- 'Fajr' => '5:42AM',
111
- 'Sunrise' => '7:16AM',
112
- 'Dhuhr' => '12:06PM',
113
- 'Asr' => '2:24PM' ,
114
- 'Sunset' => '4:37PM' ,
115
- 'Maghrib' => '4:46PM' ,
116
- 'Isha' => '6:13PM' ,
117
- 'Midnight' => '12:00AM' }}
118
- it{subject.must_equal expected}
106
+ let(:pt){PrayerTimes.new "Turkey", time_format: '12h'}
107
+ subject{pt.get_times([2013,12,17], [41.02,28.94], 2)}
108
+ let(:expected){{
109
+ 'Imsak' => '5:34AM',
110
+ 'Fajr' => '5:42AM',
111
+ 'Sunrise' => '7:16AM',
112
+ 'Dhuhr' => '12:06PM',
113
+ 'Asr' => '2:24PM' ,
114
+ 'Sunset' => '4:37PM' ,
115
+ 'Maghrib' => '4:46PM' ,
116
+ 'Isha' => '6:13PM' ,
117
+ 'Midnight' => '12:00AM' }}
118
+ it{subject.must_equal expected}
119
119
  end
120
120
  end
121
-
122
-
121
+
122
+ context 'when method is Karachi' do
123
+ context 'when date is 2013/12/17, location is Islamabad, timezone +5 and format is 12h' do
124
+ let(:pt){PrayerTimes.new "Karachi", time_format: '12h'}
125
+ subject{pt.get_times([2014,1,23], [33.73,73.06], 5)}
126
+ let(:expected){{
127
+ 'Imsak' => '5:33AM',
128
+ 'Fajr' => '5:43AM',
129
+ 'Sunrise' => '7:10AM',
130
+ 'Dhuhr' => '12:20PM',
131
+ 'Asr' => '3:52PM' ,
132
+ 'Sunset' => '5:30PM' ,
133
+ 'Maghrib' => '5:30PM' ,
134
+ 'Isha' => '6:56PM' ,
135
+ 'Midnight' => '12:20AM' }}
136
+ it{subject.must_equal expected}
137
+ end
138
+ end
139
+
140
+ context 'when method is Kula Malaysia' do
141
+ context 'when date is 2013/12/17, location is Kula Lumpur, timezone +8 and format is 12h' do
142
+ let(:pt){PrayerTimes.new "Malaysia", time_format: '12h'}
143
+ subject{pt.get_times([2014,1,23], [3.15,101.69], 8)}
144
+ let(:expected){{
145
+ 'Imsak' => '5:54AM',
146
+ 'Fajr' => '6:07AM',
147
+ 'Sunrise' => '7:28AM',
148
+ 'Dhuhr' => '1:26PM',
149
+ 'Asr' => '4:50PM' ,
150
+ 'Sunset' => '7:25PM' ,
151
+ 'Maghrib' => '7:25PM' ,
152
+ 'Isha' => '8:36PM' ,
153
+ 'Midnight' => '1:25AM' }}
154
+ it{subject.must_equal expected}
155
+ end
156
+ end
157
+
123
158
  end
124
159
  end
@@ -3,15 +3,15 @@ require_relative '../../test_helper'
3
3
 
4
4
  describe PrayerTimes::Calculator do
5
5
 
6
- subject{PrayerTimes::Calculator.new "MWL",{}}
7
- it{subject.must_respond_to :calculation_method}
8
- it{subject.must_respond_to :time_format}
9
- it{subject.must_respond_to :times_names}
10
- it{subject.must_respond_to :time_suffixes}
11
- it{subject.must_respond_to :invalid_time}
12
- it{subject.must_respond_to :iterations_count}
13
- it{subject.must_respond_to :times_offsets}
14
- it{subject.must_respond_to :get_times}
15
- it{subject.must_be_kind_of PrayerTimes::Setters}
16
-
6
+ subject{PrayerTimes::Calculator.new "MWL",{}}
7
+ it{subject.must_respond_to :calculation_method}
8
+ it{subject.must_respond_to :time_format}
9
+ it{subject.must_respond_to :times_names}
10
+ it{subject.must_respond_to :time_suffixes}
11
+ it{subject.must_respond_to :invalid_time}
12
+ it{subject.must_respond_to :iterations_count}
13
+ it{subject.must_respond_to :times_offsets}
14
+ it{subject.must_respond_to :get_times}
15
+ it{subject.must_be_kind_of PrayerTimes::Setters}
16
+
17
17
  end
@@ -16,31 +16,31 @@ describe PrayerTimes::MathHelpers do
16
16
  describe "#rsin" do
17
17
  it {subject.must_respond_to(:rsin)}
18
18
  end
19
-
19
+
20
20
  describe "#rcos" do
21
21
  it {subject.must_respond_to(:rcos)}
22
22
  end
23
-
23
+
24
24
  describe "#rtan" do
25
25
  it {subject.must_respond_to(:rtan)}
26
26
  end
27
-
27
+
28
28
  describe "#darcsin" do
29
29
  it {subject.must_respond_to(:darcsin)}
30
30
  end
31
-
31
+
32
32
  describe "#darccos" do
33
33
  it {subject.must_respond_to(:darccos)}
34
34
  end
35
-
35
+
36
36
  describe "#darctan" do
37
37
  it {subject.must_respond_to(:darctan)}
38
38
  end
39
-
39
+
40
40
  describe "#darccot" do
41
41
  it {subject.must_respond_to(:darccot)}
42
42
  end
43
-
43
+
44
44
  describe "#darctan2" do
45
45
  it {subject.must_respond_to(:darctan2)}
46
46
  end
@@ -15,10 +15,10 @@ describe PrayerTimes do
15
15
  it{subject.must_respond_to :times_offsets}
16
16
  it{subject.must_be_kind_of PrayerTimes::Setters}
17
17
  end
18
-
18
+
19
19
  describe ".new" do
20
20
  subject{PrayerTimes.new}
21
21
  it{subject.must_be_kind_of PrayerTimes::Calculator}
22
22
  end
23
23
 
24
- end
24
+ end
@@ -2,7 +2,7 @@
2
2
  require_relative '../../test_helper'
3
3
 
4
4
  describe PrayerTimes::Setters do
5
-
5
+
6
6
  subject{PrayerTimes::Calculator.new "MWL",{}}
7
7
  describe "#iteration_count=" do
8
8
  context "when number not number or out of range" do
@@ -33,7 +33,7 @@ describe PrayerTimes::Setters do
33
33
  it{result.must_equal time_format}
34
34
  end
35
35
  end
36
-
36
+
37
37
  describe "#invalid_time=" do
38
38
  context "when nil" do
39
39
  let(:invalid_time){nil}
@@ -47,7 +47,7 @@ describe PrayerTimes::Setters do
47
47
  it{result.must_equal invalid_time}
48
48
  end
49
49
  end
50
-
50
+
51
51
  describe "#time_suffixes=" do
52
52
  context "when wrong value" do
53
53
  let(:time_suffixes){{:amz => "صباحا", :pm => "مساءا"}}
@@ -61,7 +61,7 @@ describe PrayerTimes::Setters do
61
61
  it{result.must_equal PrayerTimes.time_suffixes.merge(time_suffixes)}
62
62
  end
63
63
  end
64
-
64
+
65
65
  describe "#times_names=" do
66
66
  context "when wrong value" do
67
67
  let(:times_names){{:aser => "Aser", :koko => "Dano", :isha => "Ishaa"}}
@@ -75,7 +75,7 @@ describe PrayerTimes::Setters do
75
75
  it{result.must_equal PrayerTimes.times_names.merge(times_names)}
76
76
  end
77
77
  end
78
-
78
+
79
79
  describe "#times_offsets=" do
80
80
  context "when wrong value" do
81
81
  let(:times_offsets){{:aser => 10, :dhuhr => "Dano", :isha => 3.6}}
@@ -89,7 +89,7 @@ describe PrayerTimes::Setters do
89
89
  it{result.must_equal PrayerTimes.times_offsets.merge(times_offsets)}
90
90
  end
91
91
  end
92
-
92
+
93
93
  describe "#calculation_method=" do
94
94
  context "when wrong value" do
95
95
  let(:calculation_method){'K@mp'}
@@ -103,4 +103,4 @@ describe PrayerTimes::Setters do
103
103
  it{result.must_equal PrayerTimes.calculation_methods['Makkah']}
104
104
  end
105
105
  end
106
- end
106
+ end
@@ -7,4 +7,4 @@ describe PrayerTimes do
7
7
  PrayerTimes::VERSION.wont_be_nil
8
8
  end
9
9
 
10
- end
10
+ end
data/test/test_helper.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  # encoding: UTF-8
2
2
  require 'minitest/autorun'
3
3
  require 'minitest/pride'
4
+ require 'coveralls'
5
+ Coveralls.wear!
4
6
  require File.expand_path('../../lib/prayer_times.rb', __FILE__)
5
7
  class MiniTest::Spec
6
8
  class << self
7
9
  alias :context :describe
8
10
  end
9
- end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prayer_times
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Khaled alHabache
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2014-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Calculates Muslim prayers times in given settings
56
70
  email:
57
71
  - khellls@gmail.com