lens_protocol 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +98 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +7 -0
  7. data/CODE_OF_CONDUCT.md +74 -0
  8. data/Gemfile +4 -0
  9. data/Gemfile.lock +106 -0
  10. data/Guardfile +42 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +69 -0
  13. data/Rakefile +6 -0
  14. data/bin/console +11 -0
  15. data/bin/setup +8 -0
  16. data/examples/images/R360_1.png +0 -0
  17. data/examples/oma/R1000_1.oma +213 -0
  18. data/examples/oma/R1000_2.oma +213 -0
  19. data/examples/oma/R1000_3.oma +217 -0
  20. data/examples/oma/R360_1.oma +78 -0
  21. data/examples/oma/R360_2.oma +75 -0
  22. data/examples/oma/R360_3.oma +276 -0
  23. data/examples/oma/TRCFMT6.oma +28 -0
  24. data/examples/public/styles.css +22 -0
  25. data/examples/svg.rb +10 -0
  26. data/examples/views/index.erb +26 -0
  27. data/lens_protocol.gemspec +33 -0
  28. data/lib/lens_protocol.rb +18 -0
  29. data/lib/lens_protocol/errors.rb +10 -0
  30. data/lib/lens_protocol/oma.rb +14 -0
  31. data/lib/lens_protocol/oma/formatter.rb +22 -0
  32. data/lib/lens_protocol/oma/message.rb +138 -0
  33. data/lib/lens_protocol/oma/parser.rb +24 -0
  34. data/lib/lens_protocol/oma/record.rb +19 -0
  35. data/lib/lens_protocol/oma/type/base.rb +97 -0
  36. data/lib/lens_protocol/oma/type/integer.rb +15 -0
  37. data/lib/lens_protocol/oma/type/numeric.rb +24 -0
  38. data/lib/lens_protocol/oma/type/r.rb +17 -0
  39. data/lib/lens_protocol/oma/type/text.rb +8 -0
  40. data/lib/lens_protocol/oma/type/trcfmt.rb +30 -0
  41. data/lib/lens_protocol/oma/types.rb +84 -0
  42. data/lib/lens_protocol/svg.rb +45 -0
  43. data/lib/lens_protocol/version.rb +3 -0
  44. metadata +213 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9072daaf6fa8bfc140c0c7cda8d472ae3e947c89e0311995c4ce9dfb1c40c3dd
4
+ data.tar.gz: d64a4645a7bcf2a4190873262660008a90152f5f7b475e39528dd701076a11c7
5
+ SHA512:
6
+ metadata.gz: 5ac11fe4748409cbaa5ce6def4e4e16e50dc76bc09bba20ac014e8125f1492a0e60f5822d1cf9133fe302f7760268c10060c5425532ea55829dedce132e37d5a
7
+ data.tar.gz: 014722c7b8a2e6568a97e1042031e479d87cf5c3a38e6d6bac96eee43b73c81f41902ec81553cb0f5f3db75746ed0e58d873d8024a39ce30eda1a09dce0f05d1
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,98 @@
1
+ Style/Documentation:
2
+ Enabled: false
3
+
4
+ Style/MethodDefParentheses:
5
+ Enabled: false
6
+
7
+ Style/ParallelAssignment:
8
+ Enabled: false
9
+
10
+ Style/FrozenStringLiteralComment:
11
+ Enabled: false
12
+
13
+ Style/FormatStringToken:
14
+ Enabled: false
15
+
16
+ Style/EmptyMethod:
17
+ Enabled: false
18
+
19
+ Style/GuardClause:
20
+ Enabled: false
21
+
22
+ Style/CommentAnnotation:
23
+ Enabled: false
24
+
25
+ Style/AsciiComments:
26
+ Enabled: false
27
+
28
+ Style/StabbyLambdaParentheses:
29
+ EnforcedStyle: require_no_parentheses
30
+
31
+ Style/MultilineIfModifier:
32
+ Enabled: false
33
+
34
+ Style/SafeNavigation:
35
+ Enabled: false
36
+
37
+ Style/FormatString:
38
+ Enabled: false
39
+
40
+ Style/AndOr:
41
+ Enabled: false
42
+
43
+ Style/Next:
44
+ Enabled: false
45
+
46
+ Style/NumericPredicate:
47
+ Enabled: false
48
+
49
+ Style/SymbolArray:
50
+ Enabled: false
51
+
52
+ Style/MutableConstant:
53
+ Enabled: false
54
+
55
+ Style/RescueModifier:
56
+ Enabled: false
57
+
58
+ Layout/SpaceInsideHashLiteralBraces:
59
+ Enabled: false
60
+
61
+ Layout/MultilineMethodCallIndentation:
62
+ Enabled: false
63
+
64
+ Layout/TrailingBlankLines:
65
+ Enabled: false
66
+
67
+ Layout/IndentArray:
68
+ EnforcedStyle: consistent
69
+
70
+ Layout/AlignParameters:
71
+ EnforcedStyle: with_fixed_indentation
72
+
73
+ Layout/SpaceInLambdaLiteral:
74
+ Enabled: false
75
+
76
+ Metrics:
77
+ Enabled: false
78
+
79
+ Bundler:
80
+ Enabled: false
81
+
82
+ Lint/AssignmentInCondition:
83
+ Enabled: false
84
+
85
+ Lint/ShadowingOuterLocalVariable:
86
+ Enabled: false
87
+
88
+ Lint/AmbiguousRegexpLiteral:
89
+ Enabled: false
90
+
91
+ Lint/AmbiguousOperator:
92
+ Enabled: false
93
+
94
+ Lint/AmbiguousBlockAssociation:
95
+ Enabled: false
96
+
97
+ Naming/UncommunicativeMethodParamName:
98
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.5.0
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 2.0.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at emmanicolau@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lens_protocol.gemspec
4
+ gemspec
@@ -0,0 +1,106 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lens_protocol (0.1.0)
5
+ activesupport (>= 4.0)
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2)
17
+ byebug (11.0.1)
18
+ coderay (1.1.2)
19
+ concurrent-ruby (1.1.5)
20
+ diff-lcs (1.3)
21
+ ffi (1.11.2)
22
+ formatador (0.2.5)
23
+ guard (2.16.1)
24
+ formatador (>= 0.2.4)
25
+ listen (>= 2.7, < 4.0)
26
+ lumberjack (>= 1.0.12, < 2.0)
27
+ nenv (~> 0.1)
28
+ notiffany (~> 0.0)
29
+ pry (>= 0.9.12)
30
+ shellany (~> 0.0)
31
+ thor (>= 0.18.1)
32
+ guard-compat (1.2.1)
33
+ guard-rspec (4.7.3)
34
+ guard (~> 2.1)
35
+ guard-compat (~> 1.1)
36
+ rspec (>= 2.99.0, < 4.0)
37
+ i18n (1.7.0)
38
+ concurrent-ruby (~> 1.0)
39
+ listen (3.2.0)
40
+ rb-fsevent (~> 0.10, >= 0.10.3)
41
+ rb-inotify (~> 0.9, >= 0.9.10)
42
+ lumberjack (1.0.13)
43
+ method_source (0.9.2)
44
+ mini_portile2 (2.4.0)
45
+ minitest (5.13.0)
46
+ mustermann (1.0.3)
47
+ nenv (0.3.0)
48
+ nokogiri (1.10.5)
49
+ mini_portile2 (~> 2.4.0)
50
+ notiffany (0.1.3)
51
+ nenv (~> 0.1)
52
+ shellany (~> 0.0)
53
+ pry (0.12.2)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.9.0)
56
+ pry-byebug (3.7.0)
57
+ byebug (~> 11.0)
58
+ pry (~> 0.10)
59
+ rack (2.0.7)
60
+ rack-protection (2.0.7)
61
+ rack
62
+ rake (10.5.0)
63
+ rb-fsevent (0.10.3)
64
+ rb-inotify (0.10.0)
65
+ ffi (~> 1.0)
66
+ rspec (3.9.0)
67
+ rspec-core (~> 3.9.0)
68
+ rspec-expectations (~> 3.9.0)
69
+ rspec-mocks (~> 3.9.0)
70
+ rspec-core (3.9.0)
71
+ rspec-support (~> 3.9.0)
72
+ rspec-expectations (3.9.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.9.0)
75
+ rspec-mocks (3.9.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.9.0)
78
+ rspec-support (3.9.0)
79
+ shellany (0.0.1)
80
+ sinatra (2.0.7)
81
+ mustermann (~> 1.0)
82
+ rack (~> 2.0)
83
+ rack-protection (= 2.0.7)
84
+ tilt (~> 2.0)
85
+ thor (0.20.3)
86
+ thread_safe (0.3.6)
87
+ tilt (2.0.10)
88
+ tzinfo (1.2.5)
89
+ thread_safe (~> 0.1)
90
+ zeitwerk (2.2.1)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ bundler (~> 2.0)
97
+ guard-rspec
98
+ lens_protocol!
99
+ pry
100
+ pry-byebug
101
+ rake (~> 10.0)
102
+ rspec (~> 3.0)
103
+ sinatra
104
+
105
+ BUNDLED WITH
106
+ 2.0.2
@@ -0,0 +1,42 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Emmanuel Nicolau
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # LensProtocol
2
+
3
+ A Ruby parser and builder for the OMA protocol (a.k.a. Data Communication Standard) that was developed by the Lens Processing & Technology Division of The Vision Council for interconnection of optical laboratory equipment.
4
+
5
+ Furthermore, it allows you to generate a SVG representation of the tracing datasets.
6
+
7
+ [![Build Status](https://travis-ci.org/eeng/lens_protocol.svg?branch=master)](https://travis-ci.org/eeng/lens_protocol)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'lens_protocol'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install lens_protocol
24
+
25
+ ## Usage
26
+
27
+ ### Parsing an OMA file
28
+
29
+ ```ruby
30
+ require 'lens_protocol'
31
+ message = LensProtocol::OMA.parse(File.read('examples/oma/R360_1.oma'))
32
+ message.values_of('SPH') # => [1.25, -0.5]
33
+ ```
34
+
35
+ ### Generating the tracing data SVG
36
+
37
+ The `message.to_svg` method returns an array of SVG strings, one for each side, which can be used directly in an ERB template, like this:
38
+
39
+ ```html
40
+ <div class="lenses-container">
41
+ <% message.to_svg.map do |svg| %>
42
+ <div class="lens">
43
+ <%= svg %>
44
+ </div>
45
+ <% end %>
46
+ </div>
47
+ ```
48
+
49
+ And it should look like this:
50
+
51
+ ![Sample Image](examples/images/R360_1.png)
52
+
53
+ To customize the styles, please check out [the provided sample stylesheet](examples/public/styles.css).
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` or `guard` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
58
+
59
+ There's also a Sinatra app which allows you visualize the generated SVG. To start the server do `bundle exec ruby examples/svg.rb` and go to `http://localhost:4567/`
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eeng/lens_protocol. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
66
+
67
+ ## Code of Conduct
68
+
69
+ Everyone interacting in the LensProtocol project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/eeng/lens_protocol/blob/master/CODE_OF_CONDUCT.md).