bit_set 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a550438abe4ced2c45d1c9f4ce131af1ff1774c5
4
+ data.tar.gz: a8fe4334ef7a7e012df35d46b9f9ebde5bfb22cc
5
+ SHA512:
6
+ metadata.gz: 9ecdac54a146f3c81d3a52834968a321b86d240c0808fd7bf2408d43fd8564dbea13d79d21fd1c3bf5f9acad031b42c79f89d873d9e3728e7d73d590257a654a
7
+ data.tar.gz: 75d501dfdaec1271e5005c89564f7b7144d2be7aabb21cb0e5cbea73ad6b9b7c0159a7c6195e1c165dec6e7adbd1af4355c09f832f2a98d973977a3d8eeac3cf
@@ -0,0 +1 @@
1
+ service_name: travis-ci
@@ -0,0 +1,12 @@
1
+ # Project metadata
2
+ nbproject
3
+ .idea
4
+
5
+ Gemfile.lock
6
+
7
+ doc/api
8
+ coverage
9
+ pkg
10
+ .yardoc
11
+ .rbx
12
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,54 @@
1
+ language: ruby
2
+ os:
3
+ - linux
4
+ - osx
5
+ rvm:
6
+ - 1.9
7
+ - 2.0
8
+ - 2.1
9
+ - 2.2
10
+ - 2.3.0
11
+ - rbx-2
12
+ - rbx-3.26
13
+ matrix:
14
+ include:
15
+ - rvm: &jruby_1_7 jruby-19mode
16
+ jdk: openjdk6
17
+ os: linux
18
+ - rvm: *jruby_1_7
19
+ jdk: openjdk7
20
+ os: linux
21
+ - rvm: *jruby_1_7
22
+ jdk: oraclejdk7
23
+ os: linux
24
+ - rvm: *jruby_1_7
25
+ jdk: oraclejdk8
26
+ os: linux
27
+ - rvm: &jruby_9_0 jruby-9.0.5.0
28
+ jdk: openjdk6
29
+ os: linux
30
+ - rvm: *jruby_9_0
31
+ jdk: openjdk7
32
+ os: linux
33
+ - rvm: *jruby_9_0
34
+ jdk: oraclejdk7
35
+ os: linux
36
+ - rvm: *jruby_9_0
37
+ jdk: oraclejdk8
38
+ os: linux
39
+ - rvm: *jruby_1_7
40
+ os: osx
41
+ - rvm: *jruby_9_0
42
+ os: osx
43
+ allow_failures:
44
+ - rvm: 2.2 # Not available on Travis CI yet
45
+ os: osx
46
+ - rvm: 2.3.0 # Not available on Travis CI yet
47
+ os: osx
48
+ - rvm: *jruby_1_7 # Not available on Travis CI yet
49
+ os: osx
50
+ - rvm: *jruby_9_0 # JRuby 9.x does not support OpenJDK 6
51
+ jdk: openjdk6
52
+
53
+ before_install:
54
+ - gem install bundler
@@ -0,0 +1,9 @@
1
+ --output-dir=doc/api
2
+ --embed-mixins
3
+ --protected
4
+ --no-private
5
+ --markup-provider=kramdown
6
+ --markup=markdown
7
+ -
8
+ HISTORY.md
9
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ =begin
3
+ Copyright GodObject Team <dev@godobject.net>, 2012-2016
4
+
5
+ This file is part of BitSet.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted, provided that the above
9
+ copyright notice and this permission notice appear in all copies.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ =end
19
+
20
+ source 'https://rubygems.org'
21
+
22
+ # Gem dependencies are specified in the .gemspec file
23
+ gemspec
24
+
25
+ gem 'coveralls', require: false
@@ -0,0 +1,6 @@
1
+ 0.1.0 / 2016-05-05
2
+ ==================
3
+
4
+ * 1 major enhancement
5
+
6
+ * Birthday!
@@ -0,0 +1,15 @@
1
+ Copyright GodObject Team <dev@godobject.net>, 2012-2016
2
+
3
+ BitSet is licensed under the following ISC-style license:
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
11
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,435 @@
1
+ BitSet
2
+ ======
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/bit_set.png)](https://badge.fury.io/rb/bit_set)
5
+ [![Dependency Status](https://gemnasium.com/godobject/bit_set.png)](https://gemnasium.com/godobject/bit_set)
6
+ [![Code Climate](https://codeclimate.com/github/godobject/bit_set.png)](https://codeclimate.com/github/godobject/bit_set)
7
+ [![Build Status](https://secure.travis-ci.org/godobject/bit_set.png)](https://secure.travis-ci.org/godobject/bit_set)
8
+ [![Coverage Status](https://coveralls.io/repos/github/godobject/bit_set/badge.svg?branch=master)](https://coveralls.io/github/godobject/bit_set?branch=master)
9
+
10
+ * [Documentation][docs]
11
+ * [Project][project]
12
+
13
+ [docs]: http://rdoc.info/github/godobject/bit_set/
14
+ [project]: https://github.com/godobject/bit_set/
15
+
16
+ Description
17
+ -----------
18
+
19
+ BitSet is a Ruby library implementing a bit set structure with labeled digits
20
+ and binary logic operators. Additionally it allows to create precached
21
+ configurations of BitSets which also allow the String representation to be
22
+ customized easily.
23
+
24
+ Features / Problems
25
+ -------------------
26
+
27
+ This project tries to conform to:
28
+
29
+ * [Semantic Versioning (2.0.0)][semver]
30
+ * [Ruby Packaging Standard (0.5-draft)][rps]
31
+ * [Ruby Style Guide][style]
32
+ * [Gem Packaging: Best Practices][gem]
33
+
34
+ [semver]: http://semver.org/spec/v2.0.0.html
35
+ [rps]: http://chneukirchen.github.com/rps/
36
+ [style]: https://github.com/bbatsov/ruby-style-guide
37
+ [gem]: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
38
+
39
+ Additional facts:
40
+
41
+ * Written purely in Ruby.
42
+ * Documented with YARD.
43
+ * Automatically testable through RSpec.
44
+ * Intended to be used with Ruby 1.9.3 or higher.
45
+ * Cryptographically signed git tags.
46
+ * This library was developed as part of the
47
+ [PosixMode](https://rubygems.org/gems/posix_mode) project.
48
+
49
+ Shortcomings and problems:
50
+
51
+ * BitSets with numbered but unnamed digits can't currently be handled.
52
+ * The library is optimized for usability and not for computational efficiency.
53
+
54
+ If you have solved any of these feel free to submit your changes back.
55
+
56
+ Requirements
57
+ ------------
58
+
59
+ * Ruby 1.9.3 or higher
60
+
61
+ Installation
62
+ ------------
63
+
64
+ On *nix systems you may need to prefix the command with `sudo` to get root
65
+ privileges.
66
+
67
+ ### Gem
68
+
69
+ gem install bit_set
70
+
71
+ ### Automated testing
72
+
73
+ Go into the root directory of the installed gem and run the following command
74
+ to fetch all development dependencies:
75
+
76
+ bundle
77
+
78
+ Afterwards start the test runner:
79
+
80
+ rake spec
81
+
82
+ If something goes wrong you should be notified through failing examples.
83
+
84
+ Usage
85
+ -----
86
+
87
+ This documentation defines the public interface of the software. The version
88
+ number of the software tracks changes to this public interface as described in
89
+ [Semantic Versioning][semver]. Do not use elements that are marked as private.
90
+ These elements are not guaranteed to exist in otherwise compatible future
91
+ versions. Should you really need some parts that are currently marked as
92
+ private, please contact us. We might be able to expose them as public
93
+ interface for your convenience.
94
+
95
+ This is still experimental software, even the public interface may change
96
+ substantially in future releases.
97
+
98
+ [semver]: http://semver.org/spec/v2.0.0.html
99
+
100
+ ### Ruby interface
101
+
102
+ #### Loading
103
+
104
+ In most cases you want to load the code by using the following command:
105
+
106
+ ~~~~~ ruby
107
+ require 'bit_set'
108
+ ~~~~~
109
+
110
+ In a bundler Gemfile you should use the following:
111
+
112
+ ~~~~~ ruby
113
+ gem 'bit_set'
114
+ ~~~~~
115
+
116
+ #### Namespace
117
+
118
+ This project is contained within a namespace to avoid name collisions with
119
+ other code. If you do not want to specifiy the namespace explicitly you can
120
+ include it into the current scope by executing the following statement:
121
+
122
+ ~~~~~ ruby
123
+ include GodObject::BitSet
124
+ ~~~~~
125
+
126
+ The following documentation assumes that you did include the namespace.
127
+
128
+ #### Creating a Configuration
129
+
130
+ A configuration defines the amount of bits in the set and defines a unique name
131
+ for each. The simplest way to create a configuration is to providing a list of
132
+ symbols. In the concrete bit sets, each digit will then be represented by a "1"
133
+ if it is enabled and a "0" if it is disabled.
134
+
135
+ ~~~~~
136
+ Configuration.new([:red, :green, :blue])
137
+ ~~~~~
138
+
139
+ Instead you can also provide each digit with a specificy "enabled"
140
+ representation. The given String will be used to represent the specific digit
141
+ when it is enabled. In case it is disabled a "-" will be displayed.
142
+
143
+ ~~~~~
144
+ pixel_config = Configuration.new(
145
+ red: 'r',
146
+ green: 'g',
147
+ blue: 'b'
148
+ )
149
+ ~~~~~
150
+
151
+ One further option is to provide each digit with both specific "enabled" and
152
+ "disabled" representations.
153
+
154
+ ~~~~~
155
+ Configuration.new(
156
+ red: ['r', 'o'],
157
+ green: ['g', '!'],
158
+ blue: ['b', 'x']
159
+ )
160
+ ~~~~~
161
+
162
+ #### Creating a BitSet
163
+
164
+ To create an actual BitSet based on a given configuration you can call the
165
+ following:
166
+
167
+ ~~~~~
168
+ bitset = pixel_config.new
169
+ # => #<GodObject::BitSet: "---">
170
+ ~~~~~
171
+
172
+ If you want to provide an initial state for the BitSet you can either list all
173
+ enabled digits like this:
174
+
175
+ ~~~~~
176
+ bitset = pixel_config.new(:red, :blue)
177
+ # => #<GodObject::BitSet: "r-b">
178
+ ~~~~~
179
+
180
+ Or you can set the initial state by giving an integer representation like this:
181
+
182
+ ~~~~~
183
+ bitset = pixel_config.new(6)
184
+ # => #<GodObject::BitSet: "rg-">
185
+ ~~~~~
186
+
187
+ Additionally it is possible to create a BitSet by providing a
188
+ Configuration object directly:
189
+
190
+ ~~~~~
191
+ bitset = BitSet.new(:blue, pixel_configuration)
192
+ # => #<GodObject::BitSet: "--b">
193
+ ~~~~~
194
+
195
+ Or by creating a Configuration definition on-the-fly:
196
+
197
+ ~~~~~
198
+ bitset = BitSet.new(:green, red: 'r', green: 'g', blue: 'b')
199
+ # => #<GodObject::BitSet: "-g-">
200
+ ~~~~~
201
+
202
+ #### Examing a BitSet
203
+
204
+ Each BitSet can be asked for the state of its individual digits:
205
+
206
+ ~~~~~
207
+ bitset.red?
208
+ # => false
209
+
210
+ bitset.green?
211
+ # => true
212
+
213
+ bitset.blue?
214
+ # => false
215
+ ~~~~~
216
+
217
+ Or in a slightly different way:
218
+
219
+ ~~~~~
220
+ bitset[:red]
221
+ # => false
222
+
223
+ bitset[:green]
224
+ # => true
225
+
226
+ bitset[:blue]
227
+ # => false
228
+ ~~~~~
229
+
230
+ You can also get a complete state-containing hash by the following:
231
+
232
+ ~~~~~
233
+ bitset.state
234
+ # => {:red=>false, :green=>true, :blue=>false}
235
+ ~~~~~
236
+
237
+ Or a Set of all enabled/disabled digits:
238
+
239
+ ~~~~~
240
+ bitset.enabled_digits
241
+ # => #<Set: {:green}>
242
+
243
+ bitset.disabled_digits
244
+ # => #<Set: {:red, :blue}>
245
+ ~~~~~
246
+
247
+ A String representation can be generated in the usual way:
248
+
249
+ ~~~~~
250
+ bitset.to_s
251
+ # => "-g-"
252
+ ~~~~~
253
+
254
+ By default this will generate the long version, with both the enabled and the
255
+ disabled digits represented. A short variant is available as long as each digit
256
+ in the configuration has a unique enabled representation.
257
+
258
+ ~~~~~
259
+ bitset.to_s(:short)
260
+ # => "g"
261
+ ~~~~~
262
+
263
+ An Integer representation of the BitSet is as well available in a
264
+ straight-forward way:
265
+
266
+ ~~~~~
267
+ bitset.to_s
268
+ # => #<GodObject::BitSet::Configuration: … >
269
+ ~~~~~
270
+
271
+ To gain access to the Configuration of the BitSet just use the following:
272
+
273
+ ~~~~~
274
+ bitset.configuration
275
+ # => 2
276
+ ~~~~~
277
+
278
+ #### Comparison
279
+
280
+ BitSets are considered equal when their state and configuration are equal.
281
+ Configurations are considered equal when they have the same list of
282
+ digits, without considering their String representations.
283
+
284
+ Using the #eql? method for comparison also checks for class family
285
+ compatibility.
286
+
287
+ #### Operations
288
+
289
+ A set of operations can be used upon BitSets. Notice that BitSets are immutable
290
+ so that the results of the operations are always new BitSet objects.
291
+
292
+ Each digit's state in a BitSet can be inverted like the following:
293
+
294
+ ~~~~~
295
+ bitset.invert
296
+ # => #<GodObject::BitSet: "r-b">
297
+ ~~~~~
298
+
299
+ You can combine the enabled digits of two BitSets by adding them together:
300
+
301
+ ~~~~~
302
+ pixel_config.new(:red) + pixel_config.new(:red, :blue)
303
+ # => #<GodObject::BitSet: "r-b">
304
+ ~~~~~
305
+
306
+ To disable all digits in a BitSet that are enabled in another you can subtract
307
+ them from one another:
308
+
309
+ ~~~~~
310
+ pixel_config.new(:red, :blue) - pixel_config.new(:green, :blue)
311
+ # => #<GodObject::BitSet: "r--">
312
+ ~~~~~
313
+
314
+ To produce a BitSet which has only those digits enabled which are enabled on
315
+ both given BitSets you can calculate the intersection:
316
+
317
+ ~~~~~
318
+ pixel_config.new(:red, :blue) ^ pixel_config.new(:green, :blue)
319
+ # => #<GodObject::BitSet: "--b">
320
+ ~~~~~
321
+
322
+ An to only have those digits enabled in the result which are enabled on only
323
+ one of the given BitSets, calculate the symmetric difference:
324
+
325
+ ~~~~~
326
+ pixel_config.new(:red, :blue).symmetric_difference(pixel_config.new(:green, :blue))
327
+ # => #<GodObject::BitSet: "rg-">
328
+ ~~~~~
329
+
330
+ Development
331
+ -----------
332
+
333
+ ### Bug reports and feature requests
334
+
335
+ Please use the [issue tracker][issues] on github.com to let us know about errors
336
+ or ideas for improvement of this software.
337
+
338
+ [issues]: https://github.com/godobject/bit_set/issues/
339
+
340
+ ### Source code
341
+
342
+ #### Distribution
343
+
344
+ This software is developed in the source code management system Git. There are
345
+ several synchronized mirror repositories available:
346
+
347
+ * [GitHub][github] (located in California, USA)
348
+
349
+ URI: https://github.com/godobject/bit_set.git
350
+
351
+ * [GitLab][gitlab] (located in Illinois, USA)
352
+
353
+ URI: https://gitlab.com/godobject/bit_set.git
354
+
355
+ * [BitBucket][bitbucket] (located in California, USA)
356
+
357
+ URI: https://bitbucket.org/godobject/bit_set.git
358
+
359
+ * [Pikacode][pikacode] (located in France)
360
+
361
+ URI: https://pikacode.com/godobject/bit_set.git
362
+
363
+ [github]: https://github.com/godobject/bit_set/
364
+ [gitlab]: https://gitlab.com/godobject/bit_set/
365
+ [bitbucket]: https://bitbucket.org/godobject/bit_set/
366
+ [pikacode]: https://pikacode.com/godobject/bit_set/
367
+
368
+ You can get the latest source code with the following command, while
369
+ exchanging the placeholder for one of the mirror URIs:
370
+
371
+ git clone MIRROR_URI
372
+
373
+ #### Tags and cryptographic verification
374
+
375
+ The final commit before each released gem version will be marked by a tag
376
+ named like the version with a prefixed lower-case "v". Every tag will be signed
377
+ by Alexander E. Fischer's [OpenPGP public key][openpgp] which enables you to
378
+ verify your copy of the code cryptographically.
379
+
380
+ [openpgp]: https://aef.name/crypto/aef-openpgp.asc
381
+
382
+ Add the key to your GnuPG keyring by the following command:
383
+
384
+ gpg --import aef-openpgp.asc
385
+
386
+ This command will tell you if your code is of integrity and authentic:
387
+
388
+ git tag --verify [TAG NAME]
389
+
390
+ #### Building gems
391
+
392
+ To package your state of the source code into a gem package use the following
393
+ command:
394
+
395
+ rake build
396
+
397
+ The gem will be generated according to the .gemspec file in the project root
398
+ directory and will be placed into the pkg/ directory.
399
+
400
+ ### Contribution
401
+
402
+ Help on making this software better is always very appreciated. If you want
403
+ your changes to be included in the official release, please clone the project
404
+ on github.com, create a named branch to commit, push your changes into it and
405
+ send a pull request afterwards.
406
+
407
+ Please make sure to write tests for your changes so that no one else will break
408
+ them when changing other things. Also notice that an inclusion of your changes
409
+ cannot be guaranteed before reviewing them.
410
+
411
+ The following people were involved in development:
412
+
413
+ * Oliver Feldt <of@godobject.net>
414
+ * Alexander E. Fischer <aef@godobject.net>
415
+ * Axel Sorge <as@godobject.net>
416
+ * Andreas Wurm <aw@godobject.net>
417
+
418
+ License
419
+ -------
420
+
421
+ Copyright GodObject Team <dev@godobject.net>, 2012-2016
422
+
423
+ This file is part of BitSet.
424
+
425
+ Permission to use, copy, modify, and/or distribute this software for any
426
+ purpose with or without fee is hereby granted, provided that the above
427
+ copyright notice and this permission notice appear in all copies.
428
+
429
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
430
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
431
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
432
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
433
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
434
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
435
+ PERFORMANCE OF THIS SOFTWARE.