danica 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Rakefile +0 -2
- data/danica.gemspec +4 -4
- data/lib/danica.rb +17 -7
- data/lib/danica/base_operations.rb +7 -0
- data/lib/danica/common.rb +2 -1
- data/lib/danica/constant.rb +3 -0
- data/lib/danica/{square_root.rb → cos.rb} +6 -4
- data/lib/danica/division.rb +3 -3
- data/lib/danica/exponential.rb +3 -3
- data/lib/danica/number.rb +1 -0
- data/lib/danica/power.rb +3 -3
- data/lib/danica/product.rb +3 -3
- data/lib/danica/sin.rb +21 -0
- data/lib/danica/squared_root.rb +20 -0
- data/lib/danica/variable.rb +1 -0
- data/lib/danica/version.rb +1 -1
- data/spec/lib/danica/constant_spec.rb +21 -1
- data/spec/lib/danica/cos_spec.rb +15 -0
- data/spec/lib/danica/division_spec.rb +4 -3
- data/spec/lib/danica/exponential_spec.rb +4 -0
- data/spec/lib/danica/function_spec.rb +9 -9
- data/spec/lib/danica/number_spec.rb +3 -1
- data/spec/lib/danica/power_spec.rb +4 -3
- data/spec/lib/danica/product_spec.rb +4 -0
- data/spec/lib/danica/sin_spec.rb +15 -0
- data/spec/lib/danica/{square_root_spec.rb → squared_root_spec.rb} +5 -1
- data/spec/lib/danica/sum_spec.rb +4 -0
- data/spec/lib/danica/variable_spec.rb +5 -1
- data/spec/spec_helper.rb +0 -6
- data/spec/support/shared_examples/base_operations.rb +4 -0
- data/spec/support/shared_examples/operator/chained.rb +2 -6
- data/spec/support/shared_examples/operator/single_input.rb +1 -3
- data/spec/support/shared_examples/variable.rb +1 -1
- metadata +32 -24
- data/Gemfile.lock +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cff829125a760a9befcca81f951b911840727946
|
4
|
+
data.tar.gz: 4bf19cd95e022ed7dfa9a5b330108be5121c0b1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f2f3be5cc0b9583dab38669b7157b7f7bd1083175a90257c07ee7c49760aa6665fa54033cb284314db1ba9582d61f29616f74e055a50a608fa16e2f23946ffa
|
7
|
+
data.tar.gz: 618caae9495087e7fde2796fd5b52694196642e67da7d595f152562325e0f4561596176a86f6029db3fe00bc0090e43477616f59119508f9836f2bced66c05ee
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/danica.gemspec
CHANGED
@@ -15,10 +15,10 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
|
-
spec.add_runtime_dependency 'activesupport'
|
19
|
-
spec.add_runtime_dependency 'activemodel'
|
20
|
-
spec.add_runtime_dependency 'concern_builder'
|
21
|
-
spec.add_runtime_dependency '
|
18
|
+
spec.add_runtime_dependency 'activesupport', '~> 5.1.4'
|
19
|
+
spec.add_runtime_dependency 'activemodel', '~> 5.1.4'
|
20
|
+
spec.add_runtime_dependency 'concern_builder', '~> 0.0.3'
|
21
|
+
spec.add_runtime_dependency 'darthjee-core_ext', '~> 1.4.1'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
24
24
|
spec.add_development_dependency 'rake'
|
data/lib/danica.rb
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
require 'active_model'
|
2
2
|
|
3
3
|
module Danica
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
autoload :BaseOperations, 'danica/base_operations'
|
5
|
+
autoload :Common, 'danica/common'
|
6
|
+
autoload :Number, 'danica/number'
|
7
|
+
autoload :Variable, 'danica/variable'
|
8
|
+
autoload :Operator, 'danica/operator'
|
9
|
+
autoload :Function, 'danica/function'
|
10
|
+
autoload :Exception, 'danica/exception'
|
11
|
+
autoload :Constant, 'danica/constant'
|
12
|
+
|
13
|
+
autoload :Product, 'danica/product'
|
14
|
+
autoload :Sum, 'danica/sum'
|
15
|
+
autoload :Division, 'danica/division'
|
16
|
+
autoload :Power, 'danica/power'
|
17
|
+
autoload :SquaredRoot, 'danica/squared_root'
|
18
|
+
autoload :Exponential, 'danica/exponential'
|
19
|
+
autoload :Sin, 'danica/sin'
|
20
|
+
autoload :Cos, 'danica/cos'
|
11
21
|
end
|
12
22
|
|
data/lib/danica/common.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Danica
|
2
2
|
class Common
|
3
|
+
include BaseOperations
|
3
4
|
require 'danica/common/class_methods'
|
4
5
|
require 'danica/common/variables_builder'
|
5
6
|
|
@@ -13,7 +14,7 @@ module Danica
|
|
13
14
|
vars_map = args.extract_options!
|
14
15
|
vars_map = variables_value_hash.merge(vars_map)
|
15
16
|
vars_map.each do |k, v|
|
16
|
-
unless v && (v.is_a?(
|
17
|
+
unless v && (v.is_a?(Integer) || v.valued?)
|
17
18
|
vars_map[k] = args.shift
|
18
19
|
end
|
19
20
|
end
|
data/lib/danica/constant.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Danica
|
2
2
|
class Constant
|
3
|
+
include BaseOperations
|
4
|
+
|
3
5
|
attr_reader :value, :latex, :gnu
|
4
6
|
|
5
7
|
def initialize(value, latex, gnu)
|
@@ -14,6 +16,7 @@ module Danica
|
|
14
16
|
|
15
17
|
def ==(other)
|
16
18
|
return false unless other.class == self.class
|
19
|
+
gnu == other.gnu && latex == other.latex && value == other.value
|
17
20
|
end
|
18
21
|
|
19
22
|
def to_tex
|
@@ -1,20 +1,22 @@
|
|
1
1
|
module Danica
|
2
|
-
class
|
2
|
+
class Cos < Operator
|
3
3
|
variables :variable
|
4
4
|
|
5
5
|
def to_f
|
6
|
-
|
6
|
+
Math.cos(variable.to_f)
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def tex_string
|
12
|
-
|
12
|
+
"cos(#{variable.to_tex})"
|
13
13
|
end
|
14
14
|
|
15
15
|
def gnu_string
|
16
|
-
|
16
|
+
"cos(#{variable.to_gnu})"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
|
22
|
+
|
data/lib/danica/division.rb
CHANGED
@@ -3,17 +3,17 @@ module Danica
|
|
3
3
|
variables :numerator, :denominator
|
4
4
|
|
5
5
|
def to_f
|
6
|
-
|
6
|
+
numerator.to_f / denominator.to_f
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def tex_string
|
12
|
-
|
12
|
+
"\\frac{#{numerator.to_tex}}{#{denominator.to_tex}}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def gnu_string
|
16
|
-
|
16
|
+
"#{numerator.to_gnu}/#{denominator.to_gnu}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/danica/exponential.rb
CHANGED
@@ -3,17 +3,17 @@ module Danica
|
|
3
3
|
variables :exponent
|
4
4
|
|
5
5
|
def to_f
|
6
|
-
|
6
|
+
Math.exp(exponent.to_f)
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def tex_string
|
12
|
-
|
12
|
+
"e^{#{exponent.to_tex}}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def gnu_string
|
16
|
-
|
16
|
+
"exp(#{exponent.to_gnu})"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/danica/number.rb
CHANGED
data/lib/danica/power.rb
CHANGED
@@ -3,17 +3,17 @@ module Danica
|
|
3
3
|
variables :base, :exponent
|
4
4
|
|
5
5
|
def to_f
|
6
|
-
|
6
|
+
base.to_f ** exponent.to_f
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def tex_string
|
12
|
-
|
12
|
+
"#{base.to_tex}^{#{exponent.to_tex}}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def gnu_string
|
16
|
-
|
16
|
+
"#{base.to_gnu}**#{exponent.to_gnu}"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/danica/product.rb
CHANGED
data/lib/danica/sin.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Danica
|
2
|
+
class Sin < Operator
|
3
|
+
variables :variable
|
4
|
+
|
5
|
+
def to_f
|
6
|
+
Math.sin(variable.to_f)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tex_string
|
12
|
+
"sin(#{variable.to_tex})"
|
13
|
+
end
|
14
|
+
|
15
|
+
def gnu_string
|
16
|
+
"sin(#{variable.to_gnu})"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Danica
|
2
|
+
class SquaredRoot < Operator
|
3
|
+
variables :variable
|
4
|
+
|
5
|
+
def to_f
|
6
|
+
Math.sqrt(variable.to_f)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tex_string
|
12
|
+
"\\sqrt{#{variable.to_tex}}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def gnu_string
|
16
|
+
"sqrt(#{variable.to_gnu})"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/danica/variable.rb
CHANGED
data/lib/danica/version.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Constant do
|
4
|
-
|
4
|
+
subject { described_class.new(2.5, :M, :m) }
|
5
|
+
let(:other) { described_class.new(3, :N, :n) }
|
6
|
+
|
7
|
+
it_behaves_like 'an object with + operation'
|
5
8
|
|
6
9
|
describe '#to_f' do
|
7
10
|
it 'has a value' do
|
@@ -26,5 +29,22 @@ describe Danica::Constant do
|
|
26
29
|
it { expect(subject).not_to respond_to(:latex=) }
|
27
30
|
it { expect(subject).not_to respond_to(:gnu=) }
|
28
31
|
end
|
32
|
+
|
33
|
+
describe '==' do
|
34
|
+
context 'when comparing with the same object' do
|
35
|
+
it { expect(subject).to eq(subject) }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when comparing with a diferent object' do
|
39
|
+
context 'with diferent values' do
|
40
|
+
it { expect(subject).not_to eq(other) }
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'with same values' do
|
44
|
+
let(:other) { described_class.new(2.5, :M, :m) }
|
45
|
+
it { expect(subject).to eq(other) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
29
49
|
end
|
30
50
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Danica::Cos do
|
4
|
+
it_behaves_like 'an object with + operation' do
|
5
|
+
subject { described_class.new(:x) }
|
6
|
+
end
|
7
|
+
|
8
|
+
it_behaves_like 'a operator with a single input value', {
|
9
|
+
variable_value: Math::PI,
|
10
|
+
expected_number: -1.0,
|
11
|
+
expected_number_text: '-1',
|
12
|
+
expected_tex: 'cos(X)',
|
13
|
+
expected_gnu: 'cos(X)'
|
14
|
+
}
|
15
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Division do
|
4
|
-
let(:
|
5
|
-
|
6
|
-
|
4
|
+
let(:variables) { [2, 4] }
|
5
|
+
subject { described_class.new(*variables) }
|
6
|
+
|
7
|
+
it_behaves_like 'an object with + operation'
|
7
8
|
|
8
9
|
it_behaves_like 'a operator that has two terms', :division, {
|
9
10
|
values: [ 2, 4 ],
|
@@ -43,7 +43,7 @@ describe Danica::Function do
|
|
43
43
|
}
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
subject { described_class::Spatial.new(variables) }
|
47
47
|
|
48
48
|
describe '#to_tex' do
|
49
49
|
context 'when creating the spatial operator for constantly accelerated movement' do
|
@@ -112,7 +112,7 @@ describe Danica::Function do
|
|
112
112
|
context 'when initializing with array' do
|
113
113
|
context 'as hash' do
|
114
114
|
let(:variables) { [ :t, 'a', {name: :S0, latex: 'S_0'}, { name: :V0, latex: 'V_0' } ] }
|
115
|
-
|
115
|
+
subject { described_class::Spatial.new(variables) }
|
116
116
|
|
117
117
|
it 'returns a hash with the variabels' do
|
118
118
|
expect(subject.variables_hash).to eq(expected)
|
@@ -123,7 +123,7 @@ describe Danica::Function do
|
|
123
123
|
context 'when initializing with sequence' do
|
124
124
|
context 'as hash' do
|
125
125
|
let(:variables) { [ :t, 'a', {name: :S0, latex: 'S_0'}, { name: :V0, latex: 'V_0' } ] }
|
126
|
-
|
126
|
+
subject { described_class::Spatial.new(*variables, {}) }
|
127
127
|
|
128
128
|
it 'returns a hash with the variabels' do
|
129
129
|
expect(subject.variables_hash).to eq(expected)
|
@@ -134,7 +134,7 @@ describe Danica::Function do
|
|
134
134
|
context 'when initializing with variables array' do
|
135
135
|
context 'as hash' do
|
136
136
|
let(:variables) { [ :t, 'a', {name: :S0, latex: 'S_0'}, { name: :V0, latex: 'V_0' } ] }
|
137
|
-
|
137
|
+
subject { described_class::Spatial.new(variables: variables) }
|
138
138
|
|
139
139
|
it 'returns a hash with the variabels' do
|
140
140
|
expect(subject.variables_hash).to eq(expected)
|
@@ -145,7 +145,7 @@ describe Danica::Function do
|
|
145
145
|
|
146
146
|
describe '#variables' do
|
147
147
|
context 'when initialized with an array of variables' do
|
148
|
-
|
148
|
+
subject { described_class::Spatial.new(variables: variables.values) }
|
149
149
|
let(:expected) { variables.values.map { |v| subject.send(:wrap_value, v)} }
|
150
150
|
it do
|
151
151
|
expect(subject.variables.compact).to eq(expected)
|
@@ -153,7 +153,7 @@ describe Danica::Function do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
context 'when not initializing all variables' do
|
156
|
-
|
156
|
+
subject { described_class::Spatial.new }
|
157
157
|
let(:time) { Danica::Variable.new(name: :t) }
|
158
158
|
|
159
159
|
context 'when initialized with an empty variable set' do
|
@@ -174,7 +174,7 @@ describe Danica::Function do
|
|
174
174
|
|
175
175
|
context 'when initializing with a variable set' do
|
176
176
|
let(:names) { [ :t, :a, :s0, :v0 ] }
|
177
|
-
|
177
|
+
subject { described_class::Spatial.new *names }
|
178
178
|
|
179
179
|
it 'returns the variables given oin initialization' do
|
180
180
|
expect(subject.variables.map(&:name)).to eq(names)
|
@@ -189,7 +189,7 @@ describe Danica::Function do
|
|
189
189
|
time: :t
|
190
190
|
}
|
191
191
|
end
|
192
|
-
|
192
|
+
subject { described_class::Spatial.new variables }
|
193
193
|
|
194
194
|
it 'returns the variables given on initialization' do
|
195
195
|
expect(subject.variables.map(&:name)).to eq(names)
|
@@ -206,7 +206,7 @@ describe Danica::Function do
|
|
206
206
|
let(:acceleration) { 3 }
|
207
207
|
let(:initial_space) { 1 }
|
208
208
|
let(:initial_velocity) { 1 }
|
209
|
-
|
209
|
+
subject { described_class::Spatial.new(time, acceleration, initial_space, initial_velocity) }
|
210
210
|
let(:expected) { initial_space + initial_velocity * time_value + acceleration * (time_value ** 2) / 2.0 }
|
211
211
|
|
212
212
|
it 'retuirns the calculated value' do
|
@@ -2,7 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Danica::Number do
|
4
4
|
let(:value) { 10 }
|
5
|
-
|
5
|
+
subject { described_class.new(value) }
|
6
|
+
|
7
|
+
it_behaves_like 'an object with + operation'
|
6
8
|
|
7
9
|
describe '#to_f' do
|
8
10
|
it 'returns the float of value' do
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Power do
|
4
|
-
let(:
|
5
|
-
|
6
|
-
|
4
|
+
let(:variables) { [2, 4] }
|
5
|
+
subject { described_class.new(*variables) }
|
6
|
+
|
7
|
+
it_behaves_like 'an object with + operation'
|
7
8
|
|
8
9
|
it_behaves_like 'a operator that has two terms', :power, {
|
9
10
|
values: [ 3, 2 ],
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Product do
|
4
|
+
subject { described_class.new(2,4) }
|
5
|
+
|
6
|
+
it_behaves_like 'an object with + operation'
|
7
|
+
|
4
8
|
it_behaves_like 'a operator that joins many variables with same operation', {
|
5
9
|
calculated: 24,
|
6
10
|
numeric_variables: [ 1.5, 2, 3.5 ],
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Danica::Sin do
|
4
|
+
subject { described_class.new(10) }
|
5
|
+
|
6
|
+
it_behaves_like 'an object with + operation'
|
7
|
+
|
8
|
+
it_behaves_like 'a operator with a single input value', {
|
9
|
+
variable_value: Math::PI / 2.0,
|
10
|
+
expected_number: 1.0,
|
11
|
+
expected_number_text: '1',
|
12
|
+
expected_tex: 'sin(X)',
|
13
|
+
expected_gnu: 'sin(X)'
|
14
|
+
}
|
15
|
+
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Danica::
|
3
|
+
describe Danica::SquaredRoot do
|
4
|
+
subject { described_class.new(9) }
|
5
|
+
|
6
|
+
it_behaves_like 'an object with + operation'
|
7
|
+
|
4
8
|
it_behaves_like 'a operator with a single input value', {
|
5
9
|
variable_value: 9,
|
6
10
|
expected_number: 3.0,
|
data/spec/lib/danica/sum_spec.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Sum do
|
4
|
+
subject { described_class.new(10, 2) }
|
5
|
+
|
6
|
+
it_behaves_like 'an object with + operation'
|
7
|
+
|
4
8
|
it_behaves_like 'a operator that joins many variables with same operation', {
|
5
9
|
calculated: 10,
|
6
10
|
numeric_variables: [ 1.5, 2.5, 3.5 ],
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Danica::Variable do
|
4
|
+
it_behaves_like 'an object with + operation' do
|
5
|
+
subject { described_class.new(value: 100) }
|
6
|
+
end
|
7
|
+
|
4
8
|
describe '#to_f' do
|
5
9
|
context 'when variable has no value' do
|
6
10
|
it { expect { subject.to_f }.to raise_error(Danica::Exception::NotDefined) }
|
@@ -8,7 +12,7 @@ describe Danica::Variable do
|
|
8
12
|
|
9
13
|
context 'when variable has value' do
|
10
14
|
let(:value) { 100 }
|
11
|
-
|
15
|
+
subject { described_class.new(value: value) }
|
12
16
|
|
13
17
|
it 'returns the value' do
|
14
18
|
expect(subject.to_f).to eq(value)
|
data/spec/spec_helper.rb
CHANGED
@@ -13,12 +13,6 @@ SimpleCov.start 'gem'
|
|
13
13
|
require 'pry-nav'
|
14
14
|
require 'danica'
|
15
15
|
|
16
|
-
require 'danica/product'
|
17
|
-
require 'danica/sum'
|
18
|
-
require 'danica/division'
|
19
|
-
require 'danica/power'
|
20
|
-
require 'danica/square_root'
|
21
|
-
require 'danica/exponential'
|
22
16
|
|
23
17
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
24
18
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
@@ -12,9 +12,7 @@ shared_examples 'a operator that knows how to calculate' do |arguments|
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
let(:numeric_variables){ (1..4).to_a }
|
15
|
-
|
16
|
-
described_class.new(*variables)
|
17
|
-
end
|
15
|
+
subject { described_class.new(*variables) }
|
18
16
|
|
19
17
|
describe 'to_f' do
|
20
18
|
it 'returns the sum of variables value' do
|
@@ -50,9 +48,7 @@ end
|
|
50
48
|
shared_examples 'a operator that knows how to write to a string' do |command, arguments|
|
51
49
|
let(:numeric_variables) { arguments[:numeric_variables] }
|
52
50
|
include_context 'variables are initialized', arguments[command], *%w(integer_expected string_expected float_expected)
|
53
|
-
|
54
|
-
described_class.new(*variables)
|
55
|
-
end
|
51
|
+
subject { described_class.new(*variables) }
|
56
52
|
|
57
53
|
describe "#{command}" do
|
58
54
|
let(:variables) do
|
@@ -1,9 +1,7 @@
|
|
1
1
|
shared_examples 'a operator with a single input value' do |arguments|
|
2
2
|
include_context 'variables are initialized', arguments, *%w(variable_value expected_number expected_tex expected_number_text expected_gnu)
|
3
3
|
let(:variable) { { name: "X", value: variable_value } }
|
4
|
-
|
5
|
-
described_class.new(variable)
|
6
|
-
end
|
4
|
+
subject { described_class.new(variable) }
|
7
5
|
|
8
6
|
describe '#to_f' do
|
9
7
|
context 'when variables are not numbers but have value' do
|
@@ -2,7 +2,7 @@ shared_examples 'a variable method to formated string' do |method, format|
|
|
2
2
|
let(:name) { :delta }
|
3
3
|
let(:value) { 10.0 }
|
4
4
|
let(:arguments) { { name: name, latex: '\delta', gnu: 'del' } }
|
5
|
-
|
5
|
+
subject { described_class.new(arguments) }
|
6
6
|
|
7
7
|
context "when #{format} is not defined" do
|
8
8
|
before { arguments.delete(format) }
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 5.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.1.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 5.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: concern_builder
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.0.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.0.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: darthjee-core_ext
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.4.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.4.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,15 +174,16 @@ files:
|
|
174
174
|
- ".gitignore"
|
175
175
|
- ".rspec"
|
176
176
|
- Gemfile
|
177
|
-
- Gemfile.lock
|
178
177
|
- README.md
|
179
178
|
- Rakefile
|
180
179
|
- danica.gemspec
|
181
180
|
- lib/danica.rb
|
181
|
+
- lib/danica/base_operations.rb
|
182
182
|
- lib/danica/common.rb
|
183
183
|
- lib/danica/common/class_methods.rb
|
184
184
|
- lib/danica/common/variables_builder.rb
|
185
185
|
- lib/danica/constant.rb
|
186
|
+
- lib/danica/cos.rb
|
186
187
|
- lib/danica/division.rb
|
187
188
|
- lib/danica/exception.rb
|
188
189
|
- lib/danica/exception/not_defined.rb
|
@@ -193,22 +194,26 @@ files:
|
|
193
194
|
- lib/danica/operator/chained.rb
|
194
195
|
- lib/danica/power.rb
|
195
196
|
- lib/danica/product.rb
|
196
|
-
- lib/danica/
|
197
|
+
- lib/danica/sin.rb
|
198
|
+
- lib/danica/squared_root.rb
|
197
199
|
- lib/danica/sum.rb
|
198
200
|
- lib/danica/variable.rb
|
199
201
|
- lib/danica/version.rb
|
200
202
|
- spec/lib/danica/constant_spec.rb
|
203
|
+
- spec/lib/danica/cos_spec.rb
|
201
204
|
- spec/lib/danica/division_spec.rb
|
202
205
|
- spec/lib/danica/exponential_spec.rb
|
203
206
|
- spec/lib/danica/function_spec.rb
|
204
207
|
- spec/lib/danica/number_spec.rb
|
205
208
|
- spec/lib/danica/power_spec.rb
|
206
209
|
- spec/lib/danica/product_spec.rb
|
207
|
-
- spec/lib/danica/
|
210
|
+
- spec/lib/danica/sin_spec.rb
|
211
|
+
- spec/lib/danica/squared_root_spec.rb
|
208
212
|
- spec/lib/danica/sum_spec.rb
|
209
213
|
- spec/lib/danica/variable_spec.rb
|
210
214
|
- spec/spec_helper.rb
|
211
215
|
- spec/support/shared_contexts/common.rb
|
216
|
+
- spec/support/shared_examples/base_operations.rb
|
212
217
|
- spec/support/shared_examples/operator/chained.rb
|
213
218
|
- spec/support/shared_examples/operator/dual_term.rb
|
214
219
|
- spec/support/shared_examples/operator/single_input.rb
|
@@ -232,23 +237,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
237
|
version: '0'
|
233
238
|
requirements: []
|
234
239
|
rubyforge_project:
|
235
|
-
rubygems_version: 2.
|
240
|
+
rubygems_version: 2.6.8
|
236
241
|
signing_key:
|
237
242
|
specification_version: 4
|
238
243
|
summary: Danica
|
239
244
|
test_files:
|
240
245
|
- spec/lib/danica/constant_spec.rb
|
246
|
+
- spec/lib/danica/cos_spec.rb
|
241
247
|
- spec/lib/danica/division_spec.rb
|
242
248
|
- spec/lib/danica/exponential_spec.rb
|
243
249
|
- spec/lib/danica/function_spec.rb
|
244
250
|
- spec/lib/danica/number_spec.rb
|
245
251
|
- spec/lib/danica/power_spec.rb
|
246
252
|
- spec/lib/danica/product_spec.rb
|
247
|
-
- spec/lib/danica/
|
253
|
+
- spec/lib/danica/sin_spec.rb
|
254
|
+
- spec/lib/danica/squared_root_spec.rb
|
248
255
|
- spec/lib/danica/sum_spec.rb
|
249
256
|
- spec/lib/danica/variable_spec.rb
|
250
257
|
- spec/spec_helper.rb
|
251
258
|
- spec/support/shared_contexts/common.rb
|
259
|
+
- spec/support/shared_examples/base_operations.rb
|
252
260
|
- spec/support/shared_examples/operator/chained.rb
|
253
261
|
- spec/support/shared_examples/operator/dual_term.rb
|
254
262
|
- spec/support/shared_examples/operator/single_input.rb
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
danica (2.0.1)
|
5
|
-
activemodel
|
6
|
-
activesupport
|
7
|
-
bidu-core_ext
|
8
|
-
concern_builder
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
activemodel (5.0.0.1)
|
14
|
-
activesupport (= 5.0.0.1)
|
15
|
-
activesupport (5.0.0.1)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (~> 0.7)
|
18
|
-
minitest (~> 5.1)
|
19
|
-
tzinfo (~> 1.1)
|
20
|
-
bidu-core_ext (1.2.2)
|
21
|
-
activesupport
|
22
|
-
codeclimate-test-reporter (0.5.0)
|
23
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
24
|
-
coderay (1.1.1)
|
25
|
-
concern_builder (0.0.2)
|
26
|
-
activesupport
|
27
|
-
concurrent-ruby (1.0.2)
|
28
|
-
diff-lcs (1.2.5)
|
29
|
-
docile (1.1.5)
|
30
|
-
i18n (0.7.0)
|
31
|
-
json (2.0.2)
|
32
|
-
method_source (0.8.2)
|
33
|
-
minitest (5.9.0)
|
34
|
-
pry (0.10.4)
|
35
|
-
coderay (~> 1.1.0)
|
36
|
-
method_source (~> 0.8.1)
|
37
|
-
slop (~> 3.4)
|
38
|
-
pry-nav (0.2.4)
|
39
|
-
pry (>= 0.9.10, < 0.11.0)
|
40
|
-
rake (11.2.2)
|
41
|
-
rspec (2.99.0)
|
42
|
-
rspec-core (~> 2.99.0)
|
43
|
-
rspec-expectations (~> 2.99.0)
|
44
|
-
rspec-mocks (~> 2.99.0)
|
45
|
-
rspec-core (2.99.2)
|
46
|
-
rspec-expectations (2.99.2)
|
47
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
48
|
-
rspec-mocks (2.99.4)
|
49
|
-
simplecov (0.12.0)
|
50
|
-
docile (~> 1.1.0)
|
51
|
-
json (>= 1.8, < 3)
|
52
|
-
simplecov-html (~> 0.10.0)
|
53
|
-
simplecov-html (0.10.0)
|
54
|
-
slop (3.6.0)
|
55
|
-
thread_safe (0.3.5)
|
56
|
-
tzinfo (1.2.2)
|
57
|
-
thread_safe (~> 0.1)
|
58
|
-
|
59
|
-
PLATFORMS
|
60
|
-
ruby
|
61
|
-
|
62
|
-
DEPENDENCIES
|
63
|
-
bundler (~> 1.6)
|
64
|
-
codeclimate-test-reporter
|
65
|
-
danica!
|
66
|
-
pry-nav
|
67
|
-
rake
|
68
|
-
rspec (~> 2.14)
|
69
|
-
rspec-mocks
|
70
|
-
simplecov
|
71
|
-
|
72
|
-
BUNDLED WITH
|
73
|
-
1.12.5
|