file_permissions 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: a1ac702feef517c53d899bb829443c604b5718aa
4
+ data.tar.gz: ee06ed78adee893285e19465ff87c3c48f0a27ab
5
+ SHA512:
6
+ metadata.gz: 985abb6342d7ae2a2fa8cf69364ecf75ed212ceefd6c04d2a6e6c2dfcf8f23ceb79e74273d4b64ef7ccdf40e959a6d349c80bb0ab5ba0ef0d5428475f59be62d
7
+ data.tar.gz: 0a7be10fe2ed40c945146450004e1d0cd6b250cdd382a91376ff5db0718250aa462b7083faef3b93a584d88685951225d328ca5e5cb5ead89c7653606863995c
@@ -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,49 @@
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
+ - os: osx
45
+ - rvm: *jruby_9_0 # JRuby 9.x does not support OpenJDK 6
46
+ jdk: openjdk6
47
+
48
+ before_install:
49
+ - 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 FilePermissions.
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-15
2
+ ==================
3
+
4
+ * 1 major enhancement
5
+
6
+ * Birthday!
@@ -0,0 +1,15 @@
1
+ Copyright GodObject Team <dev@godobject.net>, 2012-2016
2
+
3
+ FilePermissions 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,391 @@
1
+ FilePermissions
2
+ ===============
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/file_permissions.png)](https://badge.fury.io/rb/file_permissions)
5
+ [![Dependency Status](https://gemnasium.com/godobject/file_permissions.png)](https://gemnasium.com/godobject/file_permissions)
6
+ [![Code Climate](https://codeclimate.com/github/godobject/file_permissions.png)](https://codeclimate.com/github/godobject/file_permissions)
7
+ [![Build Status](https://secure.travis-ci.org/godobject/file_permissions.png)](https://secure.travis-ci.org/godobject/file_permissions)
8
+ [![Coverage Status](https://coveralls.io/repos/github/godobject/file_permissions/badge.svg?branch=master)](https://coveralls.io/github/godobject/file_permissions?branch=master)
9
+
10
+ * [Documentation][docs]
11
+ * [Project][project]
12
+
13
+ [docs]: http://rdoc.info/github/godobject/file_permissions/
14
+ [project]: https://github.com/godobject/file_permissions/
15
+
16
+ Description
17
+ -----------
18
+
19
+ FilePermissions is a Ruby library providing an object representation of the
20
+ file permission bits in POSIX systems.
21
+
22
+ It can handle the generic read, write and execute permissions, as well as
23
+ the setuid, setgid and sticky flags. Permission sets can be read from file
24
+ system objects, parsed from typical string representations or simply
25
+ defined by their numeric representation. They can then be manipulated
26
+ through binary logic operators and written back to file system objects.
27
+
28
+ Features / Problems
29
+ -------------------
30
+
31
+ This project tries to conform to:
32
+
33
+ * [Semantic Versioning (2.0.0)][semver]
34
+ * [Ruby Packaging Standard (0.5-draft)][rps]
35
+ * [Ruby Style Guide][style]
36
+ * [Gem Packaging: Best Practices][gem]
37
+
38
+ [semver]: http://semver.org/spec/v2.0.0.html
39
+ [rps]: http://chneukirchen.github.com/rps/
40
+ [style]: https://github.com/bbatsov/ruby-style-guide
41
+ [gem]: http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices
42
+
43
+ Additional facts:
44
+
45
+ * Written purely in Ruby.
46
+ * Documented with YARD.
47
+ * Automatically testable through RSpec.
48
+ * Intended to be used with Ruby 1.9.3 or higher.
49
+ * Cryptographically signed git tags.
50
+ * This library was developed as part of the
51
+ [UsersAndGroups](https://rubygems.org/gems/users_and_groups) project.
52
+
53
+ Requirements
54
+ ------------
55
+
56
+ * Ruby 1.9.3 or higher
57
+ * [bit_set](https://rubygems.org/gems/bit_set)
58
+
59
+ Installation
60
+ ------------
61
+
62
+ On *nix systems you may need to prefix the command with `sudo` to get root
63
+ privileges.
64
+
65
+ ### Gem
66
+
67
+ gem install file_permissions
68
+
69
+ ### Automated testing
70
+
71
+ Go into the root directory of the installed gem and run the following command
72
+ to fetch all development dependencies:
73
+
74
+ bundle
75
+
76
+ Afterwards start the test runner:
77
+
78
+ rake spec
79
+
80
+ If something goes wrong you should be notified through failing examples.
81
+
82
+ Usage
83
+ -----
84
+
85
+ This documentation defines the public interface of the software. The version
86
+ number of the software tracks changes to this public interface as described in
87
+ [Semantic Versioning][semver]. Do not use elements that are marked as private.
88
+ These elements are not guaranteed to exist in otherwise compatible future
89
+ versions. Should you really need some parts that are currently marked as
90
+ private, please contact us. We might be able to expose them as public
91
+ interface for your convenience.
92
+
93
+ This is still experimental software, even the public interface may change
94
+ substantially in future releases.
95
+
96
+ [semver]: http://semver.org/spec/v2.0.0.html
97
+
98
+ ### Ruby interface
99
+
100
+ #### Loading
101
+
102
+ In most cases you want to load the code by using the following command:
103
+
104
+ ~~~~~ ruby
105
+ require 'file_permissions'
106
+ ~~~~~
107
+
108
+ In a bundler Gemfile you should use the following:
109
+
110
+ ~~~~~ ruby
111
+ gem 'file_permissions'
112
+ ~~~~~
113
+
114
+ #### Namespace
115
+
116
+ This project is contained within a namespace to avoid name collisions with
117
+ other code. If you do not want to specifiy the namespace explicitly you can
118
+ include it into the current scope by executing the following statement:
119
+
120
+ ~~~~~ ruby
121
+ include GodObject::FilePermissions
122
+ ~~~~~
123
+
124
+ The following documentation assumes that you did include the namespace.
125
+
126
+ #### The ComplexMode
127
+
128
+ The complete regular permissions of a POSIX file system object are represented
129
+ by the ComplexMode. It aggregates three Mode objects which define the read,
130
+ write and execute permissions for the owner, the owning group and others
131
+ respectively. Additionally it holds an instance of the SpecialMode to define
132
+ the state of the setuid, setgid and sticky flags of the file system object.
133
+
134
+ A ComplexMode can be created from a typical octal mode representation:
135
+
136
+ ~~~~~ ruby
137
+ ComplexMode.new(0644)
138
+ # => #<GodObject::FilePermissions::ComplexMode: "rw-r--r--">
139
+
140
+ ComplexMode.new(03644)
141
+ # => #<GodObject::FilePermissions::ComplexMode: "rw-r-Sr-T">
142
+ ~~~~~
143
+
144
+ Or simply by a list of permission digits:
145
+
146
+ ~~~~~ ruby
147
+ ComplexMode.new(:user_write, :group_execute, :other_read, :sticky)
148
+ # => #<GodObject::FilePermissions::ComplexMode: "-w---xr-T">
149
+ ~~~~~
150
+
151
+ It can also be read from the file system like this:
152
+
153
+ ~~~~~ ruby
154
+ mode = ComplexMode.from_file('/path/to/a/file')
155
+
156
+ # => #<GodObject::FilePermissions::ComplexMode: "rwsr-x---">
157
+ ~~~~~
158
+
159
+ Note that it also accepts a Pathname object instead of a path String.
160
+
161
+ The ComplexMode object can now be used to access the permissions:
162
+
163
+ ~~~~~ ruby
164
+ mode.user.execute?
165
+ # => true
166
+
167
+ mode.group.read?
168
+ # => true
169
+
170
+ mode.other.write?
171
+ # => false
172
+
173
+ mode.setuid?
174
+ # => true
175
+ ~~~~~
176
+
177
+ Also you can modify the ComplexMode by replacing its aggregated Mode objects:
178
+
179
+ ~~~~~ ruby
180
+ mode.other = Mode.new(:read, :execute)
181
+
182
+ mode
183
+ # => #<GodObject::FilePermissions::ComplexMode: "rwsr-xr-x">
184
+ ~~~~~
185
+
186
+ ~~~~~ ruby
187
+ mode.special = SpecialMode.new(:setuid, :setgid)
188
+
189
+ mode
190
+ # => #<GodObject::FilePermissions::ComplexMode: "rwsr-sr-x">
191
+ ~~~~~
192
+
193
+ The ComplexMode can be again written to a file system object by issuing the
194
+ following:
195
+
196
+ ~~~~~ ruby
197
+ mode.assign_to_file('/path/to/some/other/file')
198
+ ~~~~~
199
+
200
+ Note that it also accepts a Pathname object instead of a path String.
201
+
202
+ #### Mode and SpecialMode
203
+
204
+ Both Mode and SpecialMode are intended to be parts of the ComplexMode.
205
+ Instances are immutable and can therefore only be defined during creation.
206
+
207
+ New instances can either be created by a list of permission digits:
208
+
209
+ ~~~~~ ruby
210
+ Mode.new(:read, :write, :execute)
211
+ # => #<GodObject::FilePermissions::Mode: "rwx">
212
+ ~~~~~
213
+
214
+ ~~~~~ ruby
215
+ SpecialMode.new(:setuid, :setgid, :sticky)
216
+ # => #<GodObject::FilePermissions::SpecialMode: "sst">
217
+ ~~~~~
218
+
219
+ Or be defined by their octal digit representation:
220
+
221
+ ~~~~~ ruby
222
+ Mode.new(5)
223
+ # => #<GodObject::FilePermissions::Mode: "r-x">
224
+ ~~~~~
225
+
226
+ ~~~~~ ruby
227
+ SpecialMode.new(3)
228
+ # => #<GodObject::FilePermissions::SpecialMode: "-st">
229
+ ~~~~~
230
+
231
+ Another way to create new instances is to parse a String representation:
232
+
233
+ ~~~~~ ruby
234
+ regular_mode = Mode.parse('xr')
235
+ # => #<GodObject::FilePermissions::Mode: "r-x">
236
+ ~~~~~
237
+
238
+ ~~~~~ ruby
239
+ special_mode = SpecialMode.new('-st')
240
+ # => #<GodObject::FilePermissions::SpecialMode: "-st">
241
+ ~~~~~
242
+
243
+ Note that instead of the Mode, when parsing a SpecialMode, the String
244
+ representation has to be in the correct order and including dashes for disabled
245
+ digits because the SpecialMode representation doesn't have unique character
246
+ representations for each permission digit.
247
+
248
+ Both Mode and SpecialMode can then be asked for the state of their digits:
249
+
250
+ ~~~~~ ruby
251
+ regular_mode.read?
252
+ # => true
253
+ regular_mode.write?
254
+ # => false
255
+ regular_mode.execute?
256
+ # => true
257
+
258
+ regular_mode.state
259
+ # => {:read => true, :write => false, :execute => true}
260
+
261
+ regular_mode.enabled_digits
262
+ # => #<Set: {:read, :execute}>
263
+
264
+ regular_mode.disabled_digits
265
+ # => #<Set: {:write}>
266
+ ~~~~~
267
+
268
+ ~~~~~ ruby
269
+ special_mode.setuid?
270
+ # => false
271
+ special_mode.setgid?
272
+ # => true
273
+ special_mode.sticky?
274
+ # => true
275
+
276
+ special_mode.state
277
+ # => {:setuid => false, :setgid => true, :sticky => true}
278
+
279
+ special_mode.enabled_digits
280
+ # => #<Set: {:setgid, :sticky}>
281
+
282
+ special_mode.disabled_digits
283
+ # => #<Set: {:setuid}>
284
+ ~~~~~
285
+
286
+ Development
287
+ -----------
288
+
289
+ ### Bug reports and feature requests
290
+
291
+ Please use the [issue tracker][issues] on github.com to let us know about errors
292
+ or ideas for improvement of this software.
293
+
294
+ [issues]: https://github.com/godobject/file_permissions/issues/
295
+
296
+ ### Source code
297
+
298
+ #### Distribution
299
+
300
+ This software is developed in the source code management system Git. There are
301
+ several synchronized mirror repositories available:
302
+
303
+ * [GitHub][github] (located in California, USA)
304
+
305
+ URI: https://github.com/godobject/file_permissions.git
306
+
307
+ * [GitLab][gitlab] (located in Illinois, USA)
308
+
309
+ URI: https://gitlab.com/godobject/file_permissions.git
310
+
311
+ * [BitBucket][bitbucket] (located in California, USA)
312
+
313
+ URI: https://bitbucket.org/godobject/file_permissions.git
314
+
315
+ * [Pikacode][pikacode] (located in France)
316
+
317
+ URI: https://v2.pikacode.com/godobject/file_permissions.git
318
+
319
+ [github]: https://github.com/godobject/file_permissions/
320
+ [gitlab]: https://gitlab.com/godobject/file_permissions/
321
+ [bitbucket]: https://bitbucket.org/godobject/file_permissions/
322
+ [pikacode]: https://v2.pikacode.com/godobject/file_permissions/
323
+
324
+ You can get the latest source code with the following command, while
325
+ exchanging the placeholder for one of the mirror URIs:
326
+
327
+ git clone MIRROR_URI
328
+
329
+ #### Tags and cryptographic verification
330
+
331
+ The final commit before each released gem version will be marked by a tag
332
+ named like the version with a prefixed lower-case "v". Every tag will be signed
333
+ by Alexander E. Fischer's [OpenPGP public key][openpgp] which enables you to
334
+ verify your copy of the code cryptographically.
335
+
336
+ [openpgp]: https://aef.name/crypto/aef-openpgp.asc
337
+
338
+ Add the key to your GnuPG keyring by the following command:
339
+
340
+ gpg --import aef-openpgp.asc
341
+
342
+ This command will tell you if your code is of integrity and authentic:
343
+
344
+ git tag --verify [TAG NAME]
345
+
346
+ #### Building gems
347
+
348
+ To package your state of the source code into a gem package use the following
349
+ command:
350
+
351
+ rake build
352
+
353
+ The gem will be generated according to the .gemspec file in the project root
354
+ directory and will be placed into the pkg/ directory.
355
+
356
+ ### Contribution
357
+
358
+ Help on making this software better is always very appreciated. If you want
359
+ your changes to be included in the official release, please clone the project
360
+ on github.com, create a named branch to commit, push your changes into it and
361
+ send a pull request afterwards.
362
+
363
+ Please make sure to write tests for your changes so that no one else will break
364
+ them when changing other things. Also notice that an inclusion of your changes
365
+ cannot be guaranteed before reviewing them.
366
+
367
+ The following people were involved in development:
368
+
369
+ * Oliver Feldt <of@godobject.net>
370
+ * Alexander E. Fischer <aef@godobject.net>
371
+ * Axel Sorge <as@godobject.net>
372
+ * Andreas Wurm <aw@godobject.net>
373
+
374
+ License
375
+ -------
376
+
377
+ Copyright GodObject Team <dev@godobject.net>, 2012-2016
378
+
379
+ This file is part of FilePermissions.
380
+
381
+ Permission to use, copy, modify, and/or distribute this software for any
382
+ purpose with or without fee is hereby granted, provided that the above
383
+ copyright notice and this permission notice appear in all copies.
384
+
385
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
386
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
387
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
388
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
389
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
390
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
391
+ PERFORMANCE OF THIS SOFTWARE.