prayer_times 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +17 -1
- data/.yardopts +5 -0
- data/Gemfile +27 -1
- data/Guardfile +5 -0
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +2 -2
- data/Rakefile +8 -9
- data/lib/prayer_times.rb +13 -13
- data/lib/prayer_times/calculator.rb +2 -2
- data/lib/prayer_times/constants.rb +4 -4
- data/lib/prayer_times/setters.rb +10 -7
- data/lib/prayer_times/version.rb +3 -2
- data/prayer_times.gemspec +8 -14
- data/spec/helper.rb +29 -0
- data/spec/prayer_times/calculation_method_spec.rb +58 -0
- data/spec/prayer_times/calculation_methods_spec.rb +38 -0
- data/spec/prayer_times/calculation_spec.rb +159 -0
- data/spec/prayer_times/calculator_spec.rb +17 -0
- data/spec/prayer_times/math_helpers_spec.rb +47 -0
- data/spec/prayer_times/prayer_times_spec.rb +24 -0
- data/spec/prayer_times/setters_spec.rb +106 -0
- data/spec/prayer_times/version_spec.rb +10 -0
- metadata +31 -84
- data/test/lib/prayer_times/calculation_method_test.rb +0 -58
- data/test/lib/prayer_times/calculation_methods_test.rb +0 -40
- data/test/lib/prayer_times/calculation_test.rb +0 -159
- data/test/lib/prayer_times/calculator_test.rb +0 -17
- data/test/lib/prayer_times/math_helpers_test.rb +0 -47
- data/test/lib/prayer_times/prayer_times_test.rb +0 -24
- data/test/lib/prayer_times/setters_test.rb +0 -106
- data/test/lib/prayer_times/version_test.rb +0 -10
- data/test/test_helper.rb +0 -11
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe PrayerTimes::Calculator do
|
5
|
+
|
6
|
+
subject { PrayerTimes::Calculator.new 'MWL', {} }
|
7
|
+
it { expect(subject).to respond_to(:calculation_method) }
|
8
|
+
it { expect(subject).to respond_to(:time_format) }
|
9
|
+
it { expect(subject).to respond_to(:times_names) }
|
10
|
+
it { expect(subject).to respond_to(:time_suffixes) }
|
11
|
+
it { expect(subject).to respond_to(:invalid_time) }
|
12
|
+
it { expect(subject).to respond_to(:iterations_count) }
|
13
|
+
it { expect(subject).to respond_to(:times_offsets) }
|
14
|
+
it { expect(subject).to respond_to(:get_times) }
|
15
|
+
it { expect(subject).to be_a(PrayerTimes::Setters) }
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe PrayerTimes::MathHelpers do
|
5
|
+
|
6
|
+
subject { Object.new.extend PrayerTimes::MathHelpers }
|
7
|
+
|
8
|
+
describe '#radians' do
|
9
|
+
it { expect(subject).to respond_to(:radians) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#degrees' do
|
13
|
+
it { expect(subject).to respond_to(:degrees) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#rsin' do
|
17
|
+
it { expect(subject).to respond_to(:rsin) }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#rcos' do
|
21
|
+
it { expect(subject).to respond_to(:rcos) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#rtan' do
|
25
|
+
it { expect(subject).to respond_to(:rtan) }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#darcsin' do
|
29
|
+
it { expect(subject).to respond_to(:darcsin) }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#darccos' do
|
33
|
+
it { expect(subject).to respond_to(:darccos) }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#darctan' do
|
37
|
+
it { expect(subject).to respond_to(:darctan) }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#darccot' do
|
41
|
+
it { expect(subject).to respond_to(:darccot) }
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#darctan2' do
|
45
|
+
it { expect(subject).to respond_to(:darctan2) }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe PrayerTimes do
|
5
|
+
|
6
|
+
describe 'Class' do
|
7
|
+
subject { PrayerTimes }
|
8
|
+
it { expect(subject).to respond_to(:calculation_method) }
|
9
|
+
it { expect(subject).to respond_to(:calculation_methods) }
|
10
|
+
it { expect(subject).to respond_to(:time_format) }
|
11
|
+
it { expect(subject).to respond_to(:times_names) }
|
12
|
+
it { expect(subject).to respond_to(:time_suffixes) }
|
13
|
+
it { expect(subject).to respond_to(:invalid_time) }
|
14
|
+
it { expect(subject).to respond_to(:iterations_count) }
|
15
|
+
it { expect(subject).to respond_to(:times_offsets) }
|
16
|
+
it { expect(subject).to be_a(PrayerTimes::Setters) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.new' do
|
20
|
+
subject { PrayerTimes.new }
|
21
|
+
it { expect(subject).to be_a(PrayerTimes::Calculator) }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe PrayerTimes::Setters do
|
5
|
+
|
6
|
+
subject{ PrayerTimes::Calculator.new 'MWL',{} }
|
7
|
+
describe '#iteration_count=' do
|
8
|
+
context 'when number not number or out of range' do
|
9
|
+
['',1,6].each do |num|
|
10
|
+
let(:iterations_count) { 8 }
|
11
|
+
let(:result) { subject.iterations_count = iterations_count; subject.iterations_count }
|
12
|
+
it { expect(result).to eq(PrayerTimes.iterations_count) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when in range' do
|
17
|
+
let(:iterations_count) { 3 }
|
18
|
+
let(:result) { subject.iterations_count = iterations_count; subject.iterations_count }
|
19
|
+
it { expect(result).to eq(iterations_count) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#time_format=' do
|
24
|
+
context 'when wrong value' do
|
25
|
+
let(:time_format) { 'kh' }
|
26
|
+
let(:result) { subject.time_format = time_format; subject.time_format }
|
27
|
+
it { expect(result).to eq(PrayerTimes.time_format) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when right value' do
|
31
|
+
let(:time_format) { '12h' }
|
32
|
+
let(:result) { subject.time_format = time_format; subject.time_format }
|
33
|
+
it { expect(result).to eq(time_format) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#invalid_time=' do
|
38
|
+
context 'when nil' do
|
39
|
+
let(:invalid_time) { nil }
|
40
|
+
let(:result) { subject.invalid_time = invalid_time; subject.invalid_time }
|
41
|
+
it { expect(result).to eq(PrayerTimes.invalid_time) }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when other value' do
|
45
|
+
let(:invalid_time) { '*****' }
|
46
|
+
let(:result) { subject.invalid_time = invalid_time; subject.invalid_time }
|
47
|
+
it { expect(result).to eq(invalid_time) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#time_suffixes=' do
|
52
|
+
context 'when wrong value' do
|
53
|
+
let(:time_suffixes) { {:amz => 'صباحا', :pm => 'مساءا' } }
|
54
|
+
let(:result) { subject.time_suffixes = time_suffixes; subject.time_suffixes }
|
55
|
+
it { expect(result).to eq(PrayerTimes.time_suffixes.merge({:pm => 'مساءا' })) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when right value' do
|
59
|
+
let(:time_suffixes) { {:am => 'صباحا', :pm => 'مساءا' } }
|
60
|
+
let(:result) { subject.time_suffixes = time_suffixes; subject.time_suffixes }
|
61
|
+
it { expect(result).to eq(PrayerTimes.time_suffixes.merge(time_suffixes)) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#times_names=' do
|
66
|
+
context 'when wrong value' do
|
67
|
+
let(:times_names) { {:aser => 'Aser', :koko => 'Dano', :isha => 'Ishaa' } }
|
68
|
+
let(:result) { subject.times_names = times_names; subject.times_names }
|
69
|
+
it { expect(result).to eq(PrayerTimes.times_names.merge({:isha => 'Ishaa' })) }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when right value' do
|
73
|
+
let(:times_names) { {:asr => 'Aser', :isha => 'Ishaa' } }
|
74
|
+
let(:result) { subject.times_names = times_names; subject.times_names }
|
75
|
+
it { expect(result).to eq(PrayerTimes.times_names.merge(times_names)) }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#times_offsets=' do
|
80
|
+
context 'when wrong value' do
|
81
|
+
let(:times_offsets) { {:aser => 10, :dhuhr => 'Dano', :isha => 3.6} }
|
82
|
+
let(:result) { subject.times_offsets = times_offsets; subject.times_offsets }
|
83
|
+
it { expect(result).to eq(PrayerTimes.times_offsets.merge({:isha => 3.6})) }
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when right value' do
|
87
|
+
let(:times_offsets) { {:asr => 1, :dhuhr => 1.2, :isha => 3.6} }
|
88
|
+
let(:result) { subject.times_offsets = times_offsets; subject.times_offsets }
|
89
|
+
it { expect(result).to eq(PrayerTimes.times_offsets.merge(times_offsets)) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '#calculation_method=' do
|
94
|
+
context 'when wrong value' do
|
95
|
+
let(:calculation_method) { 'K@mp' }
|
96
|
+
let(:result) { subject.calculation_method = calculation_method; subject.calculation_method }
|
97
|
+
it { expect(result).to eq(PrayerTimes.calculation_method) }
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when right value' do
|
101
|
+
let(:calculation_method) { 'Makkah' }
|
102
|
+
let(:result) { subject.calculation_method = calculation_method; subject.calculation_method }
|
103
|
+
it { expect(result).to eq(PrayerTimes.calculation_methods['Makkah']) }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prayer_times
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khaled alHabache
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.3'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
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'
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
69
13
|
description: Calculates Muslim prayers times in given settings
|
70
14
|
email:
|
71
15
|
- khellls@gmail.com
|
@@ -73,10 +17,13 @@ executables: []
|
|
73
17
|
extensions: []
|
74
18
|
extra_rdoc_files: []
|
75
19
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
23
|
+
- ".yardopts"
|
78
24
|
- Gemfile
|
79
|
-
-
|
25
|
+
- Guardfile
|
26
|
+
- LICENSE.md
|
80
27
|
- README.md
|
81
28
|
- Rakefile
|
82
29
|
- lib/prayer_times.rb
|
@@ -89,15 +36,15 @@ files:
|
|
89
36
|
- lib/prayer_times/setters.rb
|
90
37
|
- lib/prayer_times/version.rb
|
91
38
|
- prayer_times.gemspec
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
39
|
+
- spec/helper.rb
|
40
|
+
- spec/prayer_times/calculation_method_spec.rb
|
41
|
+
- spec/prayer_times/calculation_methods_spec.rb
|
42
|
+
- spec/prayer_times/calculation_spec.rb
|
43
|
+
- spec/prayer_times/calculator_spec.rb
|
44
|
+
- spec/prayer_times/math_helpers_spec.rb
|
45
|
+
- spec/prayer_times/prayer_times_spec.rb
|
46
|
+
- spec/prayer_times/setters_spec.rb
|
47
|
+
- spec/prayer_times/version_spec.rb
|
101
48
|
homepage: https://github.com/Startappz/prayer_times/
|
102
49
|
licenses:
|
103
50
|
- GNU LGPL v3.0
|
@@ -108,28 +55,28 @@ require_paths:
|
|
108
55
|
- lib
|
109
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
57
|
requirements:
|
111
|
-
- -
|
58
|
+
- - ">="
|
112
59
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
60
|
+
version: 1.9.2
|
114
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
62
|
requirements:
|
116
|
-
- -
|
63
|
+
- - ">="
|
117
64
|
- !ruby/object:Gem::Version
|
118
65
|
version: '0'
|
119
66
|
requirements: []
|
120
67
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.2.2
|
122
69
|
signing_key:
|
123
70
|
specification_version: 4
|
124
71
|
summary: Muslim prayers times calculator
|
125
72
|
test_files:
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
73
|
+
- spec/helper.rb
|
74
|
+
- spec/prayer_times/calculation_method_spec.rb
|
75
|
+
- spec/prayer_times/calculation_methods_spec.rb
|
76
|
+
- spec/prayer_times/calculation_spec.rb
|
77
|
+
- spec/prayer_times/calculator_spec.rb
|
78
|
+
- spec/prayer_times/math_helpers_spec.rb
|
79
|
+
- spec/prayer_times/prayer_times_spec.rb
|
80
|
+
- spec/prayer_times/setters_spec.rb
|
81
|
+
- spec/prayer_times/version_spec.rb
|
135
82
|
has_rdoc:
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require_relative '../../test_helper'
|
3
|
-
|
4
|
-
describe PrayerTimes::CalculationMethod do
|
5
|
-
|
6
|
-
let(:method_name){"Medina"}
|
7
|
-
let(:description){"Medina testing methods"}
|
8
|
-
|
9
|
-
describe "Object" do
|
10
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description,{})}
|
11
|
-
it {subject.must_respond_to :description}
|
12
|
-
it {subject.must_respond_to :description=}
|
13
|
-
it {subject.must_respond_to :settings}
|
14
|
-
it {subject.must_respond_to :settings=}
|
15
|
-
it {subject.must_respond_to :offsets}
|
16
|
-
it {subject.must_respond_to :offsets=}
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#initialize" do
|
20
|
-
context "when method_name and description are provided" do
|
21
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description)}
|
22
|
-
it {subject.name.must_equal(method_name)}
|
23
|
-
it {subject.description.must_equal(description)}
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when settings are not provided" do
|
27
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description, {})}
|
28
|
-
it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings)}
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when settings are provided" do
|
32
|
-
let(:opts){{
|
33
|
-
fajr: 18,
|
34
|
-
asr: 'Hanafi',
|
35
|
-
isha: 18
|
36
|
-
}}
|
37
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description,opts)}
|
38
|
-
it {subject.settings.must_equal(PrayerTimes::CalculationMethod.default_settings.merge opts)}
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when offsets are not provided" do
|
42
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description, {}, {})}
|
43
|
-
it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets)}
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when offsets are provided" do
|
47
|
-
let(:opts){{
|
48
|
-
fajr: 3,
|
49
|
-
asr: -1,
|
50
|
-
isha: 6
|
51
|
-
}}
|
52
|
-
subject{PrayerTimes::CalculationMethod.new(method_name, description,{},opts)}
|
53
|
-
it {subject.offsets.must_equal(PrayerTimes::Constants.times_offsets.merge opts)}
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require_relative '../../test_helper'
|
3
|
-
|
4
|
-
describe PrayerTimes::CalculationMethods do
|
5
|
-
describe "#initialize" do
|
6
|
-
subject{PrayerTimes::CalculationMethods.new}
|
7
|
-
it {subject.must_respond_to :add}
|
8
|
-
it {subject.keys.must_equal subject.class.default_methods.keys}
|
9
|
-
it {subject.must_respond_to :[]}
|
10
|
-
it {subject.must_respond_to :each}
|
11
|
-
it {subject.must_respond_to :keys}
|
12
|
-
it {subject.must_respond_to :key?}
|
13
|
-
it {subject.must_respond_to :delete}
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
describe "#add" do
|
19
|
-
before do
|
20
|
-
@subject = PrayerTimes::CalculationMethods.new
|
21
|
-
@settings = {fajr: 16.5, asr: 'Hanafi', isha: '80 min'}
|
22
|
-
@offsets = {dhuhr: 2, asr: -1, isha: 3}
|
23
|
-
|
24
|
-
@new = @subject.add("Test", "Testing method", @settings, @offsets)
|
25
|
-
end
|
26
|
-
it {@new.must_be_instance_of PrayerTimes::CalculationMethod}
|
27
|
-
it {@subject["Test"].must_be_same_as @new}
|
28
|
-
it {@subject["Test"].settings[:fajr].must_equal 16.5}
|
29
|
-
it {@subject["Test"].settings[:asr].must_equal 'Hanafi'}
|
30
|
-
it {@subject["Test"].settings[:isha].must_equal '80 min'}
|
31
|
-
it {@subject["Test"].offsets[:dhuhr].must_equal 2}
|
32
|
-
it {@subject["Test"].offsets[:asr].must_equal -1}
|
33
|
-
it {@subject["Test"].offsets[:isha].must_equal 3}
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#names" do
|
37
|
-
subject{PrayerTimes::CalculationMethods.new}
|
38
|
-
it{subject.names.must_equal subject.keys}
|
39
|
-
end
|
40
|
-
end
|