poepod 0.1.7 → 0.1.8

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: 3bc92cfee72702377260c08e2639cf32b789e54be73d3cea7896bde4bf357332
4
- data.tar.gz: f79c5a7847f8329c2a1c5ef1718c97b7ce18852df727a5d92c2b58244da2a7c0
3
+ metadata.gz: 5f3b75d6903698ba37dea1a00b73ff9d6a5672436dadac4cf452fd4d0ed46416
4
+ data.tar.gz: cfc4055807a6cb01ed40cb685be644e91317bfd6303120fa75410b97eff5e7c1
5
5
  SHA512:
6
- metadata.gz: 92da41a07f4007489ccba2dacd7a0e0eb194042916a3172d6b62a2e246a8d80eb364816ad0a5721157e1da5367071dfa34e5ca80c3e419ee2a81ddc609f17aa0
7
- data.tar.gz: cd07a158aab095842892fbd8dd34154811be5d64d5bed0af27d3a085974a1955217ab7a1d445975c993ee30ffb57e57b679958d870785d98767babb7e18042f9
6
+ metadata.gz: ecdede017300986e4d1a226f895f232b91a182f6ade3384d804308239b1b252251e8f36fac652667c41a3c2baa05927a98b5f67c779b176e4b4e7a4d939e302f
7
+ data.tar.gz: aace78fd62422ec85134e79def873f3cc721b26f44b70563741443f3b3de23b8f29f0d7c3d9c0b8933a55ea0a2a80579a0140575539c7d901c7dbe1a77cc313e
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 3.0
3
5
 
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,122 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2024-10-28 08:08:05 UTC using RuboCop version 1.67.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ Layout/ElseAlignment:
12
+ Exclude:
13
+ - 'lib/poepod/processor.rb'
14
+
15
+ # Offense count: 1
16
+ # This cop supports safe autocorrection (--autocorrect).
17
+ Layout/EmptyLineAfterMagicComment:
18
+ Exclude:
19
+ - 'lib/poepod/file_processor.rb'
20
+
21
+ # Offense count: 1
22
+ # This cop supports safe autocorrection (--autocorrect).
23
+ # Configuration parameters: EnforcedStyleAlignWith, Severity.
24
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
25
+ Layout/EndAlignment:
26
+ Exclude:
27
+ - 'lib/poepod/processor.rb'
28
+
29
+ # Offense count: 1
30
+ # This cop supports safe autocorrection (--autocorrect).
31
+ # Configuration parameters: Width, AllowedPatterns.
32
+ Layout/IndentationWidth:
33
+ Exclude:
34
+ - 'lib/poepod/processor.rb'
35
+
36
+ # Offense count: 5
37
+ # This cop supports safe autocorrection (--autocorrect).
38
+ # Configuration parameters: AutoCorrect.
39
+ Lint/UselessAssignment:
40
+ Exclude:
41
+ - 'lib/poepod/gem_processor.rb'
42
+ - 'spec/poepod/gem_processor_spec.rb'
43
+
44
+ # Offense count: 1
45
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
46
+ Metrics/AbcSize:
47
+ Max: 24
48
+
49
+ # Offense count: 12
50
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
51
+ # AllowedMethods: refine
52
+ Metrics/BlockLength:
53
+ Max: 158
54
+
55
+ # Offense count: 1
56
+ # Configuration parameters: CountComments, CountAsOne.
57
+ Metrics/ClassLength:
58
+ Max: 105
59
+
60
+ # Offense count: 5
61
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
62
+ Metrics/MethodLength:
63
+ Max: 18
64
+
65
+ # Offense count: 2
66
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
67
+ Metrics/ParameterLists:
68
+ Max: 7
69
+
70
+ # Offense count: 1
71
+ # This cop supports unsafe autocorrection (--autocorrect-all).
72
+ # Configuration parameters: EnforcedStyle.
73
+ # SupportedStyles: always, always_true, never
74
+ Style/FrozenStringLiteralComment:
75
+ Exclude:
76
+ - 'lib/poepod/file_processor.rb'
77
+
78
+ # Offense count: 1
79
+ # This cop supports safe autocorrection (--autocorrect).
80
+ Style/IfUnlessModifier:
81
+ Exclude:
82
+ - 'lib/poepod/processor.rb'
83
+
84
+ # Offense count: 1
85
+ Style/OptionalArguments:
86
+ Exclude:
87
+ - 'lib/poepod/processor.rb'
88
+
89
+ # Offense count: 4
90
+ # This cop supports safe autocorrection (--autocorrect).
91
+ # Configuration parameters: EnforcedStyleForMultiline.
92
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
93
+ Style/TrailingCommaInArguments:
94
+ Exclude:
95
+ - 'lib/poepod/cli.rb'
96
+ - 'lib/poepod/processor.rb'
97
+ - 'spec/poepod/file_processor_spec.rb'
98
+
99
+ # Offense count: 2
100
+ # This cop supports safe autocorrection (--autocorrect).
101
+ # Configuration parameters: EnforcedStyleForMultiline.
102
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
103
+ Style/TrailingCommaInArrayLiteral:
104
+ Exclude:
105
+ - 'lib/poepod/processor.rb'
106
+ - 'spec/poepod/gem_processor_spec.rb'
107
+
108
+ # Offense count: 1
109
+ # This cop supports safe autocorrection (--autocorrect).
110
+ # Configuration parameters: EnforcedStyleForMultiline.
111
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
112
+ Style/TrailingCommaInHashLiteral:
113
+ Exclude:
114
+ - 'spec/poepod/gem_processor_spec.rb'
115
+
116
+ # Offense count: 6
117
+ # This cop supports safe autocorrection (--autocorrect).
118
+ # Configuration parameters: AllowNamedUnderscoreVariables.
119
+ Style/TrailingUnderscoreVariable:
120
+ Exclude:
121
+ - 'lib/poepod/gem_processor.rb'
122
+ - 'spec/poepod/gem_processor_spec.rb'
data/lib/poepod/cli.rb CHANGED
@@ -44,7 +44,7 @@ module Poepod
44
44
  include_binary: options[:include_binary],
45
45
  include_dot_files: options[:include_dot_files],
46
46
  base_dir: base_dir,
47
- config_file: options[:config],
47
+ config_file: options[:config]
48
48
  )
49
49
  success, result, unstaged_files = processor.process(output_file)
50
50
  if success
@@ -81,7 +81,7 @@ module Poepod
81
81
  include_binary: options[:include_binary],
82
82
  include_dot_files: options[:include_dot_files],
83
83
  exclude: options[:exclude],
84
- base_dir: base_dir,
84
+ base_dir: base_dir
85
85
  )
86
86
  total_files, copied_files = processor.process(output_path.to_s)
87
87
  print_result(total_files, copied_files, output_path)
@@ -1,4 +1,3 @@
1
- # lib/poepod/file_processor.rb
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require_relative "processor"
@@ -29,9 +28,24 @@ module Poepod
29
28
  private
30
29
 
31
30
  def collect_files_to_process
32
- @patterns.flatten.each_with_object([]) do |pattern, files_to_process|
33
- files_to_process.concat(collect_files_from_pattern(pattern))
31
+ files_to_process = []
32
+
33
+ @patterns.flatten.each do |pattern|
34
+ expanded_pattern = File.expand_path(pattern)
35
+ if File.directory?(expanded_pattern)
36
+ # If the pattern is a directory, collect all files within it recursively
37
+ files = collect_files_from_pattern(File.join(expanded_pattern, "**", "*"))
38
+ files_to_process.concat(files)
39
+ elsif File.file?(expanded_pattern)
40
+ files_to_process << expanded_pattern unless should_exclude?(expanded_pattern)
41
+ else
42
+ # It's a pattern, collect matching files
43
+ files = collect_files_from_pattern(expanded_pattern)
44
+ files_to_process.concat(files)
45
+ end
34
46
  end
47
+
48
+ files_to_process.uniq
35
49
  end
36
50
  end
37
51
  end
@@ -3,6 +3,7 @@
3
3
  require_relative "processor"
4
4
  require "rubygems/specification"
5
5
  require "git"
6
+ require "pathname"
6
7
 
7
8
  module Poepod
8
9
  # Processes gem files for wrapping, handling unstaged files
@@ -35,7 +36,7 @@ module Poepod
35
36
 
36
37
  unstaged_files = check_unstaged_files
37
38
 
38
- total_files, copied_files = super(output_file)
39
+ super(output_file)
39
40
 
40
41
  [true, output_file, unstaged_files]
41
42
  end
@@ -46,11 +47,26 @@ module Poepod
46
47
  files_to_include = find_gemspec_files
47
48
  files_to_include += check_unstaged_files if @include_unstaged
48
49
 
49
- files_to_include.sort.uniq.reject do |relative_path|
50
- should_exclude?(File.join(@base_dir, relative_path))
51
- end.map do |relative_path|
52
- File.join(@base_dir, relative_path)
50
+ files_to_collect = []
51
+
52
+ files_to_include.sort.uniq.each do |relative_path|
53
+ full_path = File.join(@base_dir, relative_path)
54
+
55
+ next if should_exclude?(full_path)
56
+
57
+ if File.directory?(full_path)
58
+ # Recursively collect all files under the directory
59
+ files = collect_files_from_pattern(full_path)
60
+ files_to_collect.concat(files)
61
+ elsif File.file?(full_path)
62
+ files_to_collect << full_path
63
+ else
64
+ # Skip if neither file nor directory
65
+ next
66
+ end
53
67
  end
68
+
69
+ files_to_collect
54
70
  end
55
71
 
56
72
  def find_gemspec_files
@@ -10,7 +10,7 @@ module Poepod
10
10
  # Base processor class
11
11
  class Processor
12
12
  EXCLUDE_DEFAULT = [
13
- %r{node_modules/}, %r{.git/}, /.gitignore$/, /.DS_Store$/,
13
+ %r{node_modules/}, %r{.git/}, /.gitignore$/, /.DS_Store$/
14
14
  ].freeze
15
15
 
16
16
  def initialize(
@@ -56,9 +56,7 @@ module Poepod
56
56
 
57
57
  def collect_files_from_pattern(pattern)
58
58
  expanded_pattern = File.expand_path(pattern)
59
- if File.directory?(expanded_pattern)
60
- expanded_pattern = File.join(expanded_pattern, "**", "*")
61
- end
59
+ expanded_pattern = File.join(expanded_pattern, "**", "*") if File.directory?(expanded_pattern)
62
60
 
63
61
  Dir.glob(expanded_pattern, File::FNM_DOTMATCH).each_with_object([]) do |file_path, acc|
64
62
  next unless File.file?(file_path)
@@ -82,7 +80,7 @@ module Poepod
82
80
  mime_type = Marcel::MimeType.for(
83
81
  content,
84
82
  name: File.basename(file_path),
85
- declared_type: "text/plain",
83
+ declared_type: "text/plain"
86
84
  )
87
85
 
88
86
  !mime_type.start_with?("text/") && mime_type != "application/json"
@@ -93,10 +91,10 @@ module Poepod
93
91
  output ||= StringIO.new
94
92
 
95
93
  relative_path = if @base_dir
96
- Pathname.new(file_path).relative_path_from(@base_dir).to_s
97
- else
98
- file_path
99
- end
94
+ Pathname.new(file_path).relative_path_from(@base_dir).to_s
95
+ else
96
+ file_path
97
+ end
100
98
 
101
99
  puts "Adding to bundle: #{relative_path}"
102
100
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Poepod
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
@@ -147,4 +147,38 @@ RSpec.describe Poepod::FileProcessor do
147
147
  end.to raise_error(Encoding::InvalidByteSequenceError)
148
148
  end
149
149
  end
150
+
151
+ context "when directories are included in the file patterns (e.g., git submodules)" do
152
+ let(:submodule_dir) { File.join(temp_dir, "vendor", "submodule_project") }
153
+ let(:submodule_file) { File.join(submodule_dir, "submodule_file.rb") }
154
+
155
+ before do
156
+ # Simulate a submodule directory with a file
157
+ FileUtils.mkdir_p(submodule_dir)
158
+ File.write(submodule_file, "puts 'Hello from submodule'")
159
+
160
+ # Include the submodule directory in the patterns
161
+ @processor = described_class.new(
162
+ [text_file1, text_file2, submodule_dir],
163
+ output_file.path,
164
+ include_binary: false,
165
+ include_dot_files: false,
166
+ exclude: nil,
167
+ base_dir: temp_dir
168
+ )
169
+ end
170
+
171
+ it "includes files from directories specified in the patterns" do
172
+ total_files, copied_files = @processor.process(output_file.path)
173
+ expect(total_files).to eq(3) # text_file1, text_file2, submodule_file
174
+ expect(copied_files).to eq(3)
175
+
176
+ output_content = File.read(output_file.path, encoding: "utf-8")
177
+ expect(output_content).to include("Content of file1.\n")
178
+ expect(output_content).to include("Content of file2.\n")
179
+ expect(output_content).to include("puts 'Hello from submodule'")
180
+
181
+ expect(output_content).to include("--- START FILE: vendor/submodule_project/submodule_file.rb ---")
182
+ end
183
+ end
150
184
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # spec/poepod/gem_processor_spec.rb
4
3
  require "spec_helper"
5
4
  require "poepod/gem_processor"
6
5
  require "tempfile"
@@ -42,7 +41,7 @@ RSpec.describe Poepod::GemProcessor do
42
41
  end
43
42
 
44
43
  it "processes the gem files, includes README files, and spec files in sorted order" do
45
- success, result, _ = processor.process(output_file)
44
+ success, = processor.process(output_file)
46
45
  expect(success).to be true
47
46
  expect(File.exist?(output_file)).to be true
48
47
 
@@ -53,7 +52,7 @@ RSpec.describe Poepod::GemProcessor do
53
52
  "README.md",
54
53
  "README.txt",
55
54
  "lib/test_gem.rb",
56
- "spec/test_gem_spec.rb",
55
+ "spec/test_gem_spec.rb"
57
56
  ]
58
57
  expect(file_order).to eq(expected_order)
59
58
 
@@ -83,7 +82,7 @@ RSpec.describe Poepod::GemProcessor do
83
82
  let(:processor) { described_class.new("non_existent.gemspec") }
84
83
 
85
84
  it "returns an error" do
86
- success, error_message, _ = processor.process(output_file)
85
+ success, error_message, = processor.process(output_file)
87
86
  expect(success).to be false
88
87
  expect(error_message).to include("Error: The specified gemspec file")
89
88
  end
@@ -116,7 +115,7 @@ RSpec.describe Poepod::GemProcessor do
116
115
  "spec/test_gem_spec.rb" => "RSpec.describe TestGem do\nend",
117
116
  "README.md" => "# Test Gem\n\nThis is a test gem.",
118
117
  "README.txt" => "Test Gem\n\nThis is a test gem in plain text.",
119
- "lib/unstaged_file.rb" => "Unstaged content",
118
+ "lib/unstaged_file.rb" => "Unstaged content"
120
119
  }
121
120
 
122
121
  # Mock File.read
@@ -138,7 +137,7 @@ RSpec.describe Poepod::GemProcessor do
138
137
  end
139
138
  end
140
139
 
141
- success, result, unstaged_files = processor.process(output_file)
140
+ success, _, unstaged_files = processor.process(output_file)
142
141
  expect(success).to be true
143
142
  expect(unstaged_files).to eq(["lib/unstaged_file.rb"])
144
143
 
@@ -168,6 +167,36 @@ RSpec.describe Poepod::GemProcessor do
168
167
  expect(content).to eq(expected)
169
168
  end
170
169
  end
170
+
171
+ context "when gem includes directories in spec.files (e.g., git submodules)" do
172
+ let(:submodule_dir) { File.join(temp_dir, "vendor", "submodule_project") }
173
+ before do
174
+ # Simulate a submodule directory with a file
175
+ FileUtils.mkdir_p(submodule_dir)
176
+ File.write(File.join(submodule_dir, "submodule_file.rb"), "puts 'Hello from submodule'")
177
+
178
+ # Update gemspec to include the submodule directory
179
+ File.write(gemspec_file, <<~GEMSPEC)
180
+ Gem::Specification.new do |spec|
181
+ spec.name = "test_gem"
182
+ spec.version = "0.1.0"
183
+ spec.authors = ["Test Author"]
184
+ spec.files = ["lib/test_gem.rb", "vendor/submodule_project"]
185
+ spec.test_files = ["spec/test_gem_spec.rb"]
186
+ end
187
+ GEMSPEC
188
+ end
189
+
190
+ it "includes files from directories listed in spec.files" do
191
+ success, = processor.process(output_file)
192
+ expect(success).to be true
193
+ expect(File.exist?(output_file)).to be true
194
+
195
+ content = File.read(output_file)
196
+ expect(content).to include("--- START FILE: vendor/submodule_project/submodule_file.rb ---")
197
+ expect(content).to include("puts 'Hello from submodule'")
198
+ end
199
+ end
171
200
  end
172
201
  end
173
202
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poepod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-25 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -165,6 +165,7 @@ files:
165
165
  - ".gitignore"
166
166
  - ".rspec"
167
167
  - ".rubocop.yml"
168
+ - ".rubocop_todo.yml"
168
169
  - CODE_OF_CONDUCT.md
169
170
  - Gemfile
170
171
  - README.adoc