extzstd 0.0.1.CONCEPT

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 714080450979b0ec369f0afc948a7018882da0bd
4
+ data.tar.gz: a7b33f5732cab823a73f9b31f2e0a711e1976caa
5
+ SHA512:
6
+ metadata.gz: cbcf17649efbb2a49ecd26e2059ea74f2e9bb34eda0b6fff8694f522fd2487bbceedc6cc76fd7e2c674cab7cfa7a173d7c26c54b849cd010f9e98162bee5f434
7
+ data.tar.gz: e9eba393e111181cae14f787672abd2fe24fdf316cf03158a0e0c696287501334437ef89f0634eca71a5e589e17dc32acd6bc5cb8b2341c233e029dc04fe923c
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2015, dearblue. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or
4
+ without modification, are permitted provided that the following
5
+ conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in
11
+ the documentation and/or other materials provided with the
12
+ distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # encoding:utf-8 ;
2
+
3
+ # extzstd - ruby binding for Zstandard (zstd)
4
+
5
+ This is ruby binding for compression library
6
+ [Zstd (https://github.com/Cyan4973/zstd)](https://github.com/Cyan4973/zstd).
7
+
8
+ * PACKAGE NAME: extzstd
9
+ * AUTHOR: dearblue <dearblue@users.sourceforge.jp>
10
+ * VERSION: 0.0.1.CONCEPT
11
+ * LICENSING: 2-clause BSD License
12
+ * REPORT ISSUE TO: <http://sourceforge.jp/projects/rutsubo/ticket/>
13
+ * DEPENDENCY RUBY: ruby-2.0+
14
+ * DEPENDENCY RUBY GEMS: (none)
15
+ * DEPENDENCY LIBRARY: (none)
16
+ * BUNDLED EXTERNAL LIBRARIES:
17
+ * zstd <https://github.com/Cyan4973/zstd>
18
+ (commit-e739b273f95902b7616e11338a4ef04bebc9d07b (Mon Feb 9 01:53:12 2015 +0100))
19
+
20
+
21
+ ## HOW TO USE
22
+
23
+ ### Simply process
24
+
25
+ ``` ruby:ruby
26
+ # First, load library
27
+ require "extzstd"
28
+
29
+ # Prepair data
30
+ source = "sample data..." * 50
31
+
32
+ # Directly compression
33
+ encdata = Zstd.encode(source)
34
+ puts "encdata.bytesize=#{encdata.bytesize}"
35
+
36
+ # Directly decompression
37
+ maxdestsize = source.bytesize # MUST BE ORIGINAL SIZE OR MORE! If given a smaller size, crash ruby interpreter.
38
+ decdata = Zstd.decode(encdata, maxdestsize)
39
+ puts "decdata.bytesize=#{decdata.bytesize}"
40
+
41
+ # Comparison source and decoded data
42
+ p source == decdata # => true
43
+ ```
44
+
45
+ ----
46
+
47
+ [a stub]
data/Rakefile ADDED
@@ -0,0 +1,147 @@
1
+
2
+ require "rake/clean"
3
+
4
+ DOC = FileList["{README,LICENSE,CHANGELOG,Changelog,HISTORY}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"] +
5
+ FileList["ext/**/{README,LICENSE,CHANGELOG,Changelog,HISTORY}{,.ja}{,.txt,.rd,.rdoc,.md,.markdown}"]
6
+ #EXT = FileList["ext/**/*.{h,hh,c,cc,cpp,cxx}"] +
7
+ # FileList["ext/externals/**/*"]
8
+ EXT = FileList["ext/**/*"]
9
+ BIN = FileList["bin/*"]
10
+ LIB = FileList["lib/**/*.rb"]
11
+ SPEC = FileList["spec/**/*"]
12
+ EXAMPLE = FileList["examples/**/*"]
13
+ GEMSTUB_SRC = "gemstub.rb"
14
+ RAKEFILE = [File.basename(__FILE__), GEMSTUB_SRC]
15
+ EXTRA = []
16
+
17
+ load GEMSTUB_SRC
18
+
19
+ EXTCONF = FileList["ext/extconf.rb"]
20
+ EXTCONF.reject! { |n| !File.file?(n) }
21
+ GEMSTUB.extensions += EXTCONF
22
+ GEMSTUB.executables += FileList["bin/*"].map { |n| File.basename n }
23
+ GEMSTUB.executables.sort!
24
+
25
+ GEMFILE = "#{GEMSTUB.name}-#{GEMSTUB.version}.gem"
26
+ GEMSPEC = "#{GEMSTUB.name}.gemspec"
27
+
28
+ GEMSTUB.files += DOC + EXT + EXTCONF + BIN + LIB + SPEC + EXAMPLE + RAKEFILE + EXTRA
29
+ GEMSTUB.files.sort!
30
+ GEMSTUB.rdoc_options ||= %w(--charset UTF-8)
31
+ GEMSTUB.extra_rdoc_files += DOC + LIB + EXT.reject { |n| n.include?("/externals/") || !%w(.h .hh .c .cc .cpp .cxx).include?(File.extname(n)) }
32
+ GEMSTUB.extra_rdoc_files.sort!
33
+
34
+ CLEAN << GEMSPEC
35
+ CLOBBER << GEMFILE
36
+
37
+ task :default => :all
38
+
39
+
40
+ unless EXTCONF.empty?
41
+ RUBYSET ||= (ENV["RUBYSET"] || "").split(",")
42
+
43
+ if RUBYSET.nil? || RUBYSET.empty?
44
+ $stderr.puts <<-EOS
45
+ #{__FILE__}:
46
+ |
47
+ | If you want binary gem package, launch rake with ``RUBYSET`` enviroment
48
+ | variable for set ruby interpreters by comma separated.
49
+ |
50
+ | e.g.) $ rake RUBYSET=ruby
51
+ | or) $ rake RUBYSET=ruby20,ruby21,ruby22
52
+ |
53
+ EOS
54
+ else
55
+ platforms = RUBYSET.map { |ruby| `#{ruby} --disable gems -rrbconfig -e "puts RbConfig::CONFIG['arch']"`.chomp }
56
+ platforms1 = platforms.uniq
57
+ unless platforms1.size == 1 && !platforms1[0].empty?
58
+ raise "different platforms (#{Hash[*RUBYSET.zip(platforms).flatten].inspect})"
59
+ end
60
+ PLATFORM = platforms1[0]
61
+
62
+ RUBY_VERSIONS = RUBYSET.map do |ruby|
63
+ ver = `#{ruby} --disable gem -rrbconfig -e "puts RbConfig::CONFIG['ruby_version']"`.slice(/\d+\.\d+/)
64
+ raise "failed ruby checking - ``#{ruby}''" unless $?.success?
65
+ [ver, ruby]
66
+ end
67
+ SOFILES_SET = RUBY_VERSIONS.map { |(ver, ruby)| ["lib/#{ver}/#{GEMSTUB.name}.so", ruby] }
68
+ SOFILES = SOFILES_SET.map { |(lib, ruby)| lib }
69
+
70
+ GEMSTUB_NATIVE = GEMSTUB.dup
71
+ GEMSTUB_NATIVE.files += SOFILES
72
+ GEMSTUB_NATIVE.platform = Gem::Platform.new(PLATFORM).to_s
73
+ GEMSTUB_NATIVE.extensions.clear
74
+ GEMFILE_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.version}-#{GEMSTUB_NATIVE.platform}.gem"
75
+ GEMSPEC_NATIVE = "#{GEMSTUB_NATIVE.name}-#{GEMSTUB_NATIVE.platform}.gemspec"
76
+
77
+ task :all => ["native-gem", GEMFILE]
78
+
79
+ desc "build binary gem package"
80
+ task "native-gem" => GEMFILE_NATIVE
81
+
82
+ desc "generate binary gemspec"
83
+ task "native-gemspec" => GEMSPEC_NATIVE
84
+
85
+ file GEMFILE_NATIVE => DOC + EXT + EXTCONF + BIN + LIB + SPEC + EXAMPLE + SOFILES + RAKEFILE + [GEMSPEC_NATIVE] do
86
+ sh "gem build #{GEMSPEC_NATIVE}"
87
+ end
88
+
89
+ file GEMSPEC_NATIVE => RAKEFILE do
90
+ File.write(GEMSPEC_NATIVE, GEMSTUB_NATIVE.to_ruby, mode: "wb")
91
+ end
92
+
93
+ desc "build c-extension libraries"
94
+ task "sofiles" => SOFILES
95
+
96
+ SOFILES_SET.each do |(soname, ruby)|
97
+ sodir = File.dirname(soname)
98
+ makefile = File.join(sodir, "Makefile")
99
+
100
+ CLEAN << GEMSPEC_NATIVE << sodir
101
+ CLOBBER << GEMFILE_NATIVE
102
+
103
+ directory sodir
104
+
105
+ desc "generate Makefile for binary extension library"
106
+ file makefile => [sodir] + EXTCONF do
107
+ cd sodir do
108
+ sh "#{ruby} ../../#{EXTCONF[0]} \"--ruby=#{ruby}\""
109
+ end
110
+ end
111
+
112
+ desc "build binary extension library"
113
+ file soname => [makefile] + EXT do
114
+ cd sodir do
115
+ sh "make"
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+
123
+ task :all => GEMFILE
124
+
125
+ desc "generate local rdoc"
126
+ task :rdoc => DOC + EXT + LIB do
127
+ sh *(%w(rdoc) + GEMSTUB.rdoc_options + DOC + EXT + LIB)
128
+ end
129
+
130
+ desc "launch rspec"
131
+ task rspec: :all do
132
+ sh "rspec"
133
+ end
134
+
135
+ desc "build gem package"
136
+ task gem: GEMFILE
137
+
138
+ desc "generate gemspec"
139
+ task gemspec: GEMSPEC
140
+
141
+ file GEMFILE => DOC + EXT + EXTCONF + BIN + LIB + SPEC + EXAMPLE + RAKEFILE + [GEMSPEC] do
142
+ sh "gem build #{GEMSPEC}"
143
+ end
144
+
145
+ file GEMSPEC => RAKEFILE do
146
+ File.write(GEMSPEC, GEMSTUB.to_ruby, mode: "wb")
147
+ end
@@ -0,0 +1,26 @@
1
+ ZSTD Library
2
+ Copyright (c) 2014-2015, Yann Collet
3
+ All rights reserved.
4
+
5
+ BSD License
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice, this
14
+ list of conditions and the following disclaimer in the documentation and/or
15
+ other materials provided with the distribution.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,114 @@
1
+ # ################################################################
2
+ # ZSTD library - Makefile
3
+ # Copyright (C) Yann Collet 2015
4
+ # All rights reserved.
5
+ #
6
+ # BSD license
7
+
8
+ # Redistribution and use in source and binary forms, with or without modification,
9
+ # are permitted provided that the following conditions are met:
10
+ #
11
+ # * Redistributions of source code must retain the above copyright notice, this
12
+ # list of conditions and the following disclaimer.
13
+ #
14
+ # * Redistributions in binary form must reproduce the above copyright notice, this
15
+ # list of conditions and the following disclaimer in the documentation and/or
16
+ # other materials provided with the distribution.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ #
29
+ # You can contact the author at :
30
+ # - ZSTD source repository : https://github.com/Cyan4973/zstd
31
+ # - Public forum : https://groups.google.com/forum/#!forum/lz4c
32
+ # ################################################################
33
+
34
+ # Version numbers
35
+ VERSION?= 0
36
+ LIBVER_MAJOR=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
37
+ LIBVER_MINOR=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
38
+ LIBVER_PATCH=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < zstd.h`
39
+ LIBVER = $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
40
+
41
+ DESTDIR?=
42
+ PREFIX ?= /usr
43
+ CFLAGS ?= -O3
44
+ CFLAGS += -I. -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes
45
+
46
+ LIBDIR ?= $(PREFIX)/lib
47
+ INCLUDEDIR=$(PREFIX)/include
48
+
49
+
50
+ # OS X linker doesn't support -soname, and use different extension
51
+ # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
52
+ ifeq ($(shell uname), Darwin)
53
+ SHARED_EXT = dylib
54
+ SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
55
+ SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
56
+ SONAME_FLAGS = -install_name $(PREFIX)/lib/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
57
+ else
58
+ SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
59
+ SHARED_EXT = so
60
+ SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
61
+ SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
62
+ endif
63
+
64
+ default: libzstd
65
+
66
+ all: libzstd
67
+
68
+ libzstd: zstd.c
69
+ @echo compiling static library
70
+ @$(CC) $(CPPFLAGS) $(CFLAGS) -c $^
71
+ @$(AR) rcs libzstd.a zstd.o
72
+ @echo compiling dynamic library $(LIBVER)
73
+ @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER)
74
+ @echo creating versioned links
75
+ @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT_MAJOR)
76
+ @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT)
77
+
78
+ clean:
79
+ @rm -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
80
+ @echo Cleaning library completed
81
+
82
+
83
+ #------------------------------------------------------------------------
84
+ #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
85
+ ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
86
+
87
+ libzstd.pc: libzstd.pc.in Makefile
88
+ @echo creating pkgconfig
89
+ @sed -e 's|@PREFIX@|$(PREFIX)|' \
90
+ -e 's|@LIBDIR@|$(LIBDIR)|' \
91
+ -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
92
+ -e 's|@VERSION@|$(VERSION)|' \
93
+ $< >$@
94
+
95
+ install: libzstd libzstd.pc
96
+ @install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/
97
+ @install -m 755 libzstd.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_VER)
98
+ @cp -a libzstd.$(SHARED_EXT_MAJOR) $(DESTDIR)$(LIBDIR)
99
+ @cp -a libzstd.$(SHARED_EXT) $(DESTDIR)$(LIBDIR)
100
+ @cp -a libzstd.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
101
+ @install -m 644 libzstd.a $(DESTDIR)$(LIBDIR)/libzstd.a
102
+ @install -m 644 zstd.h $(DESTDIR)$(INCLUDEDIR)/zstd.h
103
+ @echo zstd static and shared library installed
104
+
105
+ uninstall:
106
+ @rm -f $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
107
+ @rm -f $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
108
+ @rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/libzstd.pc
109
+ @[ -x $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_VER) ] && rm -f $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_VER)
110
+ @[ -f $(DESTDIR)$(LIBDIR)/libzstd.a ] && rm -f $(DESTDIR)$(LIBDIR)/libzstd.a
111
+ @[ -f $(DESTDIR)$(INCLUDEDIR)/zstd.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/zstd.h
112
+ @echo zstd libraries successfully uninstalled
113
+
114
+ endif