stimpack 0.0.1.alpha1 → 1.0.0.alpha5

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: fbbb988cfbc8e3fb761d92e2d989dd546ef196a9acada9bae2718424c81f2d74
4
- data.tar.gz: 735f0e30435e5230f2a13d11e9bb0d46a4bfd613ff7e5af79b6bbe9c8d9ec9a8
3
+ metadata.gz: 21ba1439fa4a748325f454945071ef783c608ca679abcf6756300976afed414a
4
+ data.tar.gz: 4ca99c4daac00bb7c4c44e9c8f9a32e59019201dd3d84ca3717cdcaccb253103
5
5
  SHA512:
6
- metadata.gz: 0b4e2c7457d511322225671c656267733c429fc5b4938450e466bd7fbee2a16068b5b2f4fc5ed6e33939c60d7835033b494ee6ef8407b247eda44fa2af0f04cd
7
- data.tar.gz: be22569f23c0e65833573758537e60e6fa9a67d4090f04892e44adf4705cc26b8b3e902ecd695d81d375ae823b474399ea1935f991e7d7186a1dfd4dc203ef96
6
+ metadata.gz: 88dfe424e0df8beea1894aec9c1d67a7e5b4134464ab9162650fbf592e1d07afb3aa8fb81b355f900bb36614be6ae3048b1ac44675736b35dc18eda02cad01a9
7
+ data.tar.gz: d4d72de149d1f9ec3321e71e9c6980b9841535e1b737dd9979b3c68667306e5b531a88aa3f7ceffe4f8484ef1f43f32954448aa3f5c5f1528f55eef11548dcfe
data/README.md CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'stimpack'
12
+ gem "stimpack"
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -33,4 +33,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
33
  ## Contributing
34
34
 
35
35
  Bug reports and pull requests are welcome on GitHub at https://github.com/ngan/stimpack.
36
-
data/lib/stimpack.rb CHANGED
@@ -1,6 +1,41 @@
1
- require "stimpack/version"
1
+ require "active_support"
2
+ require "rails"
2
3
 
3
4
  module Stimpack
5
+ extend ActiveSupport::Autoload
6
+
7
+ autoload :Integrations
8
+ autoload :Packs
9
+ autoload :Railtie
10
+ autoload :Settings
11
+ autoload :Stim
12
+
4
13
  class Error < StandardError; end
5
- # Your code goes here...
14
+
15
+ class << self
16
+ def start!
17
+ @started = @started ? return : true
18
+
19
+ Packs.resolve
20
+
21
+ install_integrations
22
+ end
23
+
24
+ def finalize!
25
+ @finalized = @finalized ? return : true
26
+ end
27
+
28
+ def [](name)
29
+ Packs[name.to_s]
30
+ end
31
+
32
+ private
33
+
34
+ def install_integrations
35
+ Integrations::FactoryBot.install
36
+ Integrations::RSpec.install
37
+ end
38
+ end
6
39
  end
40
+
41
+ require "stimpack/railtie"
@@ -0,0 +1,10 @@
1
+ require "active_support"
2
+
3
+ module Stimpack
4
+ module Integrations
5
+ extend ActiveSupport::Autoload
6
+
7
+ autoload :RSpec, "stimpack/integrations/rspec"
8
+ autoload :FactoryBot, "stimpack/integrations/factory_bot"
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Stimpack
2
+ module Integrations
3
+ class FactoryBot
4
+ def self.install
5
+ return unless Rails.configuration.respond_to?(:factory_bot)
6
+
7
+ Packs.each do |pack|
8
+ Rails.configuration.factory_bot.definition_file_paths << pack.settings.relative_path.join("spec/factories").to_s
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Stimpack
2
+ module Integrations
3
+ class RSpec
4
+ def self.install
5
+ return unless defined?(::RSpec)
6
+
7
+ Packs.each do |pack|
8
+ ::RSpec.configuration.pattern.concat(",#{pack.settings.relative_path.join("spec/**/*_spec.rb")}")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,57 @@
1
+ require "active_support"
2
+ require "pathname"
3
+ require "rails"
4
+
5
+ module Stimpack
6
+ module Packs
7
+ PATH = Pathname.new("packs").freeze
8
+ PACK_CLASS = "Pack".freeze
9
+
10
+ class << self
11
+ def resolve
12
+ PATH.glob("**/#{Settings::PACK_CONFIG}").each do |path|
13
+ path = path.dirname
14
+ create(path.relative_path_from(PATH).to_s, path.expand_path)
15
+ end
16
+ end
17
+
18
+ def create(name, path)
19
+ settings = Settings.new(name, path)
20
+ namespace = create_namespace(settings.engine? ? Object : self, name)
21
+ stim = Stim.new(settings, namespace)
22
+ @packs[name] = namespace.const_set(PACK_CLASS, Class.new(Rails::Engine)).include(stim)
23
+ end
24
+
25
+ def find(path)
26
+ path = "#{path}/"
27
+
28
+ @packs.values.find do |pack|
29
+ path.start_with?("#{pack.root}/")
30
+ end
31
+ end
32
+
33
+ def [](name)
34
+ @packs[name]
35
+ end
36
+
37
+ def each(*args, &block)
38
+ @packs.each_value(*args, &block)
39
+ end
40
+
41
+ private
42
+
43
+ def create_namespace(base, name)
44
+ namespace = ActiveSupport::Inflector.camelize(name)
45
+ namespace.split("::").reduce(base) do |current_base, mod|
46
+ if current_base.const_defined?(mod)
47
+ current_base.const_get(mod)
48
+ else
49
+ current_base.const_set(mod, Module.new)
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ @packs = {}
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ require "rails"
2
+
3
+ module Stimpack
4
+ class Railtie < Rails::Railtie
5
+ config.before_configuration do
6
+ Stimpack.start!
7
+ end
8
+
9
+ config.after_initialize do
10
+ Stimpack.finalize!
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Stimpack
4
+ class Settings
5
+ PACK_CONFIG = "package.yml"
6
+
7
+ attr_reader :name
8
+ attr_reader :path
9
+
10
+ def initialize(name, path)
11
+ @name = name
12
+ @path = path
13
+ end
14
+
15
+ def relative_path
16
+ @path.relative_path_from(Rails.root)
17
+ end
18
+
19
+ def engine
20
+ config.fetch("engine", false)
21
+ end
22
+ alias_method :engine?, :engine
23
+
24
+ private
25
+
26
+ def config
27
+ @config ||= begin
28
+ package_config = YAML.load_file(path.join(PACK_CONFIG))
29
+ package_config.fetch("metadata", {}).freeze
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ module Stimpack
2
+ class Stim < Module
3
+ def initialize(settings, namespace)
4
+ @settings = settings
5
+ @namespace = namespace
6
+ super()
7
+ end
8
+
9
+ def included(engine)
10
+ engine.attr_accessor(:settings)
11
+ engine.settings = @settings
12
+ engine.called_from = @settings.path
13
+ engine.extend(ClassMethods)
14
+
15
+ if @settings.engine?
16
+ engine.isolate_namespace(@namespace)
17
+ end
18
+ end
19
+
20
+ module ClassMethods
21
+ def find_root(_from)
22
+ called_from
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Stimpack
2
- VERSION = "0.0.1.alpha1"
2
+ VERSION = "1.0.0.alpha5".freeze
3
3
  end
metadata CHANGED
@@ -1,16 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha1
4
+ version: 1.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ngan Pham
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-18 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Name hold for upcoming gem
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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
+ description: Package your code.
14
56
  email:
15
57
  - gusto-opensource-buildkite@gusto.com
16
58
  executables: []
@@ -21,6 +63,13 @@ files:
21
63
  - bin/console
22
64
  - bin/setup
23
65
  - lib/stimpack.rb
66
+ - lib/stimpack/integrations.rb
67
+ - lib/stimpack/integrations/factory_bot.rb
68
+ - lib/stimpack/integrations/rspec.rb
69
+ - lib/stimpack/packs.rb
70
+ - lib/stimpack/railtie.rb
71
+ - lib/stimpack/settings.rb
72
+ - lib/stimpack/stim.rb
24
73
  - lib/stimpack/version.rb
25
74
  homepage: https://github.com/Gusto/stimpack
26
75
  licenses: []
@@ -36,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
85
  requirements:
37
86
  - - ">="
38
87
  - !ruby/object:Gem::Version
39
- version: 2.3.0
88
+ version: '2.7'
40
89
  required_rubygems_version: !ruby/object:Gem::Requirement
41
90
  requirements:
42
91
  - - ">"
@@ -46,5 +95,5 @@ requirements: []
46
95
  rubygems_version: 3.1.2
47
96
  signing_key:
48
97
  specification_version: 4
49
- summary: Name hold for upcoming gem
98
+ summary: A Rails helper to package your code.
50
99
  test_files: []