gitignore_rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +24 -0
  3. data/ext/gitignore_binding/Cargo.lock +64 -0
  4. data/ext/gitignore_binding/Cargo.toml +12 -0
  5. data/ext/gitignore_binding/Rakefile +1 -0
  6. data/ext/gitignore_binding/src/lib.rs +41 -0
  7. data/ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build-script-build +0 -0
  8. data/ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build_script_build.dSYM/Contents/Info.plist +20 -0
  9. data/ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build_script_build.dSYM/Contents/Resources/DWARF/build_script_build +0 -0
  10. data/ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/output +0 -0
  11. data/ext/gitignore_binding/target/release/deps/libadvapi32-cfef7a1f30f1e5f6.rlib +0 -0
  12. data/ext/gitignore_binding/target/release/deps/libbuild-304afb6bdff23d72.rlib +0 -0
  13. data/ext/gitignore_binding/target/release/deps/libgitignore-c7373b3d965f16d9.rlib +0 -0
  14. data/ext/gitignore_binding/target/release/deps/libglob-25f28f4f852d8a9f.rlib +0 -0
  15. data/ext/gitignore_binding/target/release/deps/liblibc-144c435538abd757.rlib +0 -0
  16. data/ext/gitignore_binding/target/release/deps/librand-bdfcc55d3466feb3.rlib +0 -0
  17. data/ext/gitignore_binding/target/release/deps/libtempdir-666eac814577b56f.rlib +0 -0
  18. data/ext/gitignore_binding/target/release/deps/libwinapi-04bd24ca029a2f2c.rlib +0 -0
  19. data/ext/gitignore_binding/target/release/libgitignore_binding.dylib +0 -0
  20. data/lib/gitignore_rb.rb +11 -0
  21. data/lib/gitignore_rb/rust.rb +18 -0
  22. metadata +163 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8396d599d3e691008f1143d27f12cf2346e3e176
4
+ data.tar.gz: 39290eba069beb20a7fd5e6ea9c72d0b42b3a839
5
+ SHA512:
6
+ metadata.gz: 8ee7bd401e7bce01edd422d4aeb66963f426da37a7c87739fa73cb55d736972d39b3561b6a7e6f4b000b41edf12d9963952d5c54b2b063dff559f86563781082
7
+ data.tar.gz: 629c661de017d7f06b7eff07adc9efe19f2efd5c5755d37489b2031f1ecdba632d65de5cd6d7a7131fca07bae1f66f9c3f4290ec76b55defd1efb638423a9ea2
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # gitignore.rb [![Build Status](https://travis-ci.org/nathankleyn/gitignore.rb.svg)](https://travis-ci.org/nathankleyn/gitignore.rb)
2
+
3
+ This is an implementation of `.gitignore` parsing and matching in Rust. Use this library if you want to check whether a given path would be excluded by a `.gitignore` file.
4
+
5
+ This library wraps [my Rust implementation of `.gitignore` semantics](https://github.com/nathankleyn/gitignore.rs) for performance.
6
+
7
+ ## Usage
8
+
9
+ The Gem is called `gitignore_rb` and you can it is available via [RubyGems](https://rubygems.org/gems/gitignore_rb):
10
+
11
+ ```sh
12
+ gem install gitignore_rb
13
+ ```
14
+
15
+ ## Examples
16
+
17
+ A simple example is as follows:
18
+
19
+ ```ruby
20
+ require 'gitignore'
21
+
22
+ gi = GitIgnore.new('/path/to/.gitignore')
23
+ gi.included_files #=> ['foo', 'bar', 'lux/win', ...]
24
+ ```
@@ -0,0 +1,64 @@
1
+ [root]
2
+ name = "gitignore_binding"
3
+ version = "0.1.0"
4
+ dependencies = [
5
+ "gitignore 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
6
+ "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
7
+ ]
8
+
9
+ [[package]]
10
+ name = "advapi32-sys"
11
+ version = "0.1.2"
12
+ source = "registry+https://github.com/rust-lang/crates.io-index"
13
+ dependencies = [
14
+ "winapi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
15
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
16
+ ]
17
+
18
+ [[package]]
19
+ name = "gitignore"
20
+ version = "1.0.2"
21
+ source = "registry+https://github.com/rust-lang/crates.io-index"
22
+ dependencies = [
23
+ "glob 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
24
+ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
25
+ ]
26
+
27
+ [[package]]
28
+ name = "glob"
29
+ version = "0.2.10"
30
+ source = "registry+https://github.com/rust-lang/crates.io-index"
31
+
32
+ [[package]]
33
+ name = "libc"
34
+ version = "0.1.10"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+
37
+ [[package]]
38
+ name = "rand"
39
+ version = "0.3.11"
40
+ source = "registry+https://github.com/rust-lang/crates.io-index"
41
+ dependencies = [
42
+ "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
43
+ "libc 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
44
+ "winapi 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
45
+ ]
46
+
47
+ [[package]]
48
+ name = "tempdir"
49
+ version = "0.3.4"
50
+ source = "registry+https://github.com/rust-lang/crates.io-index"
51
+ dependencies = [
52
+ "rand 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
53
+ ]
54
+
55
+ [[package]]
56
+ name = "winapi"
57
+ version = "0.2.3"
58
+ source = "registry+https://github.com/rust-lang/crates.io-index"
59
+
60
+ [[package]]
61
+ name = "winapi-build"
62
+ version = "0.1.1"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "gitignore_binding"
3
+ version = "0.1.0"
4
+ authors = ["Nathan Kleyn <nathan@nathankleyn.com>"]
5
+
6
+ [lib]
7
+ name = "gitignore_binding"
8
+ crate-type = ["dylib"]
9
+
10
+ [dependencies]
11
+ libc = "0.1.10"
12
+ gitignore = "1.0.2"
@@ -0,0 +1 @@
1
+ # FIXME: Make this check for presence of `rustc` and compile the library.
@@ -0,0 +1,41 @@
1
+ #![feature(cstr_to_str)]
2
+ #![feature(cstr_memory)]
3
+
4
+ extern crate gitignore;
5
+ extern crate libc;
6
+
7
+ use std::ffi::CStr;
8
+ use std::ffi::CString;
9
+ use std::mem;
10
+ use std::path::Path;
11
+
12
+ #[repr(C)]
13
+ pub struct RubyArray {
14
+ len: libc::size_t,
15
+ data: *const libc::c_void,
16
+ }
17
+
18
+ impl RubyArray {
19
+ fn from_vec<T>(vec: Vec<T>) -> RubyArray {
20
+ let array = RubyArray {
21
+ data: vec.as_ptr() as *const libc::c_void,
22
+ len: vec.len() as libc::size_t
23
+ };
24
+ mem::forget(vec);
25
+ array
26
+ }
27
+ }
28
+
29
+ #[no_mangle]
30
+ pub extern "C" fn included_files(path_ptr: *const libc::c_char) -> RubyArray {
31
+ let path_cstr = unsafe { CStr::from_ptr(path_ptr) };
32
+ let path_and_str = path_cstr.to_str().unwrap();
33
+ let path = Path::new(path_and_str).to_path_buf();
34
+
35
+ let gitignore_path = path.join(".gitignore");
36
+ let file = gitignore::File::new(&gitignore_path).unwrap();
37
+
38
+ RubyArray::from_vec(file.included_files().unwrap().iter().map(|f|
39
+ CString::new(f.to_str().unwrap()).unwrap().into_raw()
40
+ ).collect())
41
+ }
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>English</string>
7
+ <key>CFBundleIdentifier</key>
8
+ <string>com.apple.xcode.dsym.build_script_build</string>
9
+ <key>CFBundleInfoDictionaryVersion</key>
10
+ <string>6.0</string>
11
+ <key>CFBundlePackageType</key>
12
+ <string>dSYM</string>
13
+ <key>CFBundleSignature</key>
14
+ <string>????</string>
15
+ <key>CFBundleShortVersionString</key>
16
+ <string>1.0</string>
17
+ <key>CFBundleVersion</key>
18
+ <string>1</string>
19
+ </dict>
20
+ </plist>
@@ -0,0 +1,11 @@
1
+ require 'gitignore_rb/rust'
2
+
3
+ class GitIgnoreRb
4
+ def initialize(path)
5
+ @path = path
6
+ end
7
+
8
+ def included_files
9
+ GitIgnoreRust::included_files(@path).to_a
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require 'ffi'
2
+
3
+ module GitIgnoreRust
4
+ extend FFI::Library
5
+
6
+ ffi_lib File.expand_path(File.join(__dir__, '../../ext/gitignore_binding/target/release/libgitignore_binding.dylib'))
7
+
8
+ class GitIgnoreBindingArray < FFI::Struct
9
+ layout :len, :size_t, # dynamic array layout
10
+ :data, :pointer
11
+
12
+ def to_a
13
+ self[:data].get_array_of_string(0, self[:len]).compact
14
+ end
15
+ end
16
+
17
+ attach_function :included_files, [:string], GitIgnoreBindingArray.by_value
18
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitignore_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Kleyn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.10
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: filewatcher
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.2'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.34.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.34.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.3.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.1
111
+ description: See https://github.com/nathankleyn/gitignore.rb for more information!
112
+ email: nathan@nathankleyn.com
113
+ executables: []
114
+ extensions:
115
+ - ext/gitignore_binding/Rakefile
116
+ extra_rdoc_files: []
117
+ files:
118
+ - README.md
119
+ - ext/gitignore_binding/Cargo.lock
120
+ - ext/gitignore_binding/Cargo.toml
121
+ - ext/gitignore_binding/Rakefile
122
+ - ext/gitignore_binding/src/lib.rs
123
+ - ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build-script-build
124
+ - ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build_script_build.dSYM/Contents/Info.plist
125
+ - ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/build_script_build.dSYM/Contents/Resources/DWARF/build_script_build
126
+ - ext/gitignore_binding/target/release/build/advapi32-sys-cfef7a1f30f1e5f6/output
127
+ - ext/gitignore_binding/target/release/deps/libadvapi32-cfef7a1f30f1e5f6.rlib
128
+ - ext/gitignore_binding/target/release/deps/libbuild-304afb6bdff23d72.rlib
129
+ - ext/gitignore_binding/target/release/deps/libgitignore-c7373b3d965f16d9.rlib
130
+ - ext/gitignore_binding/target/release/deps/libglob-25f28f4f852d8a9f.rlib
131
+ - ext/gitignore_binding/target/release/deps/liblibc-144c435538abd757.rlib
132
+ - ext/gitignore_binding/target/release/deps/librand-bdfcc55d3466feb3.rlib
133
+ - ext/gitignore_binding/target/release/deps/libtempdir-666eac814577b56f.rlib
134
+ - ext/gitignore_binding/target/release/deps/libwinapi-04bd24ca029a2f2c.rlib
135
+ - ext/gitignore_binding/target/release/libgitignore_binding.dylib
136
+ - lib/gitignore_rb.rb
137
+ - lib/gitignore_rb/rust.rb
138
+ homepage: https://github.com/nathankleyn/gitignore.rb
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.4.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Implementation of .gitignore file parsing and glob testing. This library
162
+ is a Ruby binding around gitignore.rs.
163
+ test_files: []