rbcsv 0.1.2 → 0.1.4
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 +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/ext/rbcsv/extconf.rb +13 -0
- data/ext/rbcsv/src/lib.rs +20 -3
- data/lib/rbcsv/version.rb +1 -1
- data/quick_test.rb +23 -0
- data/test_install.rb +38 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13df1c56f1b7a646d461ae0d1623ffb1e4f0a6ee6746da0e39fd9b680626a935
|
|
4
|
+
data.tar.gz: 54e9d6ea0e7ec1446479a87fb02ff1614bc693c3c8f8168f3c575589da09a8cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c27195b66c70740de593fdbe4bf3c69415dbc9332c708c3dcccdc93a1c455df639c8563d819760acf62dcc151bc057b39fd744118befd683ded3cde3fe461b1f
|
|
7
|
+
data.tar.gz: f27373dcfa45e8aa7f3142a9f2c4a6c968d1c2f92731eb1b01fed3776f135b528b16d4cc236af2bb49c9d8f3a94bb03a0e834937041a8dbbbe4d89e628578424
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.4.5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.4] - 2025-09-20
|
|
4
|
+
|
|
5
|
+
- **Fixed**: CSV parse method returning empty array due to incorrect header handling
|
|
6
|
+
- **Fixed**: CSV reader now processes all rows instead of skipping header row
|
|
7
|
+
- **Improved**: Added proper test coverage for simple CSV parsing
|
|
8
|
+
|
|
9
|
+
## [0.1.3] - 2025-09-20
|
|
10
|
+
|
|
11
|
+
- Internal version bump
|
|
12
|
+
|
|
13
|
+
## [0.1.2] - 2025-09-20
|
|
14
|
+
|
|
15
|
+
- Internal version bump
|
|
16
|
+
|
|
3
17
|
## [0.1.1] - 2025-09-20
|
|
4
18
|
|
|
5
19
|
- Fixed Cargo workspace configuration
|
data/ext/rbcsv/extconf.rb
CHANGED
|
@@ -4,3 +4,16 @@ require "mkmf"
|
|
|
4
4
|
require "rb_sys/mkmf"
|
|
5
5
|
|
|
6
6
|
create_rust_makefile("rbcsv/rbcsv")
|
|
7
|
+
|
|
8
|
+
# After Makefile generation, patch it to handle platform-specific output paths
|
|
9
|
+
makefile_path = "Makefile"
|
|
10
|
+
if File.exist?(makefile_path)
|
|
11
|
+
content = File.read(makefile_path)
|
|
12
|
+
|
|
13
|
+
# Find the RUSTLIB target and add copy command to handle platform-specific paths
|
|
14
|
+
content.gsub!(/(\$\(RUSTLIB\): FORCE\n\s+\$\(ECHO\) generating.*\n\s+\$\(CARGO\) rustc.*-l pthread)/,
|
|
15
|
+
'\1' + "\n\t@mkdir -p $(RB_SYS_CARGO_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)" +
|
|
16
|
+
"\n\t@if [ -f $(RB_SYS_CARGO_TARGET_DIR)/*/$(RB_SYS_CARGO_PROFILE_DIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT) ]; then cp $(RB_SYS_CARGO_TARGET_DIR)/*/$(RB_SYS_CARGO_PROFILE_DIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT) $(RB_SYS_CARGO_TARGET_DIR)/$(RB_SYS_CARGO_PROFILE_DIR)/$(SOEXT_PREFIX)$(TARGET_NAME).$(SOEXT); fi")
|
|
17
|
+
|
|
18
|
+
File.write(makefile_path, content)
|
|
19
|
+
end
|
data/ext/rbcsv/src/lib.rs
CHANGED
|
@@ -5,7 +5,10 @@ use magnus::{Error, exception, function, prelude::*, Ruby};
|
|
|
5
5
|
type Error = Box<dyn std::error::Error>;
|
|
6
6
|
|
|
7
7
|
fn parse(s: String) -> Result<Vec<Vec<String>>, Error> {
|
|
8
|
-
let mut reader = csv::
|
|
8
|
+
let mut reader = csv::ReaderBuilder::new()
|
|
9
|
+
.has_headers(false) // ヘッダーを無効にして、すべての行を処理
|
|
10
|
+
.from_reader(s.as_bytes());
|
|
11
|
+
|
|
9
12
|
let mut records = Vec::new();
|
|
10
13
|
|
|
11
14
|
for result in reader.records() {
|
|
@@ -44,9 +47,23 @@ mod tests {
|
|
|
44
47
|
|
|
45
48
|
assert!(result.is_ok());
|
|
46
49
|
|
|
50
|
+
let records = result.unwrap();
|
|
51
|
+
assert_eq!(records.len(), 3); // ヘッダー行も含むため3行
|
|
52
|
+
assert_eq!(records[0], vec!["name", "age", "city"]);
|
|
53
|
+
assert_eq!(records[1], vec!["Alice", "25", "Tokyo"]);
|
|
54
|
+
assert_eq!(records[2], vec!["Bob", "30", "Osaka"]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#[test]
|
|
58
|
+
fn test_parse_simple() {
|
|
59
|
+
let csv_data = "a,b\n1,2";
|
|
60
|
+
let result = parse(csv_data.to_string());
|
|
61
|
+
|
|
62
|
+
assert!(result.is_ok());
|
|
63
|
+
|
|
47
64
|
let records = result.unwrap();
|
|
48
65
|
assert_eq!(records.len(), 2);
|
|
49
|
-
assert_eq!(records[0], vec!["
|
|
50
|
-
assert_eq!(records[1], vec!["
|
|
66
|
+
assert_eq!(records[0], vec!["a", "b"]);
|
|
67
|
+
assert_eq!(records[1], vec!["1", "2"]);
|
|
51
68
|
}
|
|
52
69
|
}
|
data/lib/rbcsv/version.rb
CHANGED
data/quick_test.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Gemが利用可能か確認するためのワンライナーテスト
|
|
5
|
+
|
|
6
|
+
puts "Testing rbcsv gem installation..."
|
|
7
|
+
|
|
8
|
+
# gemコマンドでrbcsvが利用可能か確認
|
|
9
|
+
system_result = system("ruby -e \"require 'rbcsv'; puts 'rbcsv loaded successfully: version ' + RbCsv::VERSION\"")
|
|
10
|
+
|
|
11
|
+
if system_result
|
|
12
|
+
puts "\n✅ rbcsv gem is working!"
|
|
13
|
+
else
|
|
14
|
+
puts "\n❌ rbcsv gem is not working properly"
|
|
15
|
+
|
|
16
|
+
# デバッグ情報
|
|
17
|
+
puts "\nDebugging information:"
|
|
18
|
+
puts "Current Ruby: #{`ruby -v`.strip}"
|
|
19
|
+
puts "Gem list:"
|
|
20
|
+
system("gem list rbcsv")
|
|
21
|
+
puts "\nGem paths:"
|
|
22
|
+
system("ruby -e \"puts $LOAD_PATH.grep(/gem/)\"")
|
|
23
|
+
end
|
data/test_install.rb
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'rbcsv'
|
|
5
|
+
|
|
6
|
+
puts "rbcsv gem version: #{RbCsv::VERSION}"
|
|
7
|
+
puts "Testing CSV parsing..."
|
|
8
|
+
|
|
9
|
+
# Simple CSV data for testing
|
|
10
|
+
csv_data = <<~CSV
|
|
11
|
+
name,age,city
|
|
12
|
+
Alice,30,Tokyo
|
|
13
|
+
Bob,25,Osaka
|
|
14
|
+
Carol,35,Kyoto
|
|
15
|
+
CSV
|
|
16
|
+
|
|
17
|
+
begin
|
|
18
|
+
result = RbCsv.parse(csv_data)
|
|
19
|
+
|
|
20
|
+
puts "\nParsing successful!"
|
|
21
|
+
puts "Number of records: #{result.length}"
|
|
22
|
+
puts "\nParsed data:"
|
|
23
|
+
result.each_with_index do |row, index|
|
|
24
|
+
puts "Row #{index}: #{row.inspect}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
puts "\nVerifying structure:"
|
|
28
|
+
puts "First row: #{result[0]}"
|
|
29
|
+
puts "Second row: #{result[1]}"
|
|
30
|
+
puts "Name from first record: #{result[0][0]}"
|
|
31
|
+
puts "Age from first record: #{result[0][1]}"
|
|
32
|
+
|
|
33
|
+
puts "\n✅ rbcsv gem is working correctly!"
|
|
34
|
+
rescue => e
|
|
35
|
+
puts "❌ Error: #{e.message}"
|
|
36
|
+
puts e.backtrace
|
|
37
|
+
exit 1
|
|
38
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rbcsv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- fujitani sora
|
|
@@ -53,10 +53,12 @@ files:
|
|
|
53
53
|
- lib/rbcsv.rb
|
|
54
54
|
- lib/rbcsv/version.rb
|
|
55
55
|
- output_comparison.rb
|
|
56
|
+
- quick_test.rb
|
|
56
57
|
- sample.csv
|
|
57
58
|
- sig/r_csv.rbs
|
|
58
59
|
- test.rb
|
|
59
60
|
- test_fixed.rb
|
|
61
|
+
- test_install.rb
|
|
60
62
|
homepage: https://github.com/fs0414/rbcsv
|
|
61
63
|
licenses:
|
|
62
64
|
- MIT
|