rugged 0.22.0b2 → 0.22.0b3

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
  SHA1:
3
- metadata.gz: a1fcbe10398bb6a72a8b366a061a86dc86a22d86
4
- data.tar.gz: 6d0ab2ee6aa49b3d0d6e7f9c2f5c7ee18f01e820
3
+ metadata.gz: 41fe2ca17d9e55ea205e190f8d0c23ff9d6a388f
4
+ data.tar.gz: 8a2e8c0501f8383b6c8ce747d212b7aa0d9a07fa
5
5
  SHA512:
6
- metadata.gz: 47f0d46dbfb6a493678c7c0fffc12d25ffadabc3b8210920a2f509556e2504b48de4223db27488e70a78da1d2bbf6d440dfe15b3992ff7a2ded9bdebf5219d3b
7
- data.tar.gz: 2c83e8937a0bda990da855f793901299269ea2cf174c2e7f7501795c7f3a7377b37b60fe555a453963206d93c4c035fe24c9ee02afcd084d101e484426b35030
6
+ metadata.gz: ca4649799366b724b65b4c257148c366f7e02545fa1834ff2eaf7742c33c4901e498d80a5ee5be1bd7b658051d3f626b2395d0ced84777cc488d1995cc1f1c51
7
+ data.tar.gz: ce5ac5b5439329dd959225a6225884136b7a78a5b501502c52dee7a9cc59b9e89d5343fdb7ada26a922cd96cf4052046ba5e4576005c49e6b633638db3d3c6df
@@ -32,7 +32,6 @@ extern VALUE rb_cRuggedRepo;
32
32
  static ID id_read;
33
33
 
34
34
  VALUE rb_cRuggedBlob;
35
- VALUE rb_cRuggedBlobLoader;
36
35
  VALUE rb_cRuggedBlobSig;
37
36
 
38
37
  /*
@@ -480,75 +479,46 @@ static VALUE rb_git_blob_diff(int argc, VALUE *argv, VALUE self)
480
479
  return rugged_patch_new(self, patch);
481
480
  }
482
481
 
483
- /*
484
- * call-seq:
485
- * Rugged::Blob::Loader.new(repository, max_size) -> Blob::Loader instance
486
- *
487
- * Create a Blob Loader instance that allows you to bring several blobs
488
- * from the object database with no extra memory cost by reusing the same
489
- * underlying storage.
490
- *
491
- * repository - the repo where the blobs will be loaded from
492
- * max_size - the maximum size for the underlying storage; blobs larger than
493
- * that size will be truncated
494
- *
495
- * Example:
496
- *
497
- * loader = loader = Rugged::Blob::Loader.new(@repo, 4 * 1024)
498
- * #=> Blob::Loader instance
499
- *
500
- * loader.load("d70d245ed97ed2aa596dd1af6536e4bfdb047b69")
501
- * #=> [contents, real_size]
502
- */
503
- static VALUE rb_git_blob_loader_new(VALUE self, VALUE rb_repo, VALUE rb_max_bytes)
482
+ static VALUE rb_git_blob_to_buffer(int argc, VALUE *argv, VALUE self)
504
483
  {
505
- long max_bytes;
506
-
507
- rugged_check_repo(rb_repo);
508
- Check_Type(rb_max_bytes, T_FIXNUM);
509
-
510
- /* extra byte for NULL-termination */
511
- max_bytes = (long)FIX2INT(rb_max_bytes) + 1;
512
-
513
- rb_iv_set(self, "@repository", rb_repo);
514
- rb_iv_set(self, "buffer", rb_str_buf_new(max_bytes));
515
- return Qnil;
516
- }
517
-
518
- static VALUE rb_git_blob_loader_load(VALUE self, VALUE rb_sha1)
519
- {
520
- VALUE rb_ret, rb_repo, rb_buffer;
484
+ VALUE rb_repo, rb_sha1, rb_max_bytes;
485
+ VALUE rb_ret;
521
486
 
522
487
  git_repository *repo = NULL;
523
488
  git_blob *blob = NULL;
524
489
 
525
- size_t size, capacity;
490
+ size_t size;
526
491
  const char *content;
527
492
 
528
- rb_repo = rb_iv_get(self, "@repository");
529
- rb_buffer = rb_iv_get(self, "buffer");
493
+ rb_scan_args(argc, argv, "21", &rb_repo, &rb_sha1, &rb_max_bytes);
530
494
 
531
- Check_Type(rb_buffer, T_STRING);
532
495
  rugged_check_repo(rb_repo);
533
496
  Data_Get_Struct(rb_repo, git_repository, repo);
534
497
 
535
498
  blob = (git_blob *)rugged_object_get(repo, rb_sha1, GIT_OBJ_BLOB);
536
499
 
537
500
  content = git_blob_rawcontent(blob);
538
- size = (long)git_blob_rawsize(blob);
539
- capacity = rb_str_capacity(rb_buffer);
501
+ size = git_blob_rawsize(blob);
540
502
 
541
- if (size > capacity - 1)
542
- size = capacity - 1;
503
+ if (!NIL_P(rb_max_bytes)) {
504
+ int maxbytes;
543
505
 
544
- memcpy(RSTRING_PTR(rb_buffer), content, size);
545
- rb_str_set_len(rb_buffer, size);
506
+ Check_Type(rb_max_bytes, T_FIXNUM);
507
+ maxbytes = FIX2INT(rb_max_bytes);
508
+
509
+ if (maxbytes >= 0 && (size_t)maxbytes < size)
510
+ size = (size_t)maxbytes;
511
+ }
546
512
 
547
513
  rb_ret = rb_ary_new();
548
- rb_ary_push(rb_ret, rb_buffer);
514
+
515
+ rb_ary_push(rb_ret, rb_str_new(content, size));
549
516
  rb_ary_push(rb_ret, INT2FIX(git_blob_rawsize(blob)));
550
517
 
551
518
  git_object_free((git_object*)blob);
519
+
520
+ /* TODO: LOC */
521
+
552
522
  return rb_ret;
553
523
  }
554
524
 
@@ -621,11 +591,9 @@ void Init_rugged_blob(void)
621
591
  rb_define_singleton_method(rb_cRuggedBlob, "from_disk", rb_git_blob_from_disk, 2);
622
592
  rb_define_singleton_method(rb_cRuggedBlob, "from_io", rb_git_blob_from_io, -1);
623
593
 
594
+ rb_define_singleton_method(rb_cRuggedBlob, "to_buffer", rb_git_blob_to_buffer, -1);
595
+
624
596
  rb_cRuggedBlobSig = rb_define_class_under(rb_cRuggedBlob, "HashSignature", rb_cObject);
625
597
  rb_define_singleton_method(rb_cRuggedBlobSig, "new", rb_git_blob_sig_new, -1);
626
598
  rb_define_singleton_method(rb_cRuggedBlobSig, "compare", rb_git_blob_sig_compare, 2);
627
-
628
- rb_cRuggedBlobLoader = rb_define_class_under(rb_cRuggedBlob, "Loader", rb_cObject);
629
- rb_define_method(rb_cRuggedBlobLoader, "initialize", rb_git_blob_loader_new, 2);
630
- rb_define_method(rb_cRuggedBlobLoader, "load", rb_git_blob_loader_load, 1);
631
599
  }
@@ -1,3 +1,3 @@
1
1
  module Rugged
2
- Version = VERSION = '0.22.0b2'
2
+ Version = VERSION = '0.22.0b3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0b2
4
+ version: 0.22.0b3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-23 00:00:00.000000000 Z
12
+ date: 2014-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler