stimpack 0.2.0 → 0.5.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: 51aa29c2b4753868e002f2317fa395fe14daee1f534fddea2d04eeae81feb6fe
4
- data.tar.gz: 44ca94cec6bad72328db16adfb5c809c4b0f0f630bfb33ecdc9be2492cc1270a
3
+ metadata.gz: 4ca6d661bee358381b9fc2fc2b40b9208c52ebc279cada30b1f8cd8d416b257e
4
+ data.tar.gz: 03f9fa4999c375228668a02d25712c11bc904a9e41f77f3ef4298127f9c814b4
5
5
  SHA512:
6
- metadata.gz: 297365c1a65d1f4e783c7ec9a13b764904eb45ef4f083516d85288b7bfdbd45d69b576c0756449d207e721c7be5a91d3e965985fa2517db6efa864ddb323e7a1
7
- data.tar.gz: a2f6604cdf86b588f290b6c1b503e8883fecbbb6083a21fd03d6e815596fcada6f90c5d49cd929030f39c248cbaf32d1b1ddb7d0bb3be11493b183372f34f149
6
+ metadata.gz: 6744c141fc73982fda1713198e1b6ad78971167eb7546b4be64702210b0289aa15a037fbdfa5f547e9ca732ed830d5c376710e7d365276640139af31cdb05321
7
+ data.tar.gz: 1fac57fcffcaefcf08b54c20750db09732ba565f41d76ce6fc81ce5eb1b1a696364389ebf7377820bdc437527ee20d5b093a096bcae53b0d8af9e85af9d56e13
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
@@ -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")}")
@@ -3,11 +3,10 @@
3
3
  module Stimpack
4
4
  class Pack
5
5
  class Configuration
6
- FILE = "package.yml"
7
6
  KEY = "metadata"
8
7
 
9
- def initialize(pack)
10
- @pack = pack
8
+ def initialize(path)
9
+ @path = path
11
10
  end
12
11
 
13
12
  def engine
@@ -18,7 +17,7 @@ module Stimpack
18
17
  private
19
18
 
20
19
  def data
21
- @data ||= YAML.load_file(@pack.path.join(FILE)).fetch(KEY, {}).freeze
20
+ @data ||= YAML.load_file(@path).fetch(KEY, {}).freeze
22
21
  end
23
22
  end
24
23
  end
data/lib/stimpack/pack.rb CHANGED
@@ -2,12 +2,18 @@
2
2
 
3
3
  module Stimpack
4
4
  class Pack
5
+ PACKAGE_FILE = "package.yml"
6
+
5
7
  autoload :Configuration, "stimpack/pack/configuration"
6
8
 
7
9
  attr_reader :name
8
10
  attr_reader :path
9
11
  attr_reader :engine
10
12
 
13
+ def self.create(path)
14
+ new(path) if path.join(PACKAGE_FILE).exist?
15
+ end
16
+
11
17
  def initialize(path)
12
18
  @path = path
13
19
  @name = path.relative_path_from(Packs.root)
@@ -22,7 +28,7 @@ module Stimpack
22
28
  end
23
29
 
24
30
  def config
25
- @config ||= Configuration.new(self)
31
+ @config ||= Configuration.new(path.join(PACKAGE_FILE))
26
32
  end
27
33
 
28
34
  private
@@ -14,7 +14,7 @@ module Stimpack
14
14
  def resolve
15
15
  # Gather all the packs under the root directory and create packs.
16
16
  root.children.select(&:directory?).sort!.each do |path|
17
- pack = Pack.new(path)
17
+ next unless pack = Pack.create(path)
18
18
  @packs[pack.name] = pack
19
19
  end
20
20
  @packs.freeze
@@ -1,3 +1,3 @@
1
1
  module Stimpack
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.5.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.2.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-08 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Package your code.
55
+ description: stimpack establishes and implements a set of conventions for splitting
56
+ up large monoliths.
56
57
  email:
57
58
  - gusto-opensource-buildkite@gusto.com
58
59
  executables: []