stimpack 0.3.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a182ce65cfc7f331c0b8aab98cb9f66f74e24b2892f07759b6fc0663d2ed9d2
4
- data.tar.gz: cfbdf8284d0b3c054c2708bd69bfc0eb63341044e93ca064cf9971b17e391a06
3
+ metadata.gz: e6ad8e03da3ba828985b82eccb3840f6f4122d5fe38bcbc7905734a566c7d4cc
4
+ data.tar.gz: cba30db4834bd3e056ea19c76067945d73378c799b603f1cc931d43ac409cf59
5
5
  SHA512:
6
- metadata.gz: 7dfc2c8a19b50159cddb6f5ace4a593e8f69d8719ee607c3994fed1b1541cfb639fa1bba1bb458eff632487cf65e84181899bd3c3343192ddd5f03abd6f8bd7a
7
- data.tar.gz: 1c7f5dce375f55b6733ac771d86f3799aa408335e0d17b11cff6c9e7d47e7ff6d53ccd54c5f944419bad9a9eda2a0c2146c4048dcf26ff643e056119302fb66c
6
+ metadata.gz: d38f3c326b2fa6f327de5b0d2da6e77c1ea58e54c28df8e51887247743699ad3f8cc5e4dc5f769c50eaa80011a6ee8374fd21c4173e3c5c0b59a26ebb9609f82
7
+ data.tar.gz: 20bd2048490efd0eaa00380263c31c98e1eededa46458e61195c62b4f2c2f4102db1f080eb03efaf3f9496bd5d1777ec06f48109d1cf2dab52332900e41cde98
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Stimpack
2
2
 
3
- `stimpack` makes integrating with [`packwerk`](https://github.com/Shopify/packwerk) easy and establishes conventions such that packwerk packages mimic the feel and structure of [Rails engines](https://guides.rubyonrails.org/engines.html), without all of the boilerplate. With `stimpack`, new packages' autoload paths are automatically added to Rails, so your code will immediately become usable and loadable without additional configuration.
3
+ `stimpack` establishes and implements a set of conventions for splitting up large monoliths built on top of [`packwerk`](https://github.com/Shopify/packwerk). With `stimpack`, new packages' autoload paths are automatically added to Rails, so your code will immediately become usable and loadable without additional configuration.
4
4
 
5
5
  Here is an example application that uses `stimpack`:
6
6
  ```
@@ -24,12 +24,12 @@ packs/
24
24
  some_other_non_namespaced_private_model.rb # this works too
25
25
  my_domain/
26
26
  my_private_namespacd_model.rb
27
- config/
28
- initializers/ # Initializers can live in packs and load as expected
29
27
  controllers/
30
28
  views/
31
- lib/
32
- tasks/
29
+ config/
30
+ initializers/ # Initializers can live in packs and load as expected
31
+ lib/
32
+ tasks/
33
33
  spec/ # With stimpack, specs for a pack live next to the pack
34
34
  public/
35
35
  my_domain_spec.rb
@@ -71,6 +71,17 @@ module MyCoolApp
71
71
  end
72
72
  ```
73
73
 
74
+ ### Splitting routes
75
+ `stimpack` allows you to split your application routes for every pack. You just have to create a file describing your routes and then `draw` them in your root `config/routes.rb` file.
76
+
77
+ ```ruby
78
+ # packs/my_domain/config/routes/my_domain.rb
79
+ resources :my_resource
80
+
81
+ # config/routes.rb
82
+ draw(:my_domain)
83
+ ```
84
+
74
85
  ### Making your Package an Engine
75
86
  Add `engine: true` to your `package.yml` to make it an actual Rails engine:
76
87
  ```yml
data/bin/tapioca ADDED
@@ -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 'tapioca' 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", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /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("tapioca", "tapioca")
@@ -3,6 +3,13 @@ module Stimpack
3
3
  class RSpec
4
4
  def self.install(app)
5
5
  return unless defined?(::RSpec)
6
+ # Sometimes, the `rspec-rails` gem is installed in the development
7
+ # group. This means the ::RSpec module will be defined. However, this
8
+ # doesn't mean that we've loaded rspec-core, or even about to run tests.
9
+ # Let's make sure we are actually loading the test environment before
10
+ # installing our integration. An easy of doing this is seeing of the
11
+ # configuration method exists on RSpec.
12
+ return unless ::RSpec.respond_to?(:configuration)
6
13
 
7
14
  Packs.each do |pack|
8
15
  ::RSpec.configuration.pattern.concat(",#{pack.relative_path.join("spec/**/*_spec.rb")}")
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "yaml"
4
+
3
5
  module Stimpack
4
6
  class Pack
5
7
  class Configuration
@@ -17,7 +19,11 @@ module Stimpack
17
19
  private
18
20
 
19
21
  def data
20
- @data ||= YAML.load_file(@path).fetch(KEY, {}).freeze
22
+ @data ||= begin
23
+ contents = YAML.respond_to?(:safe_load_file) ? YAML.safe_load_file(@path) : YAML.load_file(@path)
24
+ contents ||= {}
25
+ contents.fetch(KEY, {}).freeze
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -12,8 +12,9 @@ module Stimpack
12
12
  end
13
13
 
14
14
  def resolve
15
- # Gather all the packs under the root directory and create packs.
16
- root.children.select(&:directory?).sort!.each do |path|
15
+ # Gather all the parent packs and the children packs.
16
+ package_locations = root.glob('*/{package.yml,*/package.yml}').map(&:dirname)
17
+ package_locations.sort!.each do |path|
17
18
  next unless pack = Pack.create(path)
18
19
  @packs[pack.name] = pack
19
20
  end
@@ -4,6 +4,8 @@ module Stimpack
4
4
  class Railtie < Rails::Railtie
5
5
  config.before_configuration do |app|
6
6
  Stimpack.load(app)
7
+ # This is not used within stimpack. Rather, this allows OTHER tools to
8
+ # hook into Stimpack via ActiveSupport hooks.
7
9
  ActiveSupport.run_load_hooks(:stimpack, Packs)
8
10
  end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module Stimpack
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
data/lib/stimpack.rb CHANGED
@@ -42,6 +42,7 @@ module Stimpack
42
42
  config
43
43
  config/locales
44
44
  config/initializers
45
+ config/routes
45
46
  )
46
47
  end
47
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-08 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,7 +52,50 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Package your code.
55
+ - !ruby/object:Gem::Dependency
56
+ name: debug
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
+ - !ruby/object:Gem::Dependency
70
+ name: sorbet
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tapioca
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: stimpack establishes and implements a set of conventions for splitting
98
+ up large monoliths.
56
99
  email:
57
100
  - gusto-opensource-buildkite@gusto.com
58
101
  executables: []
@@ -62,6 +105,7 @@ files:
62
105
  - README.md
63
106
  - bin/console
64
107
  - bin/setup
108
+ - bin/tapioca
65
109
  - lib/stimpack.rb
66
110
  - lib/stimpack/integrations.rb
67
111
  - lib/stimpack/integrations/factory_bot.rb
@@ -79,7 +123,7 @@ metadata:
79
123
  homepage_uri: https://github.com/Gusto/stimpack
80
124
  source_code_uri: https://github.com/Gusto/stimpack
81
125
  changelog_uri: https://github.com/Gusto/stimpack/blob/master/CHANGELOG.md
82
- post_install_message:
126
+ post_install_message:
83
127
  rdoc_options: []
84
128
  require_paths:
85
129
  - lib
@@ -94,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
138
  - !ruby/object:Gem::Version
95
139
  version: '0'
96
140
  requirements: []
97
- rubygems_version: 3.2.32
98
- signing_key:
141
+ rubygems_version: 3.3.7
142
+ signing_key:
99
143
  specification_version: 4
100
144
  summary: A Rails helper to package your code.
101
145
  test_files: []