lib_ruby_diff 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: fcb4aebbd01f9fe9e3456997bb35bb261aa95a5e
4
- data.tar.gz: a8ebe873dd08b454409df15d7c3117c6907de0bf
3
+ metadata.gz: 6c924f059d90047b7d36299893d0f55485b6f315
4
+ data.tar.gz: c64b1a78c3b06bffadb23e913ea03bd965285327
5
5
  SHA512:
6
- metadata.gz: ec5073337da878f2880466dbff35fc97d576efb37939bf6891768933e99a315ae24bf3a177113a76fa61a9aa8862ba7c5b2981ef550735a4b11add456609f555
7
- data.tar.gz: c7127a35b94496764a6d9caf39dafa4f8328dc52b35abc483347b3d047d7c38b2c343ae9832ffab5377e18f9b64189e606ede5d02deb523c3663326ba757dcdb
6
+ metadata.gz: 50e92a0fe4c973531e75697b37501958860f128d38e973ade08cb8a92e3af4cfc845513ab455561ce4af3de46e99e3c03478dddbaec4411610b8fe250daced70
7
+ data.tar.gz: 5b83e33d3a3a16878cad61f3c17bbff4c90822652acfacabce64193b9756355728da21e0436fbc49e64b54a0dec48c708017dd5ac91881e0afff8dd27d3d2db9
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at dave@daveallie.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lib_ruby_diff.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dave Allie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # LibRubyDiff
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lib_ruby_diff`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'lib_ruby_diff'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install lib_ruby_diff
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lib_ruby_diff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
4
+
5
+ Rake::ExtensionTask.new "lib_ruby_diff" do |ext|
6
+ ext.lib_dir = "lib/lib_ruby_diff"
7
+ end
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lib_ruby_diff"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ rake compile
@@ -0,0 +1,107 @@
1
+ #include <ruby.h>
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+ #include <librsync.h>
5
+
6
+ VALUE LibRubyDiff = Qnil;
7
+
8
+ static VALUE lib_ruby_diff_signature(VALUE self, VALUE base_file_path, VALUE signature_file_path) {
9
+ FILE *base_file, *signature_file;
10
+ rs_result result;
11
+ rs_stats_t stats;
12
+
13
+ base_file = fopen(StringValuePtr(base_file_path), "rb");
14
+ signature_file = fopen(StringValuePtr(signature_file_path), "wb");
15
+
16
+ if (!base_file || !signature_file) {
17
+ rb_raise(rb_eIOError, "Failed to open required files. Check they exist and you have the correct permissions.");
18
+ return Qnil;
19
+ }
20
+
21
+ result = rs_sig_file(base_file, signature_file, RS_DEFAULT_BLOCK_LEN, 0, RS_BLAKE2_SIG_MAGIC, &stats);
22
+ if (result != RS_DONE) {
23
+ rb_raise(rb_eStandardError, "Failed to create signature file.");
24
+ return Qnil;
25
+ }
26
+
27
+ fclose(base_file);
28
+ fclose(signature_file);
29
+
30
+ return Qnil;
31
+ }
32
+
33
+ static VALUE lib_ruby_diff_delta(VALUE self, VALUE new_file_path, VALUE signature_file_path, VALUE delta_file_path) {
34
+ FILE *new_file, *signature_file, *delta_file;
35
+ rs_result result;
36
+ rs_stats_t stats;
37
+ rs_signature_t *signature;
38
+
39
+ new_file = fopen(StringValuePtr(new_file_path), "rb");
40
+ signature_file = fopen(StringValuePtr(signature_file_path), "rb");
41
+ delta_file = fopen(StringValuePtr(delta_file_path), "wb");
42
+
43
+ if (!new_file || !signature_file || !delta_file) {
44
+ rb_raise(rb_eIOError, "Failed to open required files. Check they exist and you have the correct permissions.");
45
+ return Qnil;
46
+ }
47
+
48
+ result = rs_loadsig_file(signature_file, &signature, &stats);
49
+ if (result != RS_DONE) {
50
+ rb_raise(rb_eStandardError, "Failed to load signature file.");
51
+ return Qnil;
52
+ }
53
+
54
+ result = rs_build_hash_table(signature);
55
+ if (result != RS_DONE) {
56
+ rb_raise(rb_eStandardError, "Failed to build hash table.");
57
+ return Qnil;
58
+ }
59
+
60
+ result = rs_delta_file(signature, new_file, delta_file, &stats);
61
+ if (result != RS_DONE) {
62
+ rb_raise(rb_eStandardError, "Failed to create delta file.");
63
+ return Qnil;
64
+ }
65
+
66
+ rs_free_sumset(signature);
67
+
68
+ fclose(new_file);
69
+ fclose(signature_file);
70
+ fclose(delta_file);
71
+
72
+ return Qnil;
73
+ }
74
+
75
+ static VALUE lib_ruby_diff_patch(VALUE self, VALUE base_file_path, VALUE delta_file_path, VALUE patched_file_path) {
76
+ FILE *base_file, *delta_file, *patched_file;
77
+ rs_stats_t stats;
78
+ rs_result result;
79
+
80
+ base_file = fopen(StringValuePtr(base_file_path), "rb");
81
+ delta_file = fopen(StringValuePtr(delta_file_path), "rb");
82
+ patched_file = fopen(StringValuePtr(patched_file_path), "wb");
83
+
84
+ if (!base_file || !delta_file || !patched_file) {
85
+ rb_raise(rb_eIOError, "Failed to open required files. Check they exist and you have the correct permissions.");
86
+ return Qnil;
87
+ }
88
+
89
+ result = rs_patch_file(base_file, delta_file, patched_file, &stats);
90
+ if (result != RS_DONE) {
91
+ rb_raise(rb_eStandardError, "Failed to create patched file.");
92
+ return Qnil;
93
+ }
94
+
95
+ fclose(base_file);
96
+ fclose(delta_file);
97
+ fclose(patched_file);
98
+
99
+ return Qnil;
100
+ }
101
+
102
+ void Init_lib_ruby_diff() {
103
+ LibRubyDiff = rb_define_module("LibRubyDiff");
104
+ rb_define_singleton_method(LibRubyDiff, "signature", lib_ruby_diff_signature, 2);
105
+ rb_define_singleton_method(LibRubyDiff, "delta", lib_ruby_diff_delta, 3);
106
+ rb_define_singleton_method(LibRubyDiff, "patch", lib_ruby_diff_patch, 3);
107
+ }
@@ -0,0 +1,2 @@
1
+ require 'lib_ruby_diff/version'
2
+ require 'lib_ruby_diff/lib_ruby_diff'
@@ -0,0 +1,3 @@
1
+ module LibRubyDiff
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lib_ruby_diff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lib_ruby_diff"
8
+ spec.version = LibRubyDiff::VERSION
9
+ spec.authors = ["Dave Allie"]
10
+ spec.email = ["dave@daveallie.com"]
11
+
12
+ spec.summary = %q{Ruby bindings for librsync core methods.}
13
+ spec.description = %q{Ruby bindings for librsync signature generation, patch generation, and patch application methods.}
14
+ spec.homepage = "https://github.com/daveallie/lib_ruby_diff"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ spec.extensions = ["ext/lib_ruby_diff/extconf.rb"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.12"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rake-compiler", "~> 1.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lib_ruby_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Allie
@@ -75,7 +75,21 @@ extensions:
75
75
  - ext/lib_ruby_diff/extconf.rb
76
76
  extra_rdoc_files: []
77
77
  files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
78
88
  - ext/lib_ruby_diff/extconf.rb
89
+ - ext/lib_ruby_diff/lib_ruby_diff.c
90
+ - lib/lib_ruby_diff.rb
91
+ - lib/lib_ruby_diff/version.rb
92
+ - lib_ruby_diff.gemspec
79
93
  homepage: https://github.com/daveallie/lib_ruby_diff
80
94
  licenses:
81
95
  - MIT