danica 2.7.6 → 3.0.0
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 +4 -4
- data/.circleci/config.yml +18 -10
- data/.rubocop.yml +11 -1
- data/.rubocop_todo.yml +50 -73
- data/Dockerfile +2 -2
- data/Gemfile +15 -0
- data/Makefile +7 -0
- data/README.md +7 -1
- data/danica.gemspec +3 -16
- data/danica.png +0 -0
- data/lib/danica/common.rb +13 -13
- data/lib/danica/dsl.rb +4 -4
- data/lib/danica/equation/builder.rb +2 -2
- data/lib/danica/equation.rb +6 -6
- data/lib/danica/exception.rb +2 -0
- data/lib/danica/expressable.rb +1 -1
- data/lib/danica/formatted.rb +10 -10
- data/lib/danica/function/name.rb +3 -3
- data/lib/danica/function.rb +2 -2
- data/lib/danica/operator/chained.rb +4 -4
- data/lib/danica/operator/division.rb +4 -4
- data/lib/danica/operator/functional.rb +3 -3
- data/lib/danica/operator/power.rb +4 -4
- data/lib/danica/variables_holder/alias_builder.rb +15 -1
- data/lib/danica/variables_holder/variables_builder.rb +11 -10
- data/lib/danica/variables_holder.rb +4 -4
- data/lib/danica/version.rb +1 -1
- data/lib/danica/wrapper/constant.rb +1 -5
- data/lib/danica/wrapper/group.rb +4 -4
- data/lib/danica/wrapper/negative.rb +2 -2
- data/lib/danica/wrapper/number.rb +1 -1
- data/lib/danica/wrapper/plus_minus.rb +4 -4
- data/lib/danica/wrapper/variable.rb +4 -4
- data/lib/danica/wrapper.rb +1 -1
- data/spec/integration/global/danica/operator/multiplication_spec.rb +1 -1
- data/spec/integration/readme/{equation_spec.rb → danica/equation_spec.rb} +2 -2
- data/spec/integration/readme/danica/expression/baskara_spec.rb +11 -0
- data/spec/integration/readme/{expression_spec.rb → danica/expression_spec.rb} +0 -8
- data/spec/integration/readme/danica/function/my_function_spec.rb +11 -0
- data/spec/integration/readme/danica/function/quadratic_sum_spec.rb +11 -0
- data/spec/integration/readme/{function_spec.rb → danica/function/spatial_spec.rb} +0 -32
- data/spec/integration/readme/danica/function_spec.rb +19 -0
- data/spec/integration/readme/{operator_spec.rb → danica/operator/inverse_spec.rb} +0 -22
- data/spec/integration/readme/danica/operator/my_operator_spec.rb +25 -0
- data/spec/integration/readme/{constant_spec.rb → danica/wrapper/constant_spec.rb} +2 -2
- data/spec/integration/readme/{number_spec.rb → danica/wrapper/number_spec.rb} +3 -3
- data/spec/integration/readme/{variables_spec.rb → danica/wrapper/variables_spec.rb} +15 -15
- data/spec/integration/readme/danica_spec.rb +3 -3
- data/spec/lib/danica/common_spec.rb +27 -27
- data/spec/lib/danica/dsl_spec.rb +1 -5
- data/spec/lib/danica/equation_spec.rb +7 -7
- data/spec/lib/danica/expression/gauss_spec.rb +6 -6
- data/spec/lib/danica/expression_spec.rb +39 -41
- data/spec/lib/danica/formatted_spec.rb +24 -23
- data/spec/lib/danica/function/name_spec.rb +6 -5
- data/spec/lib/danica/function_spec.rb +7 -18
- data/spec/lib/danica/operator/division_spec.rb +5 -5
- data/spec/lib/danica/operator_spec.rb +5 -5
- data/spec/lib/danica/variables_holder/store_spec.rb +9 -13
- data/spec/lib/danica/variables_holder_spec.rb +68 -67
- data/spec/lib/danica/wrapper/constant_spec.rb +19 -19
- data/spec/lib/danica/wrapper/group_spec.rb +7 -7
- data/spec/lib/danica/wrapper/negative_spec.rb +7 -7
- data/spec/lib/danica/wrapper/number_spec.rb +5 -5
- data/spec/lib/danica/wrapper/plus_minus_spec.rb +7 -7
- data/spec/lib/danica/wrapper/variable_spec.rb +6 -4
- data/spec/lib/danica/wrapper_spec.rb +3 -3
- data/spec/spec_helper.rb +4 -3
- data/spec/support/models/dummy/dsl_dummy.rb +5 -0
- data/spec/support/models/function/my_function.rb +1 -1
- data/spec/support/models/variables_holder/dummy.rb +1 -1
- data/spec/support/shared_examples/operator/chained.rb +2 -1
- data/spec/support/shared_examples/operator/single_input.rb +2 -1
- metadata +24 -233
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33b478d12b45fbf2d5ee53170698e864ba3bf0aedf21030ae406642b2f3e84c0
|
4
|
+
data.tar.gz: 767d15a104e9cc04c0e7fa2856d11d8c80dad4df1f8367f11e8264144ec2f913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0c759124e7c44377d1403000ca5bb6a23a162cde749777c28f7791cf7add1e892b01126e8648b42f1f3761b58f4334d8ebd801382e8c0de83a14817628af75e
|
7
|
+
data.tar.gz: 708dc6c0096c3c17adcfb2868d670dc2bd926a06439fc418fac8b34c6825fe5a89a669368efc72e36a3a451a09bc5ecb998a9c0f61882bfba01c5d5b27ca4299
|
data/.circleci/config.yml
CHANGED
@@ -7,8 +7,12 @@ workflows:
|
|
7
7
|
filters:
|
8
8
|
tags:
|
9
9
|
only: /.*/
|
10
|
+
- checks:
|
11
|
+
filters:
|
12
|
+
tags:
|
13
|
+
only: /.*/
|
10
14
|
- build-and-release:
|
11
|
-
requires: [test]
|
15
|
+
requires: [test, checks]
|
12
16
|
filters:
|
13
17
|
tags:
|
14
18
|
only: /\d+\.\d+\.\d+/
|
@@ -18,26 +22,30 @@ workflows:
|
|
18
22
|
jobs:
|
19
23
|
test:
|
20
24
|
docker:
|
21
|
-
- image: darthjee/
|
25
|
+
- image: darthjee/circleci_ruby_331:1.0.2
|
22
26
|
environment:
|
23
27
|
PROJECT: danica
|
24
28
|
steps:
|
25
29
|
- checkout
|
26
|
-
- run:
|
27
|
-
name: Prepare Coverage Test Report
|
28
|
-
command: cc-test-reporter before-build
|
29
30
|
- run:
|
30
31
|
name: Bundle Install
|
31
32
|
command: bundle install
|
32
33
|
- run:
|
33
34
|
name: RSpec
|
34
|
-
command: bundle exec rspec
|
35
|
+
command: COVERAGE_JSON=true bundle exec rspec
|
36
|
+
checks:
|
37
|
+
docker:
|
38
|
+
- image: darthjee/circleci_ruby_331:1.0.2
|
39
|
+
environment:
|
40
|
+
PROJECT: danica
|
41
|
+
steps:
|
42
|
+
- checkout
|
43
|
+
- run:
|
44
|
+
name: Bundle Install
|
45
|
+
command: bundle install
|
35
46
|
- run:
|
36
47
|
name: Rubocop
|
37
48
|
command: rubocop
|
38
|
-
- run:
|
39
|
-
name: Coverage Test Report
|
40
|
-
command: cc-test-reporter after-build --exit-code $?
|
41
49
|
- run:
|
42
50
|
name: Yardstick coverage check
|
43
51
|
command: bundle exec rake verify_measurements
|
@@ -52,7 +60,7 @@ jobs:
|
|
52
60
|
command: check_specs
|
53
61
|
build-and-release:
|
54
62
|
docker:
|
55
|
-
- image: darthjee/
|
63
|
+
- image: darthjee/circleci_ruby_331:1.0.2
|
56
64
|
environment:
|
57
65
|
PROJECT: danica
|
58
66
|
steps:
|
data/.rubocop.yml
CHANGED
@@ -2,8 +2,18 @@ require: rubocop-rspec
|
|
2
2
|
inherit_from: .rubocop_todo.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion:
|
5
|
+
TargetRubyVersion: 3.3
|
6
|
+
NewCops: enable
|
6
7
|
|
7
8
|
Metrics/BlockLength:
|
8
9
|
Exclude:
|
9
10
|
- 'spec/**/*_spec.rb'
|
11
|
+
|
12
|
+
Style/HashEachMethods:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Style/HashTransformKeys:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Style/HashTransformValues:
|
19
|
+
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
@@ -1,100 +1,87 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2025-07-27 22:39:13 UTC using RuboCop version 1.75.5.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Metrics/BlockLength:
|
17
|
-
Max: 54
|
9
|
+
# Offense count: 1
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: Severity, Include.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/RequireMFA:
|
14
|
+
Exclude:
|
15
|
+
- 'danica.gemspec'
|
18
16
|
|
19
|
-
# Offense count:
|
20
|
-
# Configuration parameters: CountComments,
|
17
|
+
# Offense count: 3
|
18
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
21
19
|
Metrics/MethodLength:
|
22
20
|
Max: 16
|
23
21
|
|
24
|
-
# Offense count: 1
|
25
|
-
# Configuration parameters: CustomIncludeMethods.
|
26
|
-
RSpec/EmptyExampleGroup:
|
27
|
-
Exclude:
|
28
|
-
- 'spec/lib/danica/variables_holder/store_spec.rb'
|
29
|
-
|
30
22
|
# Offense count: 4
|
31
|
-
# Configuration parameters:
|
32
|
-
RSpec/
|
33
|
-
|
34
|
-
- 'spec/integration/readme/constant_spec.rb'
|
35
|
-
- 'spec/integration/readme/equation_spec.rb'
|
36
|
-
- 'spec/integration/readme/number_spec.rb'
|
37
|
-
- 'spec/integration/readme/variables_spec.rb'
|
23
|
+
# Configuration parameters: AllowSubject.
|
24
|
+
RSpec/MultipleMemoizedHelpers:
|
25
|
+
Max: 8
|
38
26
|
|
39
|
-
# Offense count:
|
40
|
-
|
41
|
-
|
42
|
-
- 'spec/lib/danica/dsl_spec.rb'
|
43
|
-
|
44
|
-
# Offense count: 3
|
45
|
-
RSpec/MultipleDescribes:
|
46
|
-
Exclude:
|
47
|
-
- 'spec/integration/readme/expression_spec.rb'
|
48
|
-
- 'spec/integration/readme/function_spec.rb'
|
49
|
-
- 'spec/integration/readme/operator_spec.rb'
|
50
|
-
|
51
|
-
# Offense count: 241
|
52
|
-
# Configuration parameters: IgnoreSharedExamples.
|
27
|
+
# Offense count: 36
|
28
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
29
|
+
# SupportedStyles: always, named_only
|
53
30
|
RSpec/NamedSubject:
|
54
|
-
|
31
|
+
Exclude:
|
32
|
+
- 'spec/integration/global/danica/operator/addition_spec.rb'
|
33
|
+
- 'spec/integration/global/danica/operator/multiplication_spec.rb'
|
34
|
+
- 'spec/integration/global/danica/operator/power_spec.rb'
|
35
|
+
- 'spec/integration/global/danica/wrapper/negative_spec.rb'
|
36
|
+
- 'spec/integration/global/danica/wrapper/plus_minus_spec.rb'
|
37
|
+
- 'spec/integration/readme/danica/equation_spec.rb'
|
38
|
+
- 'spec/integration/readme/danica/expression/baskara_spec.rb'
|
39
|
+
- 'spec/integration/readme/danica/expression_spec.rb'
|
40
|
+
- 'spec/integration/readme/danica/formatted_spec.rb'
|
41
|
+
- 'spec/integration/readme/danica/function/my_function_spec.rb'
|
42
|
+
- 'spec/integration/readme/danica/function/quadratic_sum_spec.rb'
|
43
|
+
- 'spec/integration/readme/danica/function/spatial_spec.rb'
|
44
|
+
- 'spec/integration/readme/danica/function_spec.rb'
|
45
|
+
- 'spec/integration/readme/danica/operator/inverse_spec.rb'
|
46
|
+
- 'spec/integration/readme/danica/operator/my_operator_spec.rb'
|
55
47
|
|
56
48
|
# Offense count: 79
|
49
|
+
# Configuration parameters: AllowedGroups.
|
57
50
|
RSpec/NestedGroups:
|
58
51
|
Max: 6
|
59
52
|
|
60
|
-
# Offense count:
|
61
|
-
RSpec/
|
62
|
-
Exclude:
|
63
|
-
- 'spec/lib/danica/function_spec.rb'
|
64
|
-
|
65
|
-
# Offense count: 2
|
66
|
-
RSpec/RepeatedExampleGroupDescription:
|
53
|
+
# Offense count: 1
|
54
|
+
RSpec/PendingWithoutReason:
|
67
55
|
Exclude:
|
68
|
-
- 'spec/
|
56
|
+
- 'spec/lib/danica/variables_holder_spec.rb'
|
69
57
|
|
70
58
|
# Offense count: 35
|
71
|
-
#
|
72
|
-
# Configuration parameters:
|
59
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
60
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
|
73
61
|
# SupportedStyles: nested, compact
|
62
|
+
# SupportedStylesForClasses: , nested, compact
|
63
|
+
# SupportedStylesForModules: , nested, compact
|
74
64
|
Style/ClassAndModuleChildren:
|
75
65
|
Enabled: false
|
76
66
|
|
77
|
-
# Offense count: 36
|
78
|
-
Style/Documentation:
|
79
|
-
Enabled: false
|
80
|
-
|
81
67
|
# Offense count: 1
|
82
|
-
Style/
|
68
|
+
Style/DocumentDynamicEvalDefinition:
|
83
69
|
Exclude:
|
84
70
|
- 'lib/danica/operator/functional.rb'
|
85
71
|
|
72
|
+
# Offense count: 36
|
73
|
+
# Configuration parameters: AllowedConstants.
|
74
|
+
Style/Documentation:
|
75
|
+
Enabled: false
|
76
|
+
|
86
77
|
# Offense count: 1
|
78
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
87
79
|
# Configuration parameters: EnforcedStyle.
|
88
80
|
# SupportedStyles: left_coerce, right_coerce, single_coerce, fdiv
|
89
81
|
Style/FloatDivision:
|
90
82
|
Exclude:
|
91
83
|
- 'lib/danica/operator/division.rb'
|
92
84
|
|
93
|
-
# Offense count: 1
|
94
|
-
Style/MethodMissingSuper:
|
95
|
-
Exclude:
|
96
|
-
- 'lib/danica/formatted.rb'
|
97
|
-
|
98
85
|
# Offense count: 1
|
99
86
|
Style/MissingRespondToMissing:
|
100
87
|
Exclude:
|
@@ -105,19 +92,9 @@ Style/MultilineBlockChain:
|
|
105
92
|
Exclude:
|
106
93
|
- 'spec/lib/danica/function_spec.rb'
|
107
94
|
|
108
|
-
# Offense count:
|
109
|
-
#
|
110
|
-
# Configuration parameters:
|
111
|
-
# SupportedStyles: predicate, comparison
|
112
|
-
Style/NumericPredicate:
|
113
|
-
Exclude:
|
114
|
-
- 'spec/**/*'
|
115
|
-
- 'lib/danica/wrapper.rb'
|
116
|
-
- 'lib/danica/wrapper/number.rb'
|
117
|
-
|
118
|
-
# Offense count: 83
|
119
|
-
# Cop supports --auto-correct.
|
120
|
-
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
95
|
+
# Offense count: 9
|
96
|
+
# This cop supports safe autocorrection (--autocorrect).
|
97
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
121
98
|
# URISchemes: http, https
|
122
99
|
Layout/LineLength:
|
123
100
|
Max: 181
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
@@ -4,3 +4,18 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in credential_builder.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'bundler', '~> 2.6.8'
|
9
|
+
gem 'pry-nav', '~> 1.0.0'
|
10
|
+
gem 'rake', '>= 13.2.1'
|
11
|
+
gem 'rspec', '>= 3.13.0'
|
12
|
+
gem 'rspec-core', '>= 3.13.3'
|
13
|
+
gem 'rspec-expectations', '>= 3.13.3'
|
14
|
+
gem 'rspec-mocks', '>= 3.13.2'
|
15
|
+
gem 'rspec-support', '>= 3.13.2'
|
16
|
+
gem 'rubocop', '1.75.5'
|
17
|
+
gem 'rubocop-rspec', '3.6.0'
|
18
|
+
gem 'rubycritic', '>= 4.9.2'
|
19
|
+
gem 'simplecov', '~> 0.22.0'
|
20
|
+
gem 'yard', '>= 0.9.37'
|
21
|
+
gem 'yardstick', '>= 0.9.9'
|
data/Makefile
ADDED
data/README.md
CHANGED
@@ -6,11 +6,17 @@
|
|
6
6
|
[](https://www.codacy.com/gh/darthjee/danica/dashboard?utm_source=github.com&utm_medium=referral&utm_content=darthjee/danica&utm_campaign=Badge_Grade)
|
7
7
|
[](http://inch-ci.org/github/darthjee/danica)
|
8
8
|
|
9
|
+

|
10
|
+
|
9
11
|
A tool for math formulation on docs
|
10
12
|
|
13
|
+
Current Release: [3.0.0](https://github.com/darthjee/danica/tree/3.0.0)
|
14
|
+
|
15
|
+
[Next release](https://github.com/darthjee/danica/compare/2.2.7...master)
|
16
|
+
|
11
17
|
Yard Documentation
|
12
18
|
-------------------
|
13
|
-
[https://www.rubydoc.info/gems/danica/
|
19
|
+
[https://www.rubydoc.info/gems/danica/3.0.0](https://www.rubydoc.info/gems/danica/3.0.0)
|
14
20
|
|
15
21
|
## How to use
|
16
22
|
Add the gem to your project or just install the gem
|
data/danica.gemspec
CHANGED
@@ -13,22 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0")
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
16
|
spec.require_paths = ['lib']
|
17
|
+
spec.required_ruby_version = '>= 3.3.1'
|
18
18
|
|
19
|
-
spec.
|
20
|
-
spec.
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.16.1'
|
23
|
-
spec.add_development_dependency 'pry-nav', '~> 0.3.0'
|
24
|
-
spec.add_development_dependency 'rake', '>= 13.0.1'
|
25
|
-
spec.add_development_dependency 'rspec', '>= 3.9.0'
|
26
|
-
spec.add_development_dependency 'rubocop', '0.80.1'
|
27
|
-
spec.add_development_dependency 'rubocop-rspec', '1.38.1'
|
28
|
-
spec.add_development_dependency 'rubycritic', '>= 4.4.1'
|
29
|
-
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
30
|
-
spec.add_development_dependency 'yard', '>= 0.9.24'
|
31
|
-
spec.add_development_dependency 'yardstick', '>= 0.9.9'
|
32
|
-
|
33
|
-
spec.add_development_dependency 'rspec-mocks'
|
19
|
+
spec.add_dependency 'activesupport', '~> 7.2.x'
|
20
|
+
spec.add_dependency 'darthjee-core_ext', '~> 3.x'
|
34
21
|
end
|
data/danica.png
ADDED
Binary file
|
data/lib/danica/common.rb
CHANGED
@@ -28,20 +28,20 @@ module Danica
|
|
28
28
|
raise Exception::NotImplemented
|
29
29
|
end
|
30
30
|
|
31
|
-
def to_tex(**
|
32
|
-
to(:tex,
|
31
|
+
def to_tex(**)
|
32
|
+
to(:tex, **)
|
33
33
|
end
|
34
34
|
|
35
|
-
def to_gnu(**
|
36
|
-
to(:gnu,
|
35
|
+
def to_gnu(**)
|
36
|
+
to(:gnu, **)
|
37
37
|
end
|
38
38
|
|
39
|
-
def to(format, **
|
39
|
+
def to(format, **)
|
40
40
|
case format.to_sym
|
41
41
|
when :tex
|
42
|
-
to_tex(
|
42
|
+
to_tex(**)
|
43
43
|
when :gnu
|
44
|
-
to_gnu(
|
44
|
+
to_gnu(**)
|
45
45
|
when :f
|
46
46
|
to_f
|
47
47
|
else
|
@@ -49,16 +49,16 @@ module Danica
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def tex(**
|
53
|
-
formatted(format: :tex, **
|
52
|
+
def tex(**)
|
53
|
+
formatted(format: :tex, **)
|
54
54
|
end
|
55
55
|
|
56
|
-
def gnu(**
|
57
|
-
formatted(format: :gnu, **
|
56
|
+
def gnu(**)
|
57
|
+
formatted(format: :gnu, **)
|
58
58
|
end
|
59
59
|
|
60
|
-
def formatted(
|
61
|
-
Formatted.new(self,
|
60
|
+
def formatted(**)
|
61
|
+
Formatted.new(self, **)
|
62
62
|
end
|
63
63
|
|
64
64
|
def valued?
|
data/lib/danica/dsl.rb
CHANGED
@@ -23,8 +23,8 @@ module Danica
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def build(&
|
27
|
-
builder.instance_eval(&
|
26
|
+
def build(&)
|
27
|
+
builder.instance_eval(&)
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
@@ -36,8 +36,8 @@ module Danica
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def function(*variables, &
|
40
|
-
Function.build(*variables, &
|
39
|
+
def function(*variables, &)
|
40
|
+
Function.build(*variables, &).new
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/danica/equation.rb
CHANGED
@@ -7,17 +7,17 @@ module Danica
|
|
7
7
|
autoload :Builder, 'danica/equation/builder'
|
8
8
|
|
9
9
|
class << self
|
10
|
-
def build(*variables, &
|
11
|
-
Builder.new(*variables, &
|
10
|
+
def build(*variables, &)
|
11
|
+
Builder.new(*variables, &).build
|
12
12
|
end
|
13
13
|
|
14
|
-
def create(*variables, &
|
15
|
-
build(*variables, &
|
14
|
+
def create(*variables, &)
|
15
|
+
build(*variables, &).new
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def to(
|
20
|
-
"#{left.to(
|
19
|
+
def to(format, **)
|
20
|
+
"#{left.to(format, **)} = #{right.to(format, **)}"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/danica/exception.rb
CHANGED
data/lib/danica/expressable.rb
CHANGED
@@ -18,7 +18,7 @@ module Danica
|
|
18
18
|
module_eval do
|
19
19
|
define_method block_name do
|
20
20
|
instance_variable_get("@#{block_name}") ||
|
21
|
-
block && instance_variable_set("@#{block_name}", instance_eval(&block))
|
21
|
+
(block && instance_variable_set("@#{block_name}", instance_eval(&block)))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
data/lib/danica/formatted.rb
CHANGED
@@ -9,7 +9,7 @@ class Danica::Formatted
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def to_s
|
12
|
-
content.to(format, options)
|
12
|
+
content.to(format, **options)
|
13
13
|
end
|
14
14
|
|
15
15
|
def ==(other)
|
@@ -26,26 +26,26 @@ class Danica::Formatted
|
|
26
26
|
def repack(object)
|
27
27
|
self.class.new(
|
28
28
|
object,
|
29
|
-
options
|
29
|
+
**options
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
33
|
-
def to_tex(**
|
34
|
-
to(:tex, **
|
33
|
+
def to_tex(**)
|
34
|
+
to(:tex, **)
|
35
35
|
end
|
36
36
|
|
37
|
-
def to_gnu(**
|
38
|
-
to(:gnu, **
|
37
|
+
def to_gnu(**)
|
38
|
+
to(:gnu, **)
|
39
39
|
end
|
40
40
|
|
41
|
-
def to(format, **
|
42
|
-
content.to(format, options
|
41
|
+
def to(format, **)
|
42
|
+
content.to(format, **options, **)
|
43
43
|
end
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def method_missing(method, *
|
48
|
-
value = content.public_send(method, *
|
47
|
+
def method_missing(method, *)
|
48
|
+
value = content.public_send(method, *)
|
49
49
|
return value unless value.is_a?(Danica::Common)
|
50
50
|
|
51
51
|
repack(value)
|
data/lib/danica/function/name.rb
CHANGED
@@ -10,8 +10,8 @@ module Danica
|
|
10
10
|
@containers = variables.map { |v| wrap_value(v) }
|
11
11
|
end
|
12
12
|
|
13
|
-
def to(
|
14
|
-
"#{name}(#{description_variables(
|
13
|
+
def to(format, **)
|
14
|
+
"#{name}(#{description_variables(format, **)})"
|
15
15
|
end
|
16
16
|
|
17
17
|
def variables
|
@@ -22,7 +22,7 @@ module Danica
|
|
22
22
|
|
23
23
|
def description_variables(format, **options)
|
24
24
|
variables_for(format).map do |value|
|
25
|
-
value.to(format, options)
|
25
|
+
value.to(format, **options)
|
26
26
|
end.join(', ')
|
27
27
|
end
|
28
28
|
|
data/lib/danica/function.rb
CHANGED
@@ -16,8 +16,8 @@ module Danica
|
|
16
16
|
variables.include?(value.content)
|
17
17
|
end
|
18
18
|
|
19
|
-
def to(format, **
|
20
|
-
extractor = string_extractor(format, **
|
19
|
+
def to(format, **)
|
20
|
+
extractor = string_extractor(format, **)
|
21
21
|
variables.procedural_join(extractor, &join_proc(symbol(format)))
|
22
22
|
end
|
23
23
|
|
@@ -40,10 +40,10 @@ module Danica
|
|
40
40
|
proc { " #{symbol} " }
|
41
41
|
end
|
42
42
|
|
43
|
-
def string_extractor(
|
43
|
+
def string_extractor(format, **options)
|
44
44
|
proc do |parcel|
|
45
45
|
parcel = wrap_as_group(parcel)
|
46
|
-
parcel.to(
|
46
|
+
parcel.to(format, **options)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -10,12 +10,12 @@ module Danica
|
|
10
10
|
numerator.to_f / denominator.to_f
|
11
11
|
end
|
12
12
|
|
13
|
-
def to_tex(**
|
14
|
-
"\\frac{#{numerator.to_tex(
|
13
|
+
def to_tex(**)
|
14
|
+
"\\frac{#{numerator.to_tex(**)}}{#{denominator.to_tex(**)}}"
|
15
15
|
end
|
16
16
|
|
17
|
-
def to_gnu(**
|
18
|
-
"(#{numerator.to_gnu(
|
17
|
+
def to_gnu(**)
|
18
|
+
"(#{numerator.to_gnu(**)})/(#{denominator.to_gnu(**)})"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -17,13 +17,13 @@ module Danica
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_tex(**options)
|
20
|
-
'#{tex.gsub(':value:', "' + value.to_tex(options) + '")}'
|
20
|
+
'#{tex.gsub(':value:', "' + value.to_tex(**options) + '")}'
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_gnu(**options)
|
24
|
-
'#{gnu.gsub(':value:', "' + value.to_gnu(options) + '")}'
|
24
|
+
'#{gnu.gsub(':value:', "' + value.to_gnu(**options) + '")}'
|
25
25
|
end
|
26
|
-
))
|
26
|
+
), __FILE__, __LINE__ - 12)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -9,12 +9,12 @@ module Danica
|
|
9
9
|
base.to_f**exponent.to_f
|
10
10
|
end
|
11
11
|
|
12
|
-
def to_tex(**
|
13
|
-
"#{wrap_as_group(base).to_tex(
|
12
|
+
def to_tex(**)
|
13
|
+
"#{wrap_as_group(base).to_tex(**)}^{#{exponent.to_tex(**)}}"
|
14
14
|
end
|
15
15
|
|
16
|
-
def to_gnu(**
|
17
|
-
"#{wrap_as_group(base).to_gnu(
|
16
|
+
def to_gnu(**)
|
17
|
+
"#{wrap_as_group(base).to_gnu(**)}**(#{exponent.to_gnu(**)})"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -11,8 +11,22 @@ module Danica::VariablesHolder
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def build
|
14
|
+
change_keys
|
15
|
+
add_methods
|
16
|
+
add_aliases
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def change_keys
|
14
22
|
clazz.variables_hash.change_keys! { |k| k == origin ? destiny : k }
|
15
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_methods
|
26
|
+
VariablesBuilder.new(clazz, [destiny]).build
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_aliases
|
16
30
|
clazz.send(:alias_method, "#{origin}=", "#{destiny}=")
|
17
31
|
clazz.send(:alias_method, origin, destiny)
|
18
32
|
end
|