dr_light 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 288117834749641c8f72f5992cbaa22268342014b919bae7b8305af38c139dcb
4
+ data.tar.gz: 923ee123b123b4222c0f4ccc35e7f370256519ab0cd6df6ae1a5589c031eab31
5
+ SHA512:
6
+ metadata.gz: e8222dea48e0d17380267b9e5ce7a9d316580212a88213f04fd1ef625998f8d25996d9c6ec88e2143a507d628bbbb26068f9517833f49ffc158de41de9203d87
7
+ data.tar.gz: 51fec29e95479c2a3bfbe61787dcc438726b2563d56ea80d43a9a8d45d701f391995902a92abe53724985dfee0395455248ab37ac633db40e99c8067687cb5c5
@@ -0,0 +1,36 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: darthjee/circleci_ruby_gems:0.2.3
6
+ environment:
7
+ PROJECT: dr_light
8
+ steps:
9
+ - checkout
10
+ - run:
11
+ name: Prepare Coverage Test Report
12
+ command: cc-test-reporter before-build
13
+ - run:
14
+ name: Bundle Install
15
+ command: bundle install
16
+ - run:
17
+ name: RSpec
18
+ command: bundle exec rspec
19
+ - run:
20
+ name: Rubocop
21
+ command: rubocop
22
+ - run:
23
+ name: Coverage Test Report
24
+ command: cc-test-reporter after-build --exit-code $?
25
+ - run:
26
+ name: Yardstick coverage check
27
+ command: bundle exec rake verify_measurements
28
+ - run:
29
+ name: Check version documentation
30
+ command: check_readme.sh
31
+ - run:
32
+ name: Rubycritcs check
33
+ command: rubycritic.sh
34
+ - run:
35
+ name: Check unit tests
36
+ command: check_specs
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ coverages
2
+ pkg
3
+ Gemfile.lock
4
+ coverage
5
+ doc
6
+ .yardoc/
7
+ measurement/
8
+ **/*.swp
9
+ rubycritic/
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ require: rubocop-rspec
2
+ inherit_from: .rubocop_todo.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
6
+
7
+ RSpec/NestedGroups:
8
+ Max: 4
9
+
10
+ Metrics/BlockLength:
11
+ Exclude:
12
+ - 'spec/**/*_spec.rb'
13
+ - '*.gemspec'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,15 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-08-15 12:50:21 +0000 using RuboCop version 0.73.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ Style/Documentation:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+ - 'test/**/*'
14
+ - 'lib/dr_light.rb'
15
+ - 'lib/dr_light/scientific_number.rb'
data/Dockerfile ADDED
@@ -0,0 +1,30 @@
1
+ FROM darthjee/ruby_gems:0.2.3 as base
2
+ FROM darthjee/scripts:0.1.2 as scripts
3
+
4
+ ######################################
5
+
6
+ FROM base as builder
7
+
8
+ COPY --chown=app ./ /home/app/app/
9
+ COPY --chown=app:app --from=scripts /home/scripts/builder/bundle_builder.sh /usr/local/sbin/
10
+
11
+ ENV HOME_DIR /home/app
12
+ RUN bundle_builder.sh
13
+
14
+ #######################
15
+ #FINAL IMAGE
16
+ FROM base
17
+ RUN mkdir lib/dr_light -p
18
+
19
+ USER root
20
+
21
+ COPY --chown=app:app --from=builder /home/app/bundle/gems /usr/local/bundle/gems
22
+ COPY --chown=app:app --from=builder /home/app/bundle/cache /usr/local/bundle/cache
23
+ COPY --chown=app:app --from=builder /home/app/bundle/specifications /usr/local/bundle/specifications
24
+ COPY --chown=app:app --from=builder /home/app/bundle/bin /usr/local/bundle/bin
25
+ COPY --chown=app:app --from=builder /home/app/bundle/extensions /usr/local/bundle/extensions
26
+
27
+ COPY --chown=app ./*.gemspec ./Gemfile /home/app/app/
28
+ COPY --chown=app ./lib/dr_light/version.rb /home/app/app/lib/dr_light/
29
+ USER app
30
+ RUN bundle install
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 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 ADDED
@@ -0,0 +1,14 @@
1
+ DrLight
2
+ ========
3
+ [![Code Climate](https://codeclimate.com/github/darthjee/dr_light/badges/gpa.svg)](https://codeclimate.com/github/darthjee/dr_light)
4
+ [![Test Coverage](https://codeclimate.com/github/darthjee/dr_light/badges/coverage.svg)](https://codeclimate.com/github/darthjee/dr_light/coverage)
5
+ [![Issue Count](https://codeclimate.com/github/darthjee/dr_light/badges/issue_count.svg)](https://codeclimate.com/github/darthjee/dr_light)
6
+ [![Gem Version](https://badge.fury.io/rb/dr_light.svg)](https://badge.fury.io/rb/dr_light)
7
+
8
+
9
+ ![dr_light](https://raw.githubusercontent.com/darthjee/dr_light/master/dr_light.jpg)
10
+
11
+ Yard Documentation
12
+ -------------------
13
+ https://www.rubydoc.info/gems/dr_light/0.0.1
14
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+ require 'yardstick/rake/measurement'
6
+ require './config/yardstick'
7
+ require './config/rubycritc'
8
+
9
+ RSpec::Core::RakeTask.new
10
+
11
+ task default: :spec
12
+ task test: :spec
@@ -0,0 +1 @@
1
+ ignore: []
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubycritic/rake_task'
4
+
5
+ RubyCritic::RakeTask.new do |task|
6
+ options = %w[
7
+ --path rubycritic/
8
+ --no-browser
9
+ ]
10
+ task.options = options.join(' ')
11
+ task.paths = %w[lib]
12
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yardstick/rake/measurement'
4
+ require 'yardstick/rake/verify'
5
+ require 'yaml'
6
+
7
+ options = YAML.load_file('config/yardstick.yml')
8
+
9
+ Yardstick::Rake::Measurement.new(:yardstick_measure, options) do |measurement|
10
+ measurement.output = 'measurement/report.txt'
11
+ end
12
+
13
+ Yardstick::Rake::Verify.new(:verify_measurements, options)
@@ -0,0 +1,33 @@
1
+ threshold: 100
2
+ require_exact_threshold: false
3
+ rules:
4
+ ApiTag::Presence:
5
+ enabled: true
6
+ exclude: []
7
+ ApiTag::Inclusion:
8
+ enabled: true
9
+ exclude: []
10
+ ApiTag::ProtectedMethod:
11
+ enabled: true
12
+ exclude: []
13
+ ApiTag::PrivateMethod:
14
+ enabled: true
15
+ exclude: []
16
+ ExampleTag:
17
+ enabled: true
18
+ exclude: []
19
+ ReturnTag:
20
+ enabled: true
21
+ exclude: []
22
+ Summary::Presence:
23
+ enabled: true
24
+ exclude: []
25
+ Summary::Length:
26
+ enabled: true
27
+ exclude: []
28
+ Summary::Delimiter:
29
+ enabled: true
30
+ exclude: []
31
+ Summary::SingleLine:
32
+ enabled: true
33
+ exclude: []
@@ -0,0 +1,23 @@
1
+ version: '3'
2
+ services:
3
+ base: &base
4
+ image: dr_light
5
+ working_dir: /home/app/app
6
+ volumes:
7
+ - .:/home/app/app
8
+
9
+ base_build:
10
+ <<: *base
11
+ build: .
12
+ command: echo done
13
+
14
+ dr_light:
15
+ <<: *base
16
+ container_name: dr_light
17
+ depends_on: [base_build]
18
+ command: /bin/bash -c 'rspec'
19
+
20
+ test_all:
21
+ <<: *base
22
+ depends_on: [base_build]
23
+ command: /bin/bash -c 'rspec && yard && rake yardstick_measure && rake verify_measurements'
data/dr_light.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'dr_light/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'dr_light'
9
+ gem.version = DrLight::VERSION
10
+ gem.authors = ['DarthJee']
11
+ gem.email = ['darthjee@gmail.com']
12
+ gem.homepage = 'https://github.com/darthjee/dr_light'
13
+ gem.description = 'Gem for science tools'
14
+ gem.summary = gem.description
15
+ gem.required_ruby_version = '>= 2.5.0'
16
+
17
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
20
+ gem.require_paths = ['lib']
21
+
22
+ gem.add_development_dependency 'bundler', '~> 1.16.1'
23
+ gem.add_development_dependency 'pry', '0.12.2'
24
+ gem.add_development_dependency 'pry-nav', '0.3.0'
25
+ gem.add_development_dependency 'rake', '12.3.3'
26
+ gem.add_development_dependency 'reek', '5.4.0'
27
+ gem.add_development_dependency 'rspec', '3.8.0'
28
+ gem.add_development_dependency 'rspec-core', '3.8.0'
29
+ gem.add_development_dependency 'rspec-expectations', '3.8.3'
30
+ gem.add_development_dependency 'rspec-mocks', '3.8.0'
31
+ gem.add_development_dependency 'rspec-support', '3.8.0'
32
+ gem.add_development_dependency 'rubocop', '0.73.0'
33
+ gem.add_development_dependency 'rubocop-rspec', '1.33.0'
34
+ gem.add_development_dependency 'rubycritic', '4.1.0'
35
+ gem.add_development_dependency 'simplecov', '0.17.0'
36
+ gem.add_development_dependency 'yard', '0.9.20'
37
+ gem.add_development_dependency 'yardstick', '0.9.9'
38
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrLight
4
+ class ScientificNumber
5
+ # @author darthjee
6
+ # @api public
7
+ #
8
+ # Class responsible for formatting the values of
9
+ # {ScientificNumber}
10
+ class Formatter
11
+ attr_reader :exponential, :significant,
12
+ :value, :deviance
13
+
14
+ # @param value [Nuber] number to be exibed
15
+ # @param deviance [Number] deviance of number
16
+ def initialize(value:, deviance:)
17
+ @value = value
18
+ @deviance = deviance
19
+ @significant = 1
20
+ @exponential = 0
21
+ format_value
22
+ end
23
+
24
+ # Returns the string of the format expected for
25
+ # {ScientificNumber#to_s}
26
+ #
27
+ # @return [String]
28
+ def format_string
29
+ ["%<value>.#{significant}f"].tap do |values|
30
+ values << '(%<deviance>d)' unless deviance.zero?
31
+ values << 'e%<exponential>d' unless exponential.zero?
32
+ end.join
33
+ end
34
+
35
+ private
36
+
37
+ def format_value
38
+ normalize_value
39
+ normalize_deviance
40
+ end
41
+
42
+ def normalize_value
43
+ order = order_from(@value)
44
+ @exponential += order
45
+ @value /= (10.0**order)
46
+ @deviance /= (10.0**order)
47
+ end
48
+
49
+ def normalize_deviance
50
+ return if @deviance.zero?
51
+
52
+ if order_difference.negative?
53
+ @value *= (10.0**order_difference)
54
+ @exponential -= order_difference
55
+ else
56
+ @significant += order_difference
57
+ end
58
+
59
+ @deviance *= 10 * (10.0**order_difference)
60
+ @deviance += 0.5
61
+ end
62
+
63
+ def order_from(number)
64
+ format('%<number>e', number: number).gsub(/.*e/, '').to_i
65
+ end
66
+
67
+ def order_difference
68
+ @order_difference ||=
69
+ order_from(@value) - order_from(@deviance)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrLight
4
+ # @author darthjee
5
+ # @api public
6
+ #
7
+ # Number to be exibed in scientific number
8
+ class ScientificNumber
9
+ autoload :Formatter, 'dr_light/scientific_number/formatter'
10
+ attr_reader :value, :deviance
11
+
12
+ # @param value [Nuber] number to be exibed
13
+ # @param deviance [Number] deviance of number
14
+ def initialize(value, deviance = 0)
15
+ @value = value
16
+ @deviance = deviance
17
+ end
18
+
19
+ # string representation of number
20
+ def to_s
21
+ format(
22
+ formatter.format_string,
23
+ value: formatter.value,
24
+ exponential: formatter.exponential,
25
+ deviance: formatter.deviance
26
+ )
27
+ end
28
+
29
+ private
30
+
31
+ def formatter
32
+ @formatter ||= Formatter.new(
33
+ value: value,
34
+ deviance: deviance
35
+ )
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrLight
4
+ VERSION = '0.0.1'
5
+ end
data/lib/dr_light.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @author darthjee
4
+ # @ai public
5
+ #
6
+ # Pack of science usefull classes
7
+ module DrLight
8
+ autoload :ScientificNumber, 'dr_light/scientific_number'
9
+ end
@@ -0,0 +1,439 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe DrLight::ScientificNumber do
6
+ subject(:number) { described_class.new(value, deviance) }
7
+
8
+ describe '#to_s' do
9
+ context 'when there is no deviance' do
10
+ subject(:number) { described_class.new(value) }
11
+
12
+ context 'when negative number only has 2 digits and order 10' do
13
+ let(:value) { -12 }
14
+
15
+ it 'shows 2 digits' do
16
+ expect(number.to_s).to eq('-1.2e1')
17
+ end
18
+ end
19
+
20
+ context 'when negative number has 3 digits and order 10^2' do
21
+ let(:value) { -123 }
22
+
23
+ it 'shows 2 digits' do
24
+ expect(number.to_s).to eq('-1.2e2')
25
+ end
26
+ end
27
+
28
+ context 'when negative number only has 2 digits and order 1' do
29
+ let(:value) { -1.2 }
30
+
31
+ it 'shows 2 digits' do
32
+ expect(number.to_s).to eq('-1.2')
33
+ end
34
+ end
35
+
36
+ context 'when negative number has 3 digits and order 1' do
37
+ let(:value) { -1.23 }
38
+
39
+ it 'shows 2 digits' do
40
+ expect(number.to_s).to eq('-1.2')
41
+ end
42
+ end
43
+
44
+ context 'when negative number only has 2 digits and order 10^-1' do
45
+ let(:value) { -0.12 }
46
+
47
+ it 'shows 2 digits' do
48
+ expect(number.to_s).to eq('-1.2e-1')
49
+ end
50
+ end
51
+
52
+ context 'when negative number has 3 digits and order 10^-1' do
53
+ let(:value) { -0.123 }
54
+
55
+ it 'shows 2 digits' do
56
+ expect(number.to_s).to eq('-1.2e-1')
57
+ end
58
+ end
59
+
60
+ context 'when positive number only has 2 digits and order 10' do
61
+ let(:value) { 12 }
62
+
63
+ it 'shows 2 digits' do
64
+ expect(number.to_s).to eq('1.2e1')
65
+ end
66
+ end
67
+
68
+ context 'when positive number has 3 digits and order 10^2' do
69
+ let(:value) { 123 }
70
+
71
+ it 'shows 2 digits' do
72
+ expect(number.to_s).to eq('1.2e2')
73
+ end
74
+ end
75
+
76
+ context 'when positive number only has 2 digits and order 1' do
77
+ let(:value) { 1.2 }
78
+
79
+ it 'shows 2 digits' do
80
+ expect(number.to_s).to eq('1.2')
81
+ end
82
+ end
83
+
84
+ context 'when positive number has 3 digits and order 1' do
85
+ let(:value) { 1.23 }
86
+
87
+ it 'shows 2 digits' do
88
+ expect(number.to_s).to eq('1.2')
89
+ end
90
+ end
91
+
92
+ context 'when positive number only has 2 digits and order 10^-1' do
93
+ let(:value) { 0.12 }
94
+
95
+ it 'shows 2 digits' do
96
+ expect(number.to_s).to eq('1.2e-1')
97
+ end
98
+ end
99
+
100
+ context 'when positive number has 3 digits and order 10^-1' do
101
+ let(:value) { 0.123 }
102
+
103
+ it 'shows 2 digits' do
104
+ expect(number.to_s).to eq('1.2e-1')
105
+ end
106
+ end
107
+ end
108
+
109
+ context 'when deviance has the same order as the value' do
110
+ context 'when negative number only has 2 digits and order 10' do
111
+ let(:value) { -12 }
112
+ let(:deviance) { 13 }
113
+
114
+ it 'shows 2 digits' do
115
+ expect(number.to_s).to eq('-1.2(13)e1')
116
+ end
117
+ end
118
+
119
+ context 'when negative number has 3 digits and order 10^2' do
120
+ let(:value) { -123 }
121
+ let(:deviance) { 134 }
122
+
123
+ it 'shows 2 digits' do
124
+ expect(number.to_s).to eq('-1.2(13)e2')
125
+ end
126
+ end
127
+
128
+ context 'when negative number only has 2 digits and order 1' do
129
+ let(:value) { -1.2 }
130
+ let(:deviance) { 1.3 }
131
+
132
+ it 'shows 2 digits' do
133
+ expect(number.to_s).to eq('-1.2(13)')
134
+ end
135
+ end
136
+
137
+ context 'when negative number has 3 digits and order 1' do
138
+ let(:value) { -1.23 }
139
+ let(:deviance) { 1.34 }
140
+
141
+ it 'shows 2 digits' do
142
+ expect(number.to_s).to eq('-1.2(13)')
143
+ end
144
+ end
145
+
146
+ context 'when negative number only has 2 digits and order 10^-1' do
147
+ let(:value) { -0.12 }
148
+ let(:deviance) { 0.13 }
149
+
150
+ it 'shows 2 digits' do
151
+ expect(number.to_s).to eq('-1.2(13)e-1')
152
+ end
153
+ end
154
+
155
+ context 'when negative number has 3 digits and order 10^-1' do
156
+ let(:value) { -0.123 }
157
+ let(:deviance) { 0.134 }
158
+
159
+ it 'shows 2 digits' do
160
+ expect(number.to_s).to eq('-1.2(13)e-1')
161
+ end
162
+ end
163
+
164
+ context 'when positive number only has 2 digits and order 10' do
165
+ let(:value) { 12 }
166
+ let(:deviance) { 13 }
167
+
168
+ it 'shows 2 digits' do
169
+ expect(number.to_s).to eq('1.2(13)e1')
170
+ end
171
+ end
172
+
173
+ context 'when positive number has 3 digits and order 10^2' do
174
+ let(:value) { 123 }
175
+ let(:deviance) { 134 }
176
+
177
+ it 'shows 2 digits' do
178
+ expect(number.to_s).to eq('1.2(13)e2')
179
+ end
180
+ end
181
+
182
+ context 'when positive number only has 2 digits and order 1' do
183
+ let(:value) { 1.2 }
184
+ let(:deviance) { 1.3 }
185
+
186
+ it 'shows 2 digits' do
187
+ expect(number.to_s).to eq('1.2(13)')
188
+ end
189
+ end
190
+
191
+ context 'when positive number has 3 digits and order 1' do
192
+ let(:value) { 1.23 }
193
+ let(:deviance) { 1.34 }
194
+
195
+ it 'shows 2 digits' do
196
+ expect(number.to_s).to eq('1.2(13)')
197
+ end
198
+ end
199
+
200
+ context 'when positive number only has 2 digits and order 10^-1' do
201
+ let(:value) { 0.12 }
202
+ let(:deviance) { 0.13 }
203
+
204
+ it 'shows 2 digits' do
205
+ expect(number.to_s).to eq('1.2(13)e-1')
206
+ end
207
+ end
208
+
209
+ context 'when positive number has 3 digits and order 10^-1' do
210
+ let(:value) { 0.123 }
211
+ let(:deviance) { 0.134 }
212
+
213
+ it 'shows 2 digits' do
214
+ expect(number.to_s).to eq('1.2(13)e-1')
215
+ end
216
+ end
217
+ end
218
+
219
+ context 'when deviance has smaller order than the value' do
220
+ context 'when negative number only has 2 digits and order 10' do
221
+ let(:value) { -12 }
222
+ let(:deviance) { 0.13 }
223
+
224
+ it 'shows 2 deviance digits' do
225
+ expect(number.to_s).to eq('-1.200(13)e1')
226
+ end
227
+ end
228
+
229
+ context 'when negative number has 3 digits and order 10^2' do
230
+ let(:value) { -123 }
231
+ let(:deviance) { 1.34 }
232
+
233
+ it 'shows 2 deviance digits' do
234
+ expect(number.to_s).to eq('-1.230(13)e2')
235
+ end
236
+ end
237
+
238
+ context 'when negative number only has 2 digits and order 1' do
239
+ let(:value) { -1.2 }
240
+ let(:deviance) { 0.013 }
241
+
242
+ it 'shows 2 deviance digits' do
243
+ expect(number.to_s).to eq('-1.200(13)')
244
+ end
245
+ end
246
+
247
+ context 'when negative number has 3 digits and order 1' do
248
+ let(:value) { -1.23 }
249
+ let(:deviance) { 0.0134 }
250
+
251
+ it 'shows 2 deviance digits' do
252
+ expect(number.to_s).to eq('-1.230(13)')
253
+ end
254
+ end
255
+
256
+ context 'when negative number only has 2 digits and order 10^-1' do
257
+ let(:value) { -0.12 }
258
+ let(:deviance) { 0.0013 }
259
+
260
+ it 'shows 2 deviance digits' do
261
+ expect(number.to_s).to eq('-1.200(13)e-1')
262
+ end
263
+ end
264
+
265
+ context 'when negative number has 3 digits and order 10^-1' do
266
+ let(:value) { -0.123 }
267
+ let(:deviance) { 0.00134 }
268
+
269
+ it 'shows 2 deviance digits' do
270
+ expect(number.to_s).to eq('-1.230(13)e-1')
271
+ end
272
+ end
273
+
274
+ context 'when positive number only has 2 digits and order 10' do
275
+ let(:value) { 12 }
276
+ let(:deviance) { 0.13 }
277
+
278
+ it 'shows 2 deviance digits' do
279
+ expect(number.to_s).to eq('1.200(13)e1')
280
+ end
281
+ end
282
+
283
+ context 'when positive number has 3 digits and order 10^2' do
284
+ let(:value) { 123 }
285
+ let(:deviance) { 1.34 }
286
+
287
+ it 'shows 2 deviance digits' do
288
+ expect(number.to_s).to eq('1.230(13)e2')
289
+ end
290
+ end
291
+
292
+ context 'when positive number only has 2 digits and order 1' do
293
+ let(:value) { 1.2 }
294
+ let(:deviance) { 0.013 }
295
+
296
+ it 'shows 2 deviance digits' do
297
+ expect(number.to_s).to eq('1.200(13)')
298
+ end
299
+ end
300
+
301
+ context 'when positive number has 3 digits and order 1' do
302
+ let(:value) { 1.23 }
303
+ let(:deviance) { 0.0134 }
304
+
305
+ it 'shows 2 deviance digits' do
306
+ expect(number.to_s).to eq('1.230(13)')
307
+ end
308
+ end
309
+
310
+ context 'when positive number only has 2 digits and order 10^-1' do
311
+ let(:value) { 0.12 }
312
+ let(:deviance) { 0.0013 }
313
+
314
+ it 'shows 2 deviance digits' do
315
+ expect(number.to_s).to eq('1.200(13)e-1')
316
+ end
317
+ end
318
+
319
+ context 'when positive number has 3 digits and order 10^-1' do
320
+ let(:value) { 0.123 }
321
+ let(:deviance) { 0.00134 }
322
+
323
+ it 'shows 2 deviance digits' do
324
+ expect(number.to_s).to eq('1.230(13)e-1')
325
+ end
326
+ end
327
+ end
328
+
329
+ context 'when deviance has bigger order than the value' do
330
+ context 'when negative number only has 2 digits and order 10' do
331
+ let(:value) { -12 }
332
+ let(:deviance) { 130 }
333
+
334
+ it 'shows 2 deviance digits' do
335
+ expect(number.to_s).to eq('-0.1(13)e2')
336
+ end
337
+ end
338
+
339
+ context 'when negative number has 3 digits and order 10^2' do
340
+ let(:value) { -123 }
341
+ let(:deviance) { 1340 }
342
+
343
+ it 'shows 2 deviance digits' do
344
+ expect(number.to_s).to eq('-0.1(13)e3')
345
+ end
346
+ end
347
+
348
+ context 'when negative number only has 2 digits and order 1' do
349
+ let(:value) { -1.2 }
350
+ let(:deviance) { 13 }
351
+
352
+ it 'shows 2 deviance digits' do
353
+ expect(number.to_s).to eq('-0.1(13)e1')
354
+ end
355
+ end
356
+
357
+ context 'when negative number has 3 digits and order 1' do
358
+ let(:value) { -1.23 }
359
+ let(:deviance) { 13.4 }
360
+
361
+ it 'shows 2 deviance digits' do
362
+ expect(number.to_s).to eq('-0.1(13)e1')
363
+ end
364
+ end
365
+
366
+ context 'when negative number only has 2 digits and order 10^-1' do
367
+ let(:value) { -0.12 }
368
+ let(:deviance) { 1.3 }
369
+
370
+ it 'shows 2 deviance digits' do
371
+ expect(number.to_s).to eq('-0.1(13)')
372
+ end
373
+ end
374
+
375
+ context 'when negative number has 3 digits and order 10^-1' do
376
+ let(:value) { -0.123 }
377
+ let(:deviance) { 1.34 }
378
+
379
+ it 'shows 2 deviance digits' do
380
+ expect(number.to_s).to eq('-0.1(13)')
381
+ end
382
+ end
383
+
384
+ context 'when positive number only has 2 digits and order 10' do
385
+ let(:value) { 12 }
386
+ let(:deviance) { 0.13 }
387
+
388
+ it 'shows 2 deviance digits' do
389
+ expect(number.to_s).to eq('1.200(13)e1')
390
+ end
391
+ end
392
+
393
+ context 'when positive number has 3 digits and order 10^2' do
394
+ let(:value) { 123 }
395
+ let(:deviance) { 1340 }
396
+
397
+ it 'shows 2 deviance digits' do
398
+ expect(number.to_s).to eq('0.1(13)e3')
399
+ end
400
+ end
401
+
402
+ context 'when positive number only has 2 digits and order 1' do
403
+ let(:value) { 1.2 }
404
+ let(:deviance) { 13 }
405
+
406
+ it 'shows 2 deviance digits' do
407
+ expect(number.to_s).to eq('0.1(13)e1')
408
+ end
409
+ end
410
+
411
+ context 'when positive number has 3 digits and order 1' do
412
+ let(:value) { 1.23 }
413
+ let(:deviance) { 13.4 }
414
+
415
+ it 'shows 2 deviance digits' do
416
+ expect(number.to_s).to eq('0.1(13)e1')
417
+ end
418
+ end
419
+
420
+ context 'when positive number only has 2 digits and order 10^-1' do
421
+ let(:value) { 0.12 }
422
+ let(:deviance) { 1.3 }
423
+
424
+ it 'shows 2 deviance digits' do
425
+ expect(number.to_s).to eq('0.1(13)')
426
+ end
427
+ end
428
+
429
+ context 'when positive number has 3 digits and order 10^-1' do
430
+ let(:value) { 0.123 }
431
+ let(:deviance) { 1.34 }
432
+
433
+ it 'shows 2 deviance digits' do
434
+ expect(number.to_s).to eq('0.1(13)')
435
+ end
436
+ end
437
+ end
438
+ end
439
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+
5
+ SimpleCov.profiles.define 'gem' do
6
+ add_filter '/spec/'
7
+ end
8
+
9
+ SimpleCov.start 'gem'
10
+
11
+ require 'dr_light'
12
+ require 'pry-nav'
13
+
14
+ support_files = File.expand_path('spec/support/**/*.rb')
15
+ Dir[support_files].each { |file| require file }
16
+
17
+ RSpec.configure do |config|
18
+ config.run_all_when_everything_filtered = true
19
+ config.filter_run :focus
20
+ config.filter_run_excluding :integration unless ENV['ALL']
21
+
22
+ config.order = 'random'
23
+ end
metadata ADDED
@@ -0,0 +1,288 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dr_light
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - DarthJee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.16.1
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.16.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-nav
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 12.3.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 12.3.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: reek
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 5.4.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 5.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.8.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.8.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-core
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 3.8.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.8.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-expectations
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 3.8.3
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 3.8.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-mocks
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.8.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.8.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec-support
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 3.8.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 3.8.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 0.73.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 0.73.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop-rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 1.33.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 1.33.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubycritic
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '='
186
+ - !ruby/object:Gem::Version
187
+ version: 4.1.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '='
193
+ - !ruby/object:Gem::Version
194
+ version: 4.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: simplecov
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - '='
200
+ - !ruby/object:Gem::Version
201
+ version: 0.17.0
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '='
207
+ - !ruby/object:Gem::Version
208
+ version: 0.17.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: yard
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 0.9.20
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 0.9.20
223
+ - !ruby/object:Gem::Dependency
224
+ name: yardstick
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - '='
228
+ - !ruby/object:Gem::Version
229
+ version: 0.9.9
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - '='
235
+ - !ruby/object:Gem::Version
236
+ version: 0.9.9
237
+ description: Gem for science tools
238
+ email:
239
+ - darthjee@gmail.com
240
+ executables: []
241
+ extensions: []
242
+ extra_rdoc_files: []
243
+ files:
244
+ - ".circleci/config.yml"
245
+ - ".gitignore"
246
+ - ".rubocop.yml"
247
+ - ".rubocop_todo.yml"
248
+ - Dockerfile
249
+ - Gemfile
250
+ - LICENSE
251
+ - README.md
252
+ - Rakefile
253
+ - config/check_specs.yml
254
+ - config/rubycritc.rb
255
+ - config/yardstick.rb
256
+ - config/yardstick.yml
257
+ - docker-compose.yml
258
+ - dr_light.gemspec
259
+ - lib/dr_light.rb
260
+ - lib/dr_light/scientific_number.rb
261
+ - lib/dr_light/scientific_number/formatter.rb
262
+ - lib/dr_light/version.rb
263
+ - spec/lib/dr_light/scientific_number_spec.rb
264
+ - spec/spec_helper.rb
265
+ homepage: https://github.com/darthjee/dr_light
266
+ licenses: []
267
+ metadata: {}
268
+ post_install_message:
269
+ rdoc_options: []
270
+ require_paths:
271
+ - lib
272
+ required_ruby_version: !ruby/object:Gem::Requirement
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: 2.5.0
277
+ required_rubygems_version: !ruby/object:Gem::Requirement
278
+ requirements:
279
+ - - ">="
280
+ - !ruby/object:Gem::Version
281
+ version: '0'
282
+ requirements: []
283
+ rubyforge_project:
284
+ rubygems_version: 2.7.6
285
+ signing_key:
286
+ specification_version: 4
287
+ summary: Gem for science tools
288
+ test_files: []