packs 0.0.44 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3409cd21dc5284518fa90923038c0dee964186909b2934445ae0872d97b2c101
4
- data.tar.gz: 9bac9fc2170f7aeaa52e4b141dd37cfcf19fb7c3577a80e29d49cfb07dfd229b
3
+ metadata.gz: cedac59e21e3cfabcc0e70369a37f099d917c6092c75a9415e4935a9bec705af
4
+ data.tar.gz: 36307b5c6d741d2145e73b827ea66ace06cffa0123101443f4b0d2b30e09a5e9
5
5
  SHA512:
6
- metadata.gz: 40891c45799b1d861ac76794f3645250c213d217c3b92178af89bb07f519b4fe13ee1650efb693c9a1d859742860dc32ee1ceca7bdedeffb593bd951b25ec5de
7
- data.tar.gz: 3a212158f68da47f7a38ca60b16193ba72cdceb319c302aca547eae49f4a351d379cbe8d334703a4caf6d9c6fea4752a8959c76f18552fee9fda162069d635f9
6
+ metadata.gz: 9478f4344cdb4dc234abb52da988b9e63033234a78289d9bdcbdacb738f911c6fb98050b0c699d19157f100df7a0139ff0a4be453776bdefc0aafd140a71d9e8
7
+ data.tar.gz: 718c24457bc7b6f5d0b471f2954dbff83ebbbbb0602a32295fb8ffc6d0e9cfea44a8e49c3a9d26c938b78e34d1d67d774502b8db1b659e5a3f88cd3f7071802d
data/README.md CHANGED
@@ -15,6 +15,11 @@ pack_paths:
15
15
  - gems/* # gems can be packs too!
16
16
  ```
17
17
 
18
+ To customize the README template, include a `README_TEMPLATE.md` file in the root of your project. If you want to use a custom path for your README template, you can specify it in the `packs.yml` file in the root of your project:
19
+ ```yml
20
+ readme_template_path: my_folder/README_STUFF.md
21
+ ```
22
+
18
23
  # Ecosystem
19
24
  The rest of the [rubyatscale](https://github.com/rubyatscale) ecosystem is intended to help make using packs and improving the boundaries between them more clear.
20
25
 
@@ -7,6 +7,9 @@ module Packs
7
7
  class Configuration
8
8
  extend T::Sig
9
9
 
10
+ CONFIGURATION_PATHNAME = T.let(Pathname.new('packs.yml'), Pathname)
11
+ DEFAULT_README_TEMPLATE_PATHNAME = T.let(Pathname.new('README_TEMPLATE.md'), Pathname)
12
+
10
13
  sig { params(enforce_dependencies: T::Boolean).void }
11
14
  attr_writer :enforce_dependencies
12
15
 
@@ -45,6 +48,18 @@ module Packs
45
48
  def default_enforce_dependencies
46
49
  true
47
50
  end
51
+
52
+ sig { returns(Pathname) }
53
+ def readme_template_pathname
54
+ config_hash = CONFIGURATION_PATHNAME.exist? ? YAML.load_file(CONFIGURATION_PATHNAME) : {}
55
+
56
+ specified_readme_template_path = config_hash['readme_template_path']
57
+ if specified_readme_template_path.nil?
58
+ DEFAULT_README_TEMPLATE_PATHNAME
59
+ else
60
+ Pathname.new(specified_readme_template_path)
61
+ end
62
+ end
48
63
  end
49
64
 
50
65
  class << self
@@ -53,15 +53,20 @@ module Packs
53
53
 
54
54
  sig { returns(FileMoveOperation) }
55
55
  def spec_file_move_operation
56
+ path_parts = filepath_without_pack_name.split('/')
57
+ folder = T.must(path_parts[0])
58
+ file_extension = T.must(filepath_without_pack_name.split('.').last)
59
+
56
60
  # This could probably be implemented by some "strategy pattern" where different extension types are handled by different helpers
57
61
  # Such a thing could also include, for example, when moving a controller, moving its ERB view too.
58
- if origin_pathname.extname == '.rake'
59
- new_origin_pathname = origin_pathname.sub('/lib/', '/spec/lib/').sub(%r{^lib/}, 'spec/lib/').sub('.rake', '_spec.rb')
60
- new_destination_pathname = destination_pathname.sub('/lib/', '/spec/lib/').sub(%r{^lib/}, 'spec/lib/').sub('.rake', '_spec.rb')
62
+ if folder == 'app'
63
+ new_origin_pathname = spec_pathname_for_app(origin_pathname, file_extension)
64
+ new_destination_pathname = spec_pathname_for_app(destination_pathname, file_extension)
61
65
  else
62
- new_origin_pathname = origin_pathname.sub('/app/', '/spec/').sub(%r{^app/}, 'spec/').sub('.rb', '_spec.rb')
63
- new_destination_pathname = destination_pathname.sub('/app/', '/spec/').sub(%r{^app/}, 'spec/').sub('.rb', '_spec.rb')
66
+ new_origin_pathname = spec_pathname_for_non_app(origin_pathname, file_extension, folder)
67
+ new_destination_pathname = spec_pathname_for_non_app(destination_pathname, file_extension, folder)
64
68
  end
69
+
65
70
  FileMoveOperation.new(
66
71
  origin_pathname: new_origin_pathname,
67
72
  destination_pathname: new_destination_pathname,
@@ -69,8 +74,38 @@ module Packs
69
74
  )
70
75
  end
71
76
 
77
+ sig { params(filepath: Pathname, pack: T.nilable(Packs::Pack)).returns(String) }
78
+ def self.get_filepath_without_pack_name(filepath, pack)
79
+ if pack
80
+ filepath.to_s.gsub("#{pack.name}/", '')
81
+ else
82
+ filepath.to_s
83
+ end
84
+ end
85
+
72
86
  private
73
87
 
88
+ sig { returns(String) }
89
+ def filepath_without_pack_name
90
+ self.class.get_filepath_without_pack_name(origin_pathname, origin_pack)
91
+ end
92
+
93
+ sig { params(pathname: Pathname, file_extension: String).returns(Pathname) }
94
+ def spec_pathname_for_app(pathname, file_extension)
95
+ pathname
96
+ .sub('/app/', '/spec/')
97
+ .sub(%r{^app/}, 'spec/')
98
+ .sub(".#{file_extension}", '_spec.rb')
99
+ end
100
+
101
+ sig { params(pathname: Pathname, file_extension: String, folder: String).returns(Pathname) }
102
+ def spec_pathname_for_non_app(pathname, file_extension, folder)
103
+ pathname
104
+ .sub("/#{folder}/", "/spec/#{folder}/")
105
+ .sub(%r{^#{folder}/}, "spec/#{folder}/")
106
+ .sub(".#{file_extension}", '_spec.rb')
107
+ end
108
+
74
109
  sig { params(path: Pathname).returns(FileMoveOperation) }
75
110
  def relative_to(path)
76
111
  FileMoveOperation.new(
@@ -148,6 +148,11 @@ module Packs
148
148
 
149
149
  sig { params(pack_name: String).returns(String) }
150
150
  def on_create_readme_todo(pack_name)
151
+ readme_template_pathname = Packs.config.readme_template_pathname
152
+ readme_template = readme_template_pathname.read if readme_template_pathname.exist?
153
+
154
+ return readme_template unless readme_template.nil?
155
+
151
156
  <<~MSG
152
157
  Welcome to `#{pack_name}`!
153
158
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.44
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal
@@ -344,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  - !ruby/object:Gem::Version
345
345
  version: '0'
346
346
  requirements: []
347
- rubygems_version: 3.5.9
347
+ rubygems_version: 3.5.22
348
348
  signing_key:
349
349
  specification_version: 4
350
350
  summary: Provides CLI tools for working with ruby packs.