danica 2.3.0 → 2.3.1

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: ad28c3d7ea149780e400d116c83de57d427766fd
4
- data.tar.gz: 03df4bd255f7bd7f3ea1574ff3d762ee79ebcbb5
3
+ metadata.gz: f4c20cfa612c100125cf73a89cd2d30f02ab4f12
4
+ data.tar.gz: 3894bdce489e74dfdd9dd59320177e6dbbce10b3
5
5
  SHA512:
6
- metadata.gz: 6d5df83e1861e86792509782fe1c79767ee032d93dfe5b50a353f38960e2897ff1740cfe0876bb958fc1e23a82eb7959df35f3237aa14bff19964755b9953a99
7
- data.tar.gz: 239199aeb9ee44347f4721cb65b336926c9f38fef5678c384411c48bcbc57a41426d08aebebe896fbbb11abff5ac6764d8fed5927c58752a3693b5338a2ded6f
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
@@ -17,7 +17,7 @@ bundle install danica
17
17
 
18
18
  Now you can use in your project
19
19
 
20
- ###Quick Use
20
+ ### Quick Use
21
21
  Use Danica build to build and use your formula using ```Danica.build```
22
22
  ```ruby
23
23
  formula = Danica.build do
@@ -17,5 +17,13 @@ module Danica
17
17
  def -(other)
18
18
  self + negative(other)
19
19
  end
20
+
21
+ def **(other)
22
+ power(self, other)
23
+ end
24
+
25
+ def -@
26
+ negative(self)
27
+ end
20
28
  end
21
29
  end
@@ -32,6 +32,7 @@ module Danica
32
32
  DSL.register_wrapper(method)
33
33
  end
34
34
 
35
- DSL.register_operator :sum, :Addition
35
+ DSL.register_wrapper :num, :Number
36
+ DSL.register_operator :sum, :Addition
36
37
  DSL.register_operator :product, :Multiplication
37
38
  end
@@ -1,3 +1,3 @@
1
1
  module Danica
2
- VERSION = '2.3.0'
2
+ VERSION = '2.3.1'
3
3
  end
@@ -12,24 +12,25 @@ end
12
12
 
13
13
  shared_context 'a class with mapped dsl' do
14
14
  {
15
- addition: Danica::Operator::Addition,
16
- sum: Danica::Operator::Addition,
15
+ addition: Danica::Operator::Addition,
16
+ sum: Danica::Operator::Addition,
17
17
  multiplication: Danica::Operator::Multiplication,
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
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: Danica::Operator::SquaredRoot,
28
- exponential: Danica::Operator::Exponential,
29
- group: Danica::Wrapper::Group,
30
- negative: Danica::Wrapper::Negative,
31
- number: Danica::Wrapper::Number,
32
- plus_minus: Danica::Wrapper::PlusMinus
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', operations: %i(* /)
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
 
@@ -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.0
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-05 00:00:00.000000000 Z
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/positive_negative_spec.rb
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/positive_negative_spec.rb
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