danica 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/lib/danica/base_operations.rb +8 -0
- data/lib/danica/dsl.rb +2 -1
- data/lib/danica/version.rb +1 -1
- data/spec/integration/{sum_spec.rb → addition_spec.rb} +0 -0
- data/spec/integration/{product_spec.rb → multiplication_spec.rb} +0 -0
- data/spec/integration/{positive_negative_spec.rb → plus_minus_spec.rb} +0 -0
- data/spec/lib/danica/dsl_spec.rb +14 -13
- data/spec/lib/danica/operator/addition_spec.rb +1 -1
- data/spec/lib/danica_spec.rb +41 -0
- data/spec/support/shared_examples/base_operations.rb +16 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c20cfa612c100125cf73a89cd2d30f02ab4f12
|
4
|
+
data.tar.gz: 3894bdce489e74dfdd9dd59320177e6dbbce10b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d67bb880292f39d3b3946e1f9a386292fa06fc4f354e4f289ed542b7f24ae79e267bd30e047f3ff75aa5b832da0274b813f83e3b0c593500ec40f649fa985da
|
7
|
+
data.tar.gz: 5adcd6154c4c4b28a48c2cc99f1f859697a72254c759415a12e8597fc5e223552e4e8c15c5b6985ec55fdfc0d7ba2547748d9c029e8b06f2cbc19efdc2fb06ab
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Favini
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
data/lib/danica/dsl.rb
CHANGED
data/lib/danica/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/lib/danica/dsl_spec.rb
CHANGED
@@ -12,24 +12,25 @@ end
|
|
12
12
|
|
13
13
|
shared_context 'a class with mapped dsl' do
|
14
14
|
{
|
15
|
-
addition:
|
16
|
-
sum:
|
15
|
+
addition: Danica::Operator::Addition,
|
16
|
+
sum: Danica::Operator::Addition,
|
17
17
|
multiplication: Danica::Operator::Multiplication,
|
18
|
-
product:
|
19
|
-
division:
|
20
|
-
sin:
|
21
|
-
cos:
|
22
|
-
power:
|
18
|
+
product: Danica::Operator::Multiplication,
|
19
|
+
division: Danica::Operator::Division,
|
20
|
+
sin: Danica::Operator::Sin,
|
21
|
+
cos: Danica::Operator::Cos,
|
22
|
+
power: Danica::Operator::Power
|
23
23
|
}.each do |aliaz, clazz|
|
24
24
|
it_behaves_like 'a class with alias to a clazz', aliaz, clazz, 2, 3
|
25
25
|
end
|
26
26
|
{
|
27
|
-
squared_root:
|
28
|
-
exponential:
|
29
|
-
group:
|
30
|
-
negative:
|
31
|
-
number:
|
32
|
-
|
27
|
+
squared_root: Danica::Operator::SquaredRoot,
|
28
|
+
exponential: Danica::Operator::Exponential,
|
29
|
+
group: Danica::Wrapper::Group,
|
30
|
+
negative: Danica::Wrapper::Negative,
|
31
|
+
number: Danica::Wrapper::Number,
|
32
|
+
num: Danica::Wrapper::Number,
|
33
|
+
plus_minus: Danica::Wrapper::PlusMinus
|
33
34
|
}.each do |aliaz, clazz|
|
34
35
|
it_behaves_like 'a class with alias to a clazz', aliaz, clazz, 9
|
35
36
|
end
|
@@ -5,7 +5,7 @@ describe Danica::Operator::Addition do
|
|
5
5
|
|
6
6
|
it_behaves_like 'an object that respond to basic_methods'
|
7
7
|
|
8
|
-
it_behaves_like 'an object with basic operation',
|
8
|
+
it_behaves_like 'an object with basic operation', ignore: %i(+ -)
|
9
9
|
it_behaves_like 'an object with + operation' do
|
10
10
|
let(:subject_included) { 10 }
|
11
11
|
|
data/spec/lib/danica_spec.rb
CHANGED
@@ -30,6 +30,17 @@ describe Danica do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
context 'when starting with a negative object' do
|
34
|
+
let(:block) do
|
35
|
+
proc { - Danica::Wrapper::Number.new(10) }
|
36
|
+
end
|
37
|
+
let(:expected) { Danica::Wrapper::Negative.new(10) }
|
38
|
+
|
39
|
+
it 'returns the expected negative' do
|
40
|
+
expect(result).to eq(expected)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
33
44
|
context 'when defining a function' do
|
34
45
|
let(:block) do
|
35
46
|
proc do
|
@@ -52,6 +63,36 @@ describe Danica do
|
|
52
63
|
expect(result.to_tex).to eq(function.to_tex)
|
53
64
|
end
|
54
65
|
end
|
66
|
+
|
67
|
+
context 'when defining a negative output' do
|
68
|
+
let(:block) do
|
69
|
+
proc { -(sum(2, 3)) }
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:expected) do
|
73
|
+
Danica::Wrapper::Negative.new(
|
74
|
+
Danica::Operator::Addition.new(2, 3)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'wrap object with negative' do
|
79
|
+
expect(result).to eq(expected)
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'for a number' do
|
83
|
+
let(:block) do
|
84
|
+
proc { -num(2) }
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:expected) do
|
88
|
+
Danica::Wrapper::Negative.new(2)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'wrap object with negative' do
|
92
|
+
expect(result).to eq(expected)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
55
96
|
end
|
56
97
|
end
|
57
98
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
shared_examples 'an object with basic operation' do |operations:%i(+ - * /), ignore:[]|
|
1
|
+
shared_examples 'an object with basic operation' do |operations:%i(+ - * / **), ignore:[]|
|
2
2
|
(operations - [ ignore ].flatten).each do |operation|
|
3
3
|
it_behaves_like "an object with #{operation} operation"
|
4
4
|
end
|
@@ -75,3 +75,18 @@ shared_examples 'an object with - operation' do
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
shared_examples 'an object with ** operation' do
|
79
|
+
let(:other) { 104 }
|
80
|
+
let(:result) { subject ** other }
|
81
|
+
|
82
|
+
it { expect(result).to be_a(Danica::Operator::Power) }
|
83
|
+
|
84
|
+
it 'sets the subject as base' do
|
85
|
+
expect(result.base).to eq(subject)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'sets the other as exponent' do
|
89
|
+
expect(result.exponent).to eq(Danica::Wrapper::Number.new(other))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- ".gitignore"
|
147
147
|
- ".rspec"
|
148
148
|
- Gemfile
|
149
|
+
- LICENSE
|
149
150
|
- README.md
|
150
151
|
- Rakefile
|
151
152
|
- circle.yml
|
@@ -179,11 +180,11 @@ files:
|
|
179
180
|
- lib/danica/wrapper/number.rb
|
180
181
|
- lib/danica/wrapper/plus_minus.rb
|
181
182
|
- lib/danica/wrapper/variable.rb
|
183
|
+
- spec/integration/addition_spec.rb
|
184
|
+
- spec/integration/multiplication_spec.rb
|
182
185
|
- spec/integration/negative_spec.rb
|
183
|
-
- spec/integration/
|
186
|
+
- spec/integration/plus_minus_spec.rb
|
184
187
|
- spec/integration/power_spec.rb
|
185
|
-
- spec/integration/product_spec.rb
|
186
|
-
- spec/integration/sum_spec.rb
|
187
188
|
- spec/lib/danica/dsl_spec.rb
|
188
189
|
- spec/lib/danica/function_spec.rb
|
189
190
|
- spec/lib/danica/operator/addition_spec.rb
|
@@ -237,11 +238,11 @@ signing_key:
|
|
237
238
|
specification_version: 4
|
238
239
|
summary: Danica
|
239
240
|
test_files:
|
241
|
+
- spec/integration/addition_spec.rb
|
242
|
+
- spec/integration/multiplication_spec.rb
|
240
243
|
- spec/integration/negative_spec.rb
|
241
|
-
- spec/integration/
|
244
|
+
- spec/integration/plus_minus_spec.rb
|
242
245
|
- spec/integration/power_spec.rb
|
243
|
-
- spec/integration/product_spec.rb
|
244
|
-
- spec/integration/sum_spec.rb
|
245
246
|
- spec/lib/danica/dsl_spec.rb
|
246
247
|
- spec/lib/danica/function_spec.rb
|
247
248
|
- spec/lib/danica/operator/addition_spec.rb
|