gcodify 0.1.0

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: d6ca366e559cf2c657555bcdb1fa9b175258125b53465218e423449038c0d8fe
4
+ data.tar.gz: c0356174afd8e3579aae164ba10d12fb8039076d60cf5ff647033204df0e1105
5
+ SHA512:
6
+ metadata.gz: ddd5dd245bc4c67408c7747bd93c78f64ab70ba55e42cbc6e38257ead4c546adf553c32c35ae6b03b3378b4ab88426737d7cb0ea79abe3469d5d2c141479616d
7
+ data.tar.gz: a88a9aa5a559b2d6cee563648be8bd7d8571e50d5aee8e9962dbf0708e54f1fbdaa649fff3d19e49278a454355ef8b832ee0e12b1f1bf43858feccba7f53e60a
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ sudo: false
3
+ rvm:
4
+ - 2.2.1
5
+ before_install: gem install bundler -v 1.10.4
6
+ script: rake spec
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gcodify.gemspec
4
+ gemspec
5
+
6
+ gem 'coveralls', require: false
7
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Liam Marshall
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.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Gcodify
2
+
3
+ [![Build Status](https://travis-ci.org/ArchimedesPi/gcodify.svg?branch=master)](https://travis-ci.org/ArchimedesPi/gcodify) [![Inline docs](http://inch-ci.org/github/ArchimedesPi/gcodify.svg?branch=master)](http://inch-ci.org/github/ArchimedesPi/gcodify) [![Code Climate](https://codeclimate.com/github/ArchimedesPi/gcodify/badges/gpa.svg)](https://codeclimate.com/github/ArchimedesPi/gcodify) [![Coverage Status](https://coveralls.io/repos/ArchimedesPi/gcodify/badge.svg?branch=master)](https://coveralls.io/r/ArchimedesPi/gcodify?branch=master)
4
+
5
+ Gcodify is a Ruby DSL for more easily hand-writing gcode. When it comes time to make something in the physical world on a mill or lathe, if you don't have a CAD model, then you're going to have to manually write gcode, which is **NOT FUN**. Even if you do, CAM software is a pain to use, and may be harder to configure than hand-writing gcode. Gcodify makes handwriting gcode fun - forget the look-up of obscure gcode features and just write the things you want made, like cuts, holes, and pockets. Like CAM, but handwritten!
6
+
7
+ ## Feature status list
8
+ * DSL (✔)
9
+ * Holes (with a drill-bit in a chuck on the spindle) (✔)
10
+ * Pockets (✘)
11
+ * Facing (✘)
12
+ * Manual gcode entry (✔)
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'gcodify'
20
+ ```
21
+
22
+ And then just `$ bundle`.
23
+ Or install it yourself:
24
+
25
+ $ gem install gcodify
26
+
27
+ ## Usage
28
+
29
+ Write a new ruby file that requires `gcodify`:
30
+
31
+ ```ruby
32
+ require 'gcodify'
33
+ ```
34
+
35
+ Tell it that you want a program with certain features:
36
+
37
+ ```ruby
38
+ program = GCodify.program do
39
+ hole :at=>[0, 0], depth=>0.13
40
+ end
41
+ puts program.to_gcode # output the program's gcode to stdout
42
+ ```
43
+
44
+ Then run it: `$ ruby some_gcodify_script.rb > some_gcodify_script.gcode`.
45
+ You just made a gcode program which makes a hole at the origin!
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ 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).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ArchimedesPi/gcodify. 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.
56
+
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "gcodify"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ require 'gcodify'
2
+ program = Gcodify.program do
3
+ hole :at=>[1, 1], :depth=>0.13
4
+ hole :at=>[1, -1], :depth=>0.13
5
+ hole :at=>[-1, -1], :depth=>0.13
6
+ hole :at=>[-1, 1], :depth=>0.13
7
+ end
8
+ puts program.to_gcode
data/gcodify.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gcodify/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gcodify"
8
+ spec.version = Gcodify::VERSION
9
+ spec.authors = ["Liam Marshall"]
10
+ spec.email = ["liam@cpan.org"]
11
+
12
+ spec.summary = %q{Gcodify makes writing gcode by hand fun!}
13
+ spec.description = %q{Gcodify is a Ruby DSL which generates gcode from a high-level,
14
+ Ruby-based description language. It's kind of like hand-written CAM.}
15
+ spec.homepage = "https://github.com/ArchimedesPi/gcodify"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "yard"
27
+ end
data/lib/gcodify.rb ADDED
@@ -0,0 +1,32 @@
1
+ require "gcodify/version"
2
+ require "gcodify/program"
3
+ require "gcodify/opsmixin"
4
+ require "gcodify/op"
5
+ require "gcodify/ops/holeop"
6
+ require "gcodify/ops/faceop"
7
+ require "gcodify/ops/pocketop"
8
+ require "gcodify/ops/gcodeop"
9
+ require "gcodify/ops/dummyop"
10
+
11
+ # {Gcodify} is the main module that contains all the code.
12
+ # The only thing you'll be interacting with directly when you use it as a DSL is
13
+ # the module method #program, which is passed a block as a DSL.
14
+ # @example Using #program for a DSL
15
+ # aProgram = Gcodify.program do
16
+ # # some code here
17
+ # end
18
+ module Gcodify
19
+ # Takes a block of operations and creates a new {Program} from them.
20
+ #
21
+ # @example Using it to create a {Program}
22
+ # Gcodify.program do
23
+ # hole :at=>[0, 0], :depth=>0.25
24
+ # end
25
+ # @param block [Block] a block of operations (see Ops).
26
+ # @return [Program] a program created from `&block`
27
+ def self.program(&block)
28
+ prog = Program.new
29
+ prog.instance_eval(&block)
30
+ prog
31
+ end
32
+ end
data/lib/gcodify/op.rb ADDED
@@ -0,0 +1,24 @@
1
+ module Gcodify
2
+ # An Operation. An Operation is the unit of "doing". For instance, a drilled hole
3
+ # is a single {Op}, a circular pocket is a single {Op}, and so on.
4
+ # {Op}s are subclassed into things like HoleOp, PocketOp, etc., and each is responsible
5
+ # for storing data and each provides its own implementation of #to_gcode.
6
+ # @!attribute [r] options
7
+ # @return [Hash] the options passed to the Op. Used for testing.
8
+ class Op
9
+ attr_reader :options
10
+
11
+ # @param options [Hash] a {Hash} of options to be passed in to the op
12
+ def initialize(options)
13
+ @options = options
14
+ end
15
+
16
+ # Converts the {Op} to Gcode. Each *{Op} has it's own implementation of #to_gcode,
17
+ # depending on what gcode it has to generate.
18
+ #
19
+ # @return [String] some gcode
20
+ def to_gcode
21
+ "" # Return an empty string for testing purposes.
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ require 'gcodify/op'
2
+
3
+ module Gcodify::Ops
4
+ # A passthrough {Op} for testing purposes.
5
+ # It contains @str which is the string passed during
6
+ # initialization, which will be returned by #to_gcode.
7
+ class DummyOp < Gcodify::Op
8
+ # @param str [String] a string to be returned later for testing purposes
9
+ def initialize(str)
10
+ @str = str
11
+ end
12
+
13
+ # Returns the string that was passed in when initted.
14
+ #
15
+ # @return [String] the original dummy string
16
+ def to_gcode
17
+ @str
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'gcodify/op'
2
+
3
+ module Gcodify::Ops
4
+ class FaceOp < Gcodify::Op
5
+ def to_gcode
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ require 'gcodify/op'
2
+
3
+ module Gcodify::Ops
4
+ # An {Op} for passing through a line (or more) of GCode,
5
+ # since there are things that haven't been implemented yet
6
+ # that could be done in raw gcode.
7
+ # {GcodeOp} passes through a string in the same manner as DummyOp,
8
+ # but it adds '\n' to the end.
9
+ class GcodeOp < Gcodify::Op
10
+ def initialize(str)
11
+ @str = str
12
+ end
13
+
14
+ def to_gcode
15
+ @str+'\n'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'gcodify/op'
2
+
3
+ module Gcodify::Ops
4
+ # A hole to be drilled.
5
+ # In @options, no :radius or :diameter is specified or necessary,
6
+ # since that's determined by the drill-bit that you put in the machine.
7
+ class HoleOp < Gcodify::Op
8
+ # Special notice: @options[:r_position] is what the drilling cycle will rapid down to,
9
+ # if not specified it's 0.2in
10
+ #
11
+ # @param options [Hash] the options for the {HoleOp}
12
+ def initialize(options)
13
+ @options = options
14
+ @options[:r_position] = @options[:r_position] || 0.2
15
+ end
16
+
17
+ # Creates the gcode. {HoleOp} uses canned drill cycles.
18
+ #
19
+ # @return [String] the generated gcode
20
+ def to_gcode
21
+ gcode = "Z1.0\n"
22
+ gcode << "X#{@options[:at][0]} Y#{@options[:at][1]}"
23
+ gcode << "G99 G81 R#{@options[:r_position]} Z#{@options[:depth] + @options[:r_position]}\n"
24
+ gcode << "G80\n"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ require 'gcodify/op'
2
+
3
+ module Gcodify::Ops
4
+ class PocketOp < Gcodify::Op
5
+ def to_gcode
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ # {OpsMixin} is used as a Mixin to {Program} for the DSL - all of the DSL's methods,
2
+ # ie. hole, pocket, face, etc. are implemented here, and then `import`ed into
3
+ # {Program}, for DRYness and reusability.
4
+ # All methods contained in {OpsMixin} return a subclass of Op, ie. HoleOp, PocketOp, and so on.
5
+ module Gcodify::OpsMixin
6
+ # options is a Hash
7
+ # standard stuff in options for all these functions
8
+ # not every op will use all of these.
9
+ # :at - where to put the feature
10
+ # :depth - how deep the feature should be
11
+ # :radius - radius of the feature
12
+ # :diameter - diameter of the feature, behavior is undefined when specified at the same time as :radius
13
+ # :peck - peck step depth for peck drilling
14
+ # :return_height - return height for pecking during peck drilling. if not specified, pecking will not return to a constant height
15
+ #
16
+ # @return [HoleOp] a hole-drilling operation
17
+ def hole(options)
18
+ @ops << Gcodify::Ops::HoleOp.new(options)
19
+ end
20
+
21
+ # (see #hole)
22
+ # @return [PocketOp] a pocketing operation
23
+ def circular_pocket(options)
24
+ end
25
+
26
+ # (see #hole)
27
+ # @return [FaceOp] a facing operation
28
+ def face(options)
29
+ end
30
+
31
+ # #gcode is a passthrough for gcode,
32
+ # used when Gcodify doesn't provide some feature of gcode
33
+ # that you might want to use.
34
+ #
35
+ # @param gcode [String] a line of gcode
36
+ def gcode(code)
37
+ @ops << Gcodify::Ops::GcodeOp(code)
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ require "gcodify/opsmixin"
2
+
3
+ module Gcodify
4
+ # Represents a GCode program. It contains a property @ops, which is an array
5
+ # of all the ops, in order, in the program.
6
+ class Program
7
+ # Access all ops in the program
8
+ attr_accessor :ops
9
+ # Mix in all the op functions for the DSL :D
10
+ include OpsMixin
11
+
12
+ def initialize
13
+ @ops = []
14
+ end
15
+
16
+ # Converts the {Program} to a Gcode string
17
+ #
18
+ # @return [String] the Gcode
19
+ def to_gcode
20
+ gcode = ""
21
+ @ops.each do |op|
22
+ # Append that Op's generated gcode to the full gcode string
23
+ gcode << op.to_gcode
24
+ end
25
+ gcode # Return the generated gcode
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Gcodify
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gcodify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Liam Marshall
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-09-16 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ Gcodify is a Ruby DSL which generates gcode from a high-level,
71
+ Ruby-based description language. It's kind of like hand-written CAM.
72
+ email:
73
+ - liam@cpan.org
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - examples/square_of_holes.rb
89
+ - gcodify.gemspec
90
+ - lib/gcodify.rb
91
+ - lib/gcodify/op.rb
92
+ - lib/gcodify/ops/dummyop.rb
93
+ - lib/gcodify/ops/faceop.rb
94
+ - lib/gcodify/ops/gcodeop.rb
95
+ - lib/gcodify/ops/holeop.rb
96
+ - lib/gcodify/ops/pocketop.rb
97
+ - lib/gcodify/opsmixin.rb
98
+ - lib/gcodify/program.rb
99
+ - lib/gcodify/version.rb
100
+ homepage: https://github.com/ArchimedesPi/gcodify
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.0.3
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Gcodify makes writing gcode by hand fun!
123
+ test_files: []