thermite-rails 0.2.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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +43 -0
  5. data/CHANGELOG.md +14 -0
  6. data/CODE_OF_CONDUCT.md +74 -0
  7. data/Gemfile +10 -0
  8. data/MIT-LICENSE +20 -0
  9. data/README.md +131 -0
  10. data/Rakefile +15 -0
  11. data/bin/console +15 -0
  12. data/bin/rails +16 -0
  13. data/bin/rake +29 -0
  14. data/bin/rspec +29 -0
  15. data/bin/rubocop +29 -0
  16. data/bin/setup +8 -0
  17. data/lib/thermite/rails.rb +31 -0
  18. data/lib/thermite/rails/cargo_runner.rb +20 -0
  19. data/lib/thermite/rails/check_outdated.rb +19 -0
  20. data/lib/thermite/rails/generators/crate_generator.rb +100 -0
  21. data/lib/thermite/rails/generators/install_generator.rb +14 -0
  22. data/lib/thermite/rails/project.rb +88 -0
  23. data/lib/thermite/rails/railtie.rb +37 -0
  24. data/lib/thermite/rails/root_project.rb +46 -0
  25. data/lib/thermite/rails/tasks/project_rake_task.rb +81 -0
  26. data/lib/thermite/rails/tasks/project_spec_task.rb +33 -0
  27. data/lib/thermite/rails/tasks/project_thermite_build_task.rb +21 -0
  28. data/lib/thermite/rails/tasks/project_thermite_clean_task.rb +21 -0
  29. data/lib/thermite/rails/tasks/project_thermite_test_task.rb +21 -0
  30. data/lib/thermite/rails/tasks/project_thermite_update_task.rb +28 -0
  31. data/lib/thermite/rails/tasks/root_project_rake_task.rb +74 -0
  32. data/lib/thermite/rails/tasks/root_project_spec_task.rb +40 -0
  33. data/lib/thermite/rails/tasks/root_project_thermite_build_task.rb +27 -0
  34. data/lib/thermite/rails/tasks/root_project_thermite_clean_task.rb +27 -0
  35. data/lib/thermite/rails/tasks/root_project_thermite_test_task.rb +27 -0
  36. data/lib/thermite/rails/tasks/root_project_thermite_update_task.rb +27 -0
  37. data/lib/thermite/rails/tasks/rspec.rake +14 -0
  38. data/lib/thermite/rails/tasks/thermite.rake +18 -0
  39. data/lib/thermite/rails/version.rb +7 -0
  40. data/thermite-rails.gemspec +47 -0
  41. metadata +237 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1ae814897593fc1121540933143ab4e453d060e4d48421f19f3fa160f1cddafc
4
+ data.tar.gz: 601bb63007275900c07f7e449029f8ea06f385b5dd68f11c3309bd3e942897ea
5
+ SHA512:
6
+ metadata.gz: 7180d1df7f4e4b640e88952762e028ca5587ed522685eb7f8aa5388ce8beeedb3d0936a43f8c77f8e58eed037e9404c8cf5b671b4108b1d0ebb13e1d56021651
7
+ data.tar.gz: '091be81aeff326fa5812196832c3fb5a90c7a81229da61d5732fdb8e774a63c318bcf6c0f70d47b8618c407c1f4248fd714f86db0830a502fc5c022264703926'
@@ -0,0 +1,34 @@
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
12
+
13
+ # Rails engine things
14
+ log/*.log
15
+ pkg/
16
+ spec/dummy/db/*.sqlite3
17
+ spec/dummy/db/*.sqlite3-journal
18
+ spec/dummy/log/*.log
19
+ spec/dummy/tmp/
20
+
21
+ # tags
22
+ .tags
23
+
24
+ Gemfile.lock
25
+
26
+ spec/dummy/crates/mkmf.log
27
+
28
+ # Rust things
29
+ spec/dummy/crates/*/mkmf.log
30
+ spec/dummy/crates/*/target/*
31
+
32
+ *.so
33
+
34
+ tags
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,43 @@
1
+ ---
2
+ Layout/AlignParameters:
3
+ EnforcedStyle: with_fixed_indentation
4
+
5
+ Layout/DotPosition:
6
+ EnforcedStyle: trailing
7
+
8
+ Metrics/AbcSize:
9
+ Enabled: false
10
+
11
+ Metrics/BlockLength:
12
+ Exclude:
13
+ - thermite-rails.gemspec
14
+ - spec/**/*_spec.rb
15
+
16
+ Metrics/LineLength:
17
+ Max: 120
18
+
19
+ Rails:
20
+ Enabled: true
21
+
22
+ Style/Documentation:
23
+ Enabled: false
24
+
25
+ Style/FormatString:
26
+ EnforcedStyle: percent
27
+
28
+ Style/PercentLiteralDelimiters:
29
+ PreferredDelimiters:
30
+ '%i': '[]'
31
+ '%w': '[]'
32
+ '%W': '[]'
33
+
34
+ Style/SymbolArray:
35
+ Enabled: true
36
+
37
+ AllCops:
38
+ DisplayCopNames: true
39
+ DisplayStyleGuide: true
40
+ Exclude:
41
+ - spec/dummy/db/schema.rb
42
+ - vendor/bundle/**/*
43
+ TargetRubyVersion: 2.4
@@ -0,0 +1,14 @@
1
+ # Change Log
2
+
3
+ ## [0.2.0] - 2018-03-28
4
+
5
+ ### Improvements
6
+
7
+ * Moved `*Task` classes to `lib/thermite/rails/tasks/`.
8
+ * Added rake task for running `cargo update` for all crates.
9
+
10
+ ## [0.1.0] - 2018-03-27
11
+
12
+ ### Improvements
13
+
14
+ * Initial release!
@@ -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 steve@agrian.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,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ # Dummy apps don't get a Gemfile. Since thermite-rails has code for updating a
8
+ # Gemfile, we should test that that works, thus we need to eval in the dummy
9
+ # app's Gemfile to pick up the crates.
10
+ eval_gemfile 'spec/dummy/Gemfile'
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Steve Loveless
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,131 @@
1
+ # thermite-rails
2
+
3
+ Integrate your Rust+Ruby [thermite](https://github.com/malept/thermite) projects
4
+ into Rails. Like [helix-rails](https://github.com/tildeio/helix-rails), but for
5
+ thermite.
6
+
7
+ First things first: much of this project was initially "borrowed" from
8
+ [helix](http://usehelix.com/) and `helix-rails`, which are wonderful
9
+ projects for getting Rust and Ruby working together--you should check them out.
10
+
11
+ Specs |
12
+ ------|
13
+ [![Build Status](http://teamcity-build.agrian.com/app/rest/builds/buildType%3Aid%3AGems_ThermiteRails_Specs/statusIcon?guest=1)](http://teamcity-build.agrian.com/viewType.html?buildTypeId=Gems_ThermiteRails_Specs)
14
+
15
+ ## Usage
16
+
17
+ ### Generators
18
+
19
+ There are two Rails generators that get you doing Rust-y things in your Rails app.
20
+
21
+ #### `thermite:install`
22
+
23
+ This does one simple thing: adds a line to `config/environments/development.rb`
24
+ that checks to see if your crates have been updated since the last time you
25
+ built them; if any of them have been updated, you'll get an exception letting
26
+ you know.
27
+
28
+ ```bash
29
+ $ rails generate thermite:install
30
+ ```
31
+
32
+ ...adds the following to `config/environments/development.rb`:
33
+
34
+ ```ruby
35
+ config.thermite.outdated_error = :page_load
36
+ ```
37
+
38
+ #### `thermite:crate [crate-name]`
39
+
40
+ This generates a new Rust+Ruby project for you in `[Rails.root]/crates/[crate-name]`.
41
+ The Rubygem part of the project is created using `bundle gem [crate-name]`; the
42
+ Rust part of the project is created using `crate new [crate-name]`. Most of the
43
+ basic stuff that `thermite` has you do for setting up is done for you.
44
+
45
+ One main difference from `thermite`'s instructions, however, is that it does
46
+ not set up the same `test` Rake task that `thermite` says to. This is because
47
+ `thermite-rails` defines its own set of tasks for you. You can, of course,
48
+ override those if you need to.
49
+
50
+ Lastly, it also:
51
+
52
+ * makes the crate `publish = false` so you don't accidentally publish it to
53
+ `crates.io`.
54
+ * sets `crate-type = ["cdylib"]`, assuming you'll use something like
55
+ [ruru](https://github.com/d-unseductable/ruru) +
56
+ [fiddle](https://github.com/ruby/fiddle) for initializing your Rust+Ruby.
57
+
58
+ ### Rake Tasks
59
+
60
+ `thermite-rails` defines a task for building, cleaning, updating, and (cargo)
61
+ testing a) all of your projects at once, b) each of your projects separately.
62
+
63
+ * `thermite:build_all`, `thermite:build:[crate-name]` leverage `thermite`'s
64
+ `thermite:build` task.
65
+ * `thermite:clean_all`, `thermite:clean:[crate-name]` leverage `thermite`'s
66
+ `thermite:clean` task.
67
+ * `thermite:test_all`, `thermite:test:[crate-name]` leverage `thermite`'s
68
+ `thermite:test` task.
69
+ * `thermite:update_all`, `thermite:update:[crate-name]` are only defined in
70
+ `thermite-rails`. This simply runs `cargo update` for each of your crates.
71
+
72
+ If you have `rspec` in your stack, you'll also get `spec:crates` and
73
+ `spec:crates:[crate-name]`, where the latter will ensure
74
+ `thermite:build:[crate-name]` is run before (to make sure specs are run against
75
+ the latest Rust code). If you want to run all tests (Rust and Ruby ones) when
76
+ you run `rake spec`, add this to the `Rakefile` in the root of your Rails
77
+ project:
78
+
79
+ ```ruby
80
+ Rake::Task['spec'].enhance do
81
+ Rake::Task['spec:crates'].invoke
82
+ end
83
+ ```
84
+
85
+ Note that Rake tasks will only be available for crates in `crates/` that use
86
+ `thermite`. You can add Rust-only crates under `crates/` (perhaps you want to
87
+ keep your crates/projects slim and extract out some functionality?) or use
88
+ [helix](http://usehelix.com/) along side `thermite`/`thermite-rails`.
89
+
90
+ ## Installation
91
+
92
+ Add this line to your application's Gemfile:
93
+
94
+ ```ruby
95
+ gem 'thermite-rails'
96
+ ```
97
+
98
+ And then execute:
99
+
100
+ ```bash
101
+ $ bundle
102
+ $ rails generate thermite:install
103
+ ```
104
+
105
+ ...then go add some crates/projects to your app:
106
+
107
+ ```bash
108
+ $ rails generate thermite:crate new_fast_thingy
109
+ ```
110
+
111
+ ## Development
112
+
113
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
114
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
115
+ prompt that will allow you to experiment.
116
+
117
+ To install this gem onto your local machine, run `bundle exec rake install`. To
118
+ release a new version, update the version number in `version.rb`, and then run
119
+ `bundle exec rake release`, which will create a git tag for the version, push
120
+ git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
121
+
122
+
123
+ ## Code of Conduct
124
+
125
+ Everyone interacting in the Thermite::Rails project’s codebases, issue trackers,
126
+ chat rooms and mailing lists is expected to follow the
127
+ [code of conduct](https://bitbucket.com/agrian/thermite-rails/blob/master/CODE_OF_CONDUCT.md).
128
+
129
+ ## License
130
+
131
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ load 'rails/tasks/statistics.rake'
10
+
11
+ require 'bundler/gem_tasks'
12
+ require 'rspec/core/rake_task'
13
+
14
+ load 'spec/dummy/Rakefile'
15
+ RSpec::Core::RakeTask.new spec: %w[thermite:test_all]
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'thermite/rails'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This command will automatically be run when you run "rails" with Rails gems
5
+ # installed from the root of your application.
6
+
7
+ ENGINE_ROOT = File.expand_path('..', __dir__)
8
+ ENGINE_PATH = File.expand_path('../lib/thermite/rails/railtie', __dir__)
9
+ APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
10
+
11
+ # Set up gems listed in the Gemfile.
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
13
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
14
+
15
+ require 'rails/all'
16
+ require 'rails/engine/commands'
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path('bundle', __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150).match?(/This file was generated by Bundler/)
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require 'rubygems'
27
+ require 'bundler/setup'
28
+
29
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path('bundle', __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150).match?(/This file was generated by Bundler/)
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require 'rubygems'
27
+ require 'bundler/setup'
28
+
29
+ load Gem.bin_path('rspec-core', 'rspec')