danica 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b307b4b7177fbe4174f87da3d4bcad37028c635c
4
- data.tar.gz: ab3906ae623e2e99ce5223dffd5868bdac252a6f
3
+ metadata.gz: 204973e375504667567ab1246d44e05a1375e407
4
+ data.tar.gz: 0ec10d6273e79affbbb3624795cc00dd06321687
5
5
  SHA512:
6
- metadata.gz: 6fd900f7a94701ef2717be6177b373e5065b153cfc412431abf3337a1b88636d28146280d298c189cb5d7fc2eca0c337a01331d7e964b4e66a0f1213eb4e47d7
7
- data.tar.gz: 1b048a9de7ab0123ba587eae9ec651ff16b0e4e6fd5205aa476894ef8e55eafa8bbd9c87a6ad207985589d744bb1fe7e2da18fed09c882618e02d27f3bbeb3c2
6
+ metadata.gz: d63fd9fa21b3a5894d55d3a53d6af203f4bfb2f4f78162a9c7d38877f146c9a69f04851fffa6a331f03d2bd533f0945a3de70b88236e577af278e95fdc3cccae
7
+ data.tar.gz: 21d8fb184a94220c656d8631cf9b230f6f4911cc675333b5188176b379177499cb2522c4e2a306107d4347aa86585ec2c9ee281cedab70e47eaff743668b567f
@@ -1,29 +1,34 @@
1
1
  module Danica
2
2
  module BaseOperations
3
3
  def +(other)
4
- return other + self if other.is_a?(Operator::Addition)
5
- addition(self, other)
4
+ formatted_operation other, addition(self, other)
6
5
  end
7
6
 
8
7
  def *(other)
9
- return other * self if other.is_a?(Operator::Multiplication)
10
- multiplication(self, other)
8
+ formatted_operation other, multiplication(self, other)
11
9
  end
12
10
 
13
11
  def /(other)
14
- division(self, other)
12
+ formatted_operation other, division(self, other)
15
13
  end
16
14
 
17
15
  def -(other)
18
- self + negative(other)
16
+ formatted_operation other, (self + negative(other))
19
17
  end
20
18
 
21
19
  def **(other)
22
- power(self, other)
20
+ formatted_operation other, power(self, other)
23
21
  end
24
22
 
25
23
  def -@
26
24
  negative(self)
27
25
  end
26
+
27
+ private
28
+
29
+ def formatted_operation(other, value)
30
+ return other.repack(value) if other.is_a?(Danica::Formatted)
31
+ value
32
+ end
28
33
  end
29
34
  end
data/lib/danica/common.rb CHANGED
@@ -4,23 +4,23 @@ module Danica
4
4
  include Wrapper
5
5
  include DSL
6
6
 
7
- class << self
8
- def default_value(name, value)
9
- define_method(name) { |*_| value }
10
- end
11
-
12
- def default_values(*names, value)
13
- names.each do |name|
14
- default_value(name, value)
15
- end
16
- end
17
- end
18
-
19
7
  default_values :constant?, :signaled?, :container?, :variable?,
20
8
  :variable_holder?, false
21
9
  default_value :priority, 1
22
10
  end
23
11
 
12
+ class_methods do
13
+ def default_value(name, value)
14
+ define_method(name) { |*_| value }
15
+ end
16
+
17
+ def default_values(*names, value)
18
+ names.each do |name|
19
+ default_value(name, value)
20
+ end
21
+ end
22
+ end
23
+
24
24
  def to_f
25
25
  raise Exception::NotImplemented
26
26
  end
@@ -47,11 +47,15 @@ module Danica
47
47
  end
48
48
 
49
49
  def tex(**options)
50
- Formatted.new(self, :tex, options)
50
+ formatted(:tex, options)
51
51
  end
52
52
 
53
53
  def gnu(**options)
54
- Formatted.new(self, :gnu, options)
54
+ formatted(:gnu, options)
55
+ end
56
+
57
+ def formatted(*args)
58
+ Formatted.new(self, *args)
55
59
  end
56
60
 
57
61
  def valued?
@@ -0,0 +1,37 @@
1
+ module Danica
2
+ module DSL
3
+ class Builder
4
+ attr_reader :method, :claz, :base
5
+
6
+ def initialize(method, claz=nil, base=nil)
7
+ @method = method
8
+ @claz = claz
9
+ @base = base
10
+ end
11
+
12
+ def build
13
+ DSL.register_class(method, clazz)
14
+ end
15
+
16
+ private
17
+
18
+ def clazz
19
+ @clazz ||= build_clazz
20
+ end
21
+
22
+ def build_clazz
23
+ return clazz_from_method unless claz
24
+ return claz if claz.is_a? Class
25
+ clazz_from_string
26
+ end
27
+
28
+ def clazz_from_method
29
+ [base.to_s, method.to_s.camelize].compact.join('::').constantize
30
+ end
31
+
32
+ def clazz_from_string
33
+ [base, claz.to_s].compact.join('::').constantize
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/danica/dsl.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Danica
2
2
  module DSL
3
+ autoload :Builder, 'danica/dsl/builder'
4
+
3
5
  class << self
4
6
  def register_operator(method, clazz=nil)
5
7
  register(method, clazz, 'Danica::Operator')
@@ -10,9 +12,11 @@ module Danica
10
12
  end
11
13
 
12
14
  def register(method, clazz=nil, base=nil)
13
- define_method method do |*args|
14
- clazz = [base.to_s, method.to_s.camelize].compact.join('::').constantize unless clazz
15
- clazz = [base, clazz.to_s].compact.join('::').constantize unless clazz.is_a? Class
15
+ Builder.new(method, clazz, base).build
16
+ end
17
+
18
+ def register_class(method, clazz)
19
+ define_method(method) do |*args|
16
20
  clazz.new(*args)
17
21
  end
18
22
  end
@@ -2,5 +2,16 @@ class Danica::Exception < ::Exception
2
2
  class NotDefined < self; end
3
3
  class FormattedNotFound < self; end
4
4
  class NotImplemented < self; end
5
+ class InvalidInput < self
6
+ attr_reader :value
7
+ def initialize(value)
8
+ @value = value
9
+ super
10
+ end
11
+
12
+ def message
13
+ "invalid input class #{value.class}"
14
+ end
15
+ end
5
16
  end
6
17
 
@@ -2,26 +2,24 @@ module Danica
2
2
  module Expressable extend ::ActiveSupport::Concern
3
3
  include VariablesHolder
4
4
 
5
- included do
6
- class << self
7
- def built_with(block_name)
8
- self.send(:delegate, :to, :to_f, to: block_name)
5
+ class_methods do
6
+ def built_with(block_name)
7
+ self.delegate :to, :to_f, to: block_name
9
8
 
10
- self.send(:define_singleton_method, :build) do |*vars, &block|
11
- Class.new(self) do
12
- variables(*vars)
9
+ self.define_singleton_method(:build) do |*vars, &block|
10
+ Class.new(self) do
11
+ variables(*vars)
13
12
 
14
- private
13
+ private
15
14
 
16
- module_eval("define_method :#{block_name} do
15
+ module_eval("define_method :#{block_name} do
17
16
  @#{block_name} ||= instance_eval(&block) if block
18
17
  end")
19
- end
20
18
  end
19
+ end
21
20
 
22
- self.send(:define_singleton_method, :create) do |*vars, &block|
23
- build(*vars, &block).new
24
- end
21
+ self.define_singleton_method(:create) do |*vars, &block|
22
+ build(*vars, &block).new
25
23
  end
26
24
  end
27
25
  end
@@ -17,14 +17,18 @@ class Danica::Formatted
17
17
  other.format == format
18
18
  end
19
19
 
20
+ def repack(object)
21
+ self.class.new(
22
+ object,
23
+ format
24
+ )
25
+ end
26
+
20
27
  private
21
28
 
22
29
  def method_missing(method, *args)
23
30
  value = content.public_send(method, *args)
24
31
  return value unless value.is_a?(Danica::Common)
25
- self.class.new(
26
- value,
27
- format
28
- )
32
+ repack(value)
29
33
  end
30
34
  end
@@ -2,10 +2,6 @@ module Danica
2
2
  class Operator::Addition < Operator::Chained
3
3
  default_value :priority, 1
4
4
 
5
- def +(other)
6
- repack(other)
7
- end
8
-
9
5
  private
10
6
 
11
7
  default_value :symbol, :+
@@ -45,11 +45,6 @@ module Danica
45
45
  end
46
46
  end
47
47
 
48
- def repack(other)
49
- other_variables = other.is_a?(self.class) ? other.variables : [ other ]
50
- self.class.new(variables + other_variables)
51
- end
52
-
53
48
  def chain(numbers)
54
49
  numbers.inject do |a,b|
55
50
  chain_operation(a,b)
@@ -1,7 +1,7 @@
1
1
  module Danica
2
2
  class Operator::Division < Operator
3
3
  variables :numerator, :denominator
4
- default_value :priority, 2
4
+ default_value :priority, 3
5
5
  default_value :is_grouped?, true
6
6
 
7
7
  def to_f
@@ -1,10 +1,6 @@
1
1
  module Danica
2
2
  class Operator::Multiplication < Operator::Chained
3
- default_value :priority, 2
4
-
5
- def *(other)
6
- repack(other)
7
- end
3
+ default_value :priority, 3
8
4
 
9
5
  private
10
6
 
@@ -3,7 +3,7 @@ module Danica
3
3
  include VariablesHolder
4
4
  include BaseOperations
5
5
 
6
- default_value :priority, 3
6
+ default_value :priority, 4
7
7
  default_value :is_grouped?, false
8
8
 
9
9
  def ==(other)
@@ -13,32 +13,32 @@ module Danica
13
13
 
14
14
  included do
15
15
  default_value :variable_holder?, true
16
+ end
16
17
 
17
- class << self
18
- def variables(*names)
19
- VariablesBuilder.new(names, self).build
20
- end
18
+ class_methods do
19
+ def variables(*names)
20
+ VariablesBuilder.new(names, self).build
21
+ end
21
22
 
22
- def variable_alias(origin, destiny)
23
- AliasBuilder.new(origin, destiny, self).build
24
- end
23
+ def variable_alias(origin, destiny)
24
+ AliasBuilder.new(origin, destiny, self).build
25
+ end
25
26
 
26
- def variables_names
27
- variables_hash.keys
28
- end
27
+ def variables_names
28
+ variables_hash.keys
29
+ end
29
30
 
30
- def variables_hash
31
- @variables_hash ||= superclass_variables_hash.dup
32
- end
31
+ def variables_hash
32
+ @variables_hash ||= superclass_variables_hash.dup
33
+ end
33
34
 
34
- def reset_variables
35
- @superclass_variables_hash = {}
36
- @variables_hash = nil
37
- end
35
+ def reset_variables
36
+ @superclass_variables_hash = {}
37
+ @variables_hash = nil
38
+ end
38
39
 
39
- def superclass_variables_hash
40
- @superclass_variables_hash ||= (superclass.try(:variables_hash) || {})
41
- end
40
+ def superclass_variables_hash
41
+ @superclass_variables_hash ||= (superclass.try(:variables_hash) || {})
42
42
  end
43
43
  end
44
44
 
@@ -1,3 +1,3 @@
1
1
  module Danica
2
- VERSION = '2.7.1'
2
+ VERSION = '2.7.2'
3
3
  end
@@ -4,7 +4,7 @@ module Danica
4
4
  attr_accessor :content
5
5
 
6
6
  delegate :to_f, :contentd?, :to, :to_tex, :to_gnu, :priority, :grouped?,
7
- :signaled?, :constant?, :valued?, :*, :+, :-, :/, :**,
7
+ :signaled?, :constant?, :valued?, :*, :+, :-, :/, :**, :-@,
8
8
  :variables, :variable?, to: :content
9
9
 
10
10
  default_value :container?, true
@@ -6,6 +6,8 @@ module Danica
6
6
 
7
7
  def self.wrap_value(value)
8
8
  case value
9
+ when Formatted
10
+ value.content
9
11
  when Numeric
10
12
  wrap_numeric(value)
11
13
  when Hash
@@ -13,6 +15,7 @@ module Danica
13
15
  when String, Symbol, NilClass
14
16
  Variable.new(name: value)
15
17
  else
18
+ raise Exception::InvalidInput, value unless value.is_a?(Danica::Common)
16
19
  value
17
20
  end
18
21
  end
data/lib/danica.rb CHANGED
@@ -20,6 +20,7 @@ module Danica
20
20
 
21
21
  class << self
22
22
  delegate :build, to: :builder
23
+ attr_accessor :debug
23
24
 
24
25
  def builder
25
26
  @builder ||= Builder.new
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'integration of formatted objects' do
4
+ let(:variable) { Danica.build(:v) { v } }
5
+ subject do
6
+ variable.tex
7
+ end
8
+
9
+ context 'when interacting with a multiplication' do
10
+ let(:other) do
11
+ Danica.build(:x, :y) { x * y }
12
+ end
13
+ context 'when multipling another multiplication' do
14
+ let(:result) { subject * other }
15
+ it do
16
+ expect(result).to be_a(Danica::Formatted)
17
+ end
18
+
19
+ it 'knows how to convert it to string' do
20
+ expect(result.to_s).to eq('v \\cdot x \\cdot y')
21
+ end
22
+ end
23
+
24
+ context 'when multiplicated by another multiplication' do
25
+ let(:result) { other * subject }
26
+ it do
27
+ expect(result).to be_a(Danica::Formatted)
28
+ end
29
+
30
+ it 'knows how to convert it to string' do
31
+ expect(result.to_s).to eq('x \\cdot y \\cdot v')
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'when interacting with a sum' do
37
+ let(:other) do
38
+ Danica.build(:x, :y) { x + y }
39
+ end
40
+ context 'when summing another sum' do
41
+ let(:result) { subject + other }
42
+ it do
43
+ expect(result).to be_a(Danica::Formatted)
44
+ end
45
+
46
+ it 'knows how to convert it to string' do
47
+ expect(result.to_s).to eq('v + x + y')
48
+ end
49
+ end
50
+
51
+ context 'when added by another sum' do
52
+ let(:result) { other + subject }
53
+ it do
54
+ expect(result).to be_a(Danica::Formatted)
55
+ end
56
+
57
+ it 'knows how to convert it to string' do
58
+ expect(result.to_s).to eq('x + y + v')
59
+ end
60
+ end
61
+ end
62
+
63
+ context 'when operating multiplication and subtraction all toguether' do
64
+ let(:variable) { Danica::Wrapper::Variable.new(:v) }
65
+ let(:x) { Danica::Wrapper::Variable.new(:x) }
66
+ let(:result) { x * (-subject) }
67
+ it do
68
+ expect(result).to be_a(Danica::Formatted)
69
+ end
70
+
71
+ it 'knows how to convert it to string' do
72
+ expect(result.to_s).to eq('x \cdot \left(-v\right)')
73
+ end
74
+ end
75
+ end
@@ -41,4 +41,63 @@ describe 'integration of multiplication' do
41
41
  end
42
42
  end
43
43
  end
44
+
45
+ describe 'when calling * operator' do
46
+ subject do
47
+ Danica::Operator::Multiplication.new(:x, :y)
48
+ end
49
+ let(:variable) { Danica::Wrapper::Variable.new(:v) }
50
+ let(:result) { subject * variable }
51
+
52
+ it do
53
+ expect(result).to be_a(Danica::Operator::Multiplication)
54
+ end
55
+
56
+ it 'knows how to order variables' do
57
+ expect(result.to_gnu).to eq('x * y * v')
58
+ end
59
+
60
+ context 'when called from the other' do
61
+ let(:result) { variable * subject }
62
+
63
+ it do
64
+ expect(result).to be_a(Danica::Operator::Multiplication)
65
+ end
66
+
67
+ it 'knows how to order variables' do
68
+ expect(result.to_gnu).to eq('v * x * y')
69
+ end
70
+ end
71
+ end
72
+
73
+ context 'when multiplicating a negative number' do
74
+ let(:x) { Danica::Wrapper::Variable.new(:x) }
75
+ let(:y) { Danica::Wrapper::Variable.new(:y) }
76
+ let(:negative) { -y }
77
+ let(:result) { x * negative }
78
+
79
+ it do
80
+ expect(result).to be_a(Danica::Operator::Multiplication)
81
+ end
82
+
83
+ it 'knows how to order variables' do
84
+ expect(result.to_gnu).to eq('x * (-y)')
85
+ end
86
+
87
+ context 'when negative parcel is an expression' do
88
+ let(:negative) { Danica.build(:y) { -y } }
89
+
90
+ it 'knows how to order variables' do
91
+ expect(result.to_gnu).to eq('x * (-y)')
92
+ end
93
+ end
94
+
95
+ context 'when negative is the negative of an expression' do
96
+ let(:negative) { -Danica.build(:y) { y } }
97
+
98
+ it 'knows how to order variables' do
99
+ expect(result.to_gnu).to eq('x * (-y)')
100
+ end
101
+ end
102
+ end
44
103
  end
@@ -19,6 +19,36 @@ describe 'integration of negative' do
19
19
  expect(subject.to_tex).to eq('-\left(1 + 2 + 3\right)')
20
20
  end
21
21
  end
22
+
23
+ describe 'when it is the result of an expression' do
24
+ let(:x) { Danica::Wrapper::Variable.new(:x) }
25
+ let(:y) { Danica::Wrapper::Variable.new(:y) }
26
+ let(:z) { Danica::Wrapper::Variable.new(:z) }
27
+ let(:negative_parcel) { y + z }
28
+ subject do
29
+ x - negative_parcel
30
+ end
31
+
32
+ it 'wraps parcel into a group' do
33
+ expect(subject.to_gnu).to eq('x -(y + z)')
34
+ end
35
+
36
+ context 'when the negative parcel is an expression' do
37
+ let(:negative_parcel) { Danica.build(:y, :z) { y + z } }
38
+
39
+ it 'wraps parcel into a group' do
40
+ expect(subject.to_gnu).to eq('x -(y + z)')
41
+ end
42
+
43
+ context 'when negative has just one element' do
44
+ let(:negative_parcel) { Danica.build(:y) { y } }
45
+
46
+ it 'wraps parcel into a group' do
47
+ expect(subject.to_gnu).to eq('x -y')
48
+ end
49
+ end
50
+ end
51
+ end
22
52
  end
23
53
  end
24
54
 
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'formatting' do
4
+ subject do
5
+ value = 1 / 3.0
6
+ Danica.build(:x) do
7
+ x + value
8
+ end
9
+ end
10
+
11
+ describe '#to_tex' do
12
+ it 'formats the output' do
13
+ expect(subject.to_tex(decimals: 3)).to eq('x + 0.333')
14
+ end
15
+ end
16
+ end
17
+
18
+ describe Danica::Formatted do
19
+ let(:expression) do
20
+ value = 1 / 3.0
21
+ Danica.build(:x) do
22
+ x + value
23
+ end
24
+ end
25
+ subject do
26
+ expression.tex(decimals: 3)
27
+ end
28
+
29
+ describe '#to_tex' do
30
+ it 'formats the output' do
31
+ expect(subject.to_s).to eq('x + 0.333')
32
+ end
33
+ end
34
+ end
@@ -123,4 +123,14 @@ describe Danica::Common do
123
123
  end
124
124
  end
125
125
  end
126
+
127
+ describe '#formatted' do
128
+ it do
129
+ expect(subject.formatted(:gnu)).to be_a(Danica::Formatted)
130
+ end
131
+
132
+ it 'knows how to return to build the string string' do
133
+ expect(subject.formatted(:gnu, decimals: 3).to_s).to eq('gnu {:decimals=>3}')
134
+ end
135
+ end
126
136
  end
@@ -1,5 +1,29 @@
1
1
  require 'spec_helper'
2
2
 
3
+
4
+ shared_examples 'a formatted result' do |output|
5
+ it do
6
+ expect(result).to be_a(described_class)
7
+ end
8
+
9
+ it 'keeps being able to parse format' do
10
+ expect(result.to_s).to eq(output)
11
+ end
12
+ end
13
+
14
+ shared_examples('a formatted object that responds to basic operations') do |operations_map|
15
+ operations_map.each do |operation, (output, reverse_output)|
16
+ describe(operation.to_s) do
17
+ let(:result) { subject.public_send(operation, 2) }
18
+ it_behaves_like 'a formatted result', output
19
+
20
+ context 'when doing it backwards' do
21
+ let(:result) { Danica::Wrapper::Number.new(2).public_send(operation, subject) }
22
+ it_behaves_like 'a formatted result', reverse_output
23
+ end
24
+ end
25
+ end
26
+ end
3
27
  describe Danica::Formatted do
4
28
  let(:content) { Danica::Wrapper::Variable.new(latex: :V, gnuplot: :v) }
5
29
  let(:format) { :tex }
@@ -41,25 +65,13 @@ describe Danica::Formatted do
41
65
  end
42
66
 
43
67
  describe 'operators' do
44
- describe '+' do
45
- it do
46
- expect(subject + 2).to be_a(described_class)
47
- end
48
-
49
- it 'keeps being able to parse format' do
50
- expect((subject + 2).to_s).to eq('V + 2')
51
- end
52
- end
53
-
54
- describe '*' do
55
- it do
56
- expect(subject * 2).to be_a(described_class)
57
- end
58
-
59
- it 'keeps being able to parse format' do
60
- expect((subject * 2).to_s).to eq('V \cdot 2')
61
- end
62
- end
68
+ it_behaves_like 'a formatted object that responds to basic operations', {
69
+ :+ => ['V + 2', '2 + V'],
70
+ :- => ['V -2', '2 -V'],
71
+ :* => ['V \cdot 2', '2 \cdot V'],
72
+ :/ => ['\frac{V}{2}', '\frac{2}{V}'],
73
+ :** => ['V^{2}', '2^{V}']
74
+ }
63
75
 
64
76
  describe '-@' do
65
77
  it do
@@ -13,19 +13,15 @@ describe Danica::Operator::Addition do
13
13
 
14
14
  it_behaves_like 'an object with basic operation', ignore: %i(+ -)
15
15
  it_behaves_like 'an object with + operation' do
16
- let(:subject_included) { 10 }
17
-
18
16
  context 'when other is also a addition' do
19
17
  let(:other) { described_class.new(200, 5) }
20
18
 
21
19
  it 'includes the addition parcels' do
22
- expect(result).to include(200)
20
+ expect(result.to_gnu).to eq('10 + 2 + 200 + 5')
23
21
  end
24
22
  end
25
23
  end
26
- it_behaves_like 'an object with - operation' do
27
- let(:subject_included) { 10 }
28
- end
24
+ it_behaves_like 'an object with - operation'
29
25
 
30
26
  it_behaves_like 'a operator that joins many variables with same operation', {
31
27
  calculated: 10,
@@ -12,13 +12,11 @@ describe Danica::Operator::Multiplication do
12
12
  it_behaves_like 'an object that respond to basic_methods'
13
13
 
14
14
  it_behaves_like 'an object with * operation' do
15
- let(:subject_included) { 4 }
16
-
17
- context 'when other is also a addition' do
15
+ context 'when other is also a multiplication' do
18
16
  let(:other) { described_class.new(200, 5) }
19
17
 
20
- it 'includes the addition parcels' do
21
- expect(result).to include(200)
18
+ it 'includes the addition parcels in the result' do
19
+ expect(result.to_gnu).to eq('2 * 4 * 200 * 5')
22
20
  end
23
21
  end
24
22
  end
@@ -32,17 +32,21 @@ describe Danica::Wrapper do
32
32
  x: Danica::Wrapper::Variable,
33
33
  'x' => Danica::Wrapper::Variable,
34
34
  10 => Danica::Wrapper::Number,
35
+ 10.5 => Danica::Wrapper::Number,
35
36
  -10 => Danica::Wrapper::Negative,
36
- { name: :x } => Danica::Wrapper::Variable
37
+ { name: :x } => Danica::Wrapper::Variable,
38
+ { value: 10, latex: :x, gnuplot: :X } => Danica::Wrapper::Constant,
39
+ Danica::Wrapper::Variable.new(:x).tex => Danica::Wrapper::Variable,
40
+ Danica.build(:x) { x } => Danica::Expression
37
41
  }
38
42
 
39
- context 'when value is a Hash' do
40
- context 'but it is a constant' do
41
- let(:value) { { value: 10, latex: :x, gnuplot: :X } }
43
+ context 'when value is non accepted' do
44
+ let(:value) { Object.new }
42
45
 
43
- it do
44
- expect(subject.wrapped_value.content).to be_a(Danica::Wrapper::Constant)
45
- end
46
+ it do
47
+ expect do
48
+ subject.wrapped_value.content
49
+ end.to raise_error(Danica::Exception::InvalidInput)
46
50
  end
47
51
  end
48
52
  end
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.7.1
4
+ version: 2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-18 00:00:00.000000000 Z
11
+ date: 2018-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -143,6 +143,7 @@ files:
143
143
  - lib/danica/builder.rb
144
144
  - lib/danica/common.rb
145
145
  - lib/danica/dsl.rb
146
+ - lib/danica/dsl/builder.rb
146
147
  - lib/danica/equation.rb
147
148
  - lib/danica/equation/builder.rb
148
149
  - lib/danica/exception.rb
@@ -178,6 +179,7 @@ files:
178
179
  - lib/danica/wrapper/plus_minus.rb
179
180
  - lib/danica/wrapper/variable.rb
180
181
  - spec/integration/addition_spec.rb
182
+ - spec/integration/formatted_spec.rb
181
183
  - spec/integration/multiplication_spec.rb
182
184
  - spec/integration/negative_spec.rb
183
185
  - spec/integration/plus_minus_spec.rb
@@ -186,6 +188,7 @@ files:
186
188
  - spec/integration/readme/danica_spec.rb
187
189
  - spec/integration/readme/equation_spec.rb
188
190
  - spec/integration/readme/expression_spec.rb
191
+ - spec/integration/readme/formatting_spec.rb
189
192
  - spec/integration/readme/function_spec.rb
190
193
  - spec/integration/readme/number_spec.rb
191
194
  - spec/integration/readme/operator_spec.rb
@@ -262,6 +265,7 @@ specification_version: 4
262
265
  summary: Danica
263
266
  test_files:
264
267
  - spec/integration/addition_spec.rb
268
+ - spec/integration/formatted_spec.rb
265
269
  - spec/integration/multiplication_spec.rb
266
270
  - spec/integration/negative_spec.rb
267
271
  - spec/integration/plus_minus_spec.rb
@@ -270,6 +274,7 @@ test_files:
270
274
  - spec/integration/readme/danica_spec.rb
271
275
  - spec/integration/readme/equation_spec.rb
272
276
  - spec/integration/readme/expression_spec.rb
277
+ - spec/integration/readme/formatting_spec.rb
273
278
  - spec/integration/readme/function_spec.rb
274
279
  - spec/integration/readme/number_spec.rb
275
280
  - spec/integration/readme/operator_spec.rb