Skip to content

Commit 134cc5c

Browse files
authored
Merge pull request #337 from rubyworks/docs/modernize-readme-site
docs: modernize README and website. Note 2005 should be 2004. Will fix.
2 parents 6244845 + b2e1089 commit 134cc5c

27 files changed

Lines changed: 1325 additions & 2068 deletions

‎README.md‎

Lines changed: 50 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,253 +1,84 @@
1-
# Ruby Facets
1+
# Ruby Facets <img src="docs/assets/images/cherries.svg" alt="cherries" width="34" height="34">
22

33
[![Gem Version](https://badge.fury.io/rb/facets.svg)](https://rubygems.org/gems/facets)
44
[![CI](https://github.com/rubyworks/facets/actions/workflows/ci.yml/badge.svg)](https://github.com/rubyworks/facets/actions/workflows/ci.yml)
55

6+
**More of Ruby, one method at a time.** Facets is a collection of extensions to Ruby's core classes and standard library, plus a few small, reusable classes and modules. Most methods live in their own files, so you can load one extension, a class's extensions, or the core collection.
67

7-
*"ALL YOUR BASE ARE BELONG TO RUBY"*
8+
Facets began in 2005 and is still maintained. The current release is **3.2.2**, which requires **Ruby 3.1 or newer**. See the [release history](HISTORY.md) for changes and migration notes from earlier versions. The `main` branch also contains changes awaiting the next release.
89

10+
## Install
911

10-
## Introduction
12+
```sh
13+
gem install facets
14+
```
1115

12-
Ruby Facets is the premier collection of general purpose method
13-
extensions and standard additions for the Ruby programming language.
16+
With Bundler, add this to your Gemfile:
1417

15-
Facets houses the largest single collection of methods available for
16-
extending the core capabilities of Ruby's built-in classes and modules.
17-
This collection of extension methods are unique by virtue of their atomicity.
18-
The methods are stored in individual files so that each can be required
19-
independently. This gives developers the potential for much finer control over
20-
which extra methods to bring into their code.
18+
```ruby
19+
gem 'facets', require: false
20+
```
2121

22-
In addition Facets provides a collection of extensions to Ruby standard library
23-
plus a small collection of add-on classes and modules. Together these
24-
libraries constitute an reliable source of reusable components, suitable
25-
to a wide variety of usecases.
22+
`require: false` lets you choose which extensions to load. Omit it if you want Bundler to load the core collection automatically.
2623

24+
## Choose how much to load
2725

28-
## Resources
26+
### One method
2927

30-
* Homepage: https://rubyworks.github.io/facets
31-
* Report Bugs: https://github.com/rubyworks/facets/issues
32-
* Wiki Pages: https://github.com/rubyworks/facets/wiki
33-
* Source Code: https://github.com/rubyworks/facets
28+
```ruby
29+
require 'facets/array/to_ranges'
3430

31+
[1, 2, 3, 6, 7].to_ranges
32+
#=> [1..3, 6..7]
33+
```
3534

36-
## Documentation
37-
38-
Facets has special documentation needs due to its extensive breadth.
39-
The documentation generated when installing via RubyGems, or the YARD
40-
docs provided by rubydoc.info can be somewhat unwieldy because it
41-
combines all of Facets in one large set. When using these resources,
42-
it is important to remain aware of the source location of particular
43-
methods.
44-
45-
For better organized online documentation, generated to separate core
46-
extensions from standard libraries, see the [Learn Facets](https://rubyworks.github.io/facets/learn.html) page on the website for links to available documentation.
47-
48-
49-
## Installation
50-
51-
### Bundler
52-
53-
If you are using Bundler with your project, add the facets gem to the project's
54-
Gemfile. Unless you want all of facets loaded be sure to add the `:require => false`
55-
option.
56-
57-
gem "facets", require: false
58-
59-
### RubyGems
60-
61-
The easiest way to install is via RubyGems.
62-
63-
$ gem install facets
64-
65-
### Requirements
66-
67-
Facets 3.2+ requires Ruby 3.1 or higher.
68-
69-
70-
## Mission
71-
72-
Facets holds to the notion that the more we can *reasonably* integrate into
73-
a common foundation, directed toward general needs, the better that foundation
74-
will be able to serve the community. There are a number of advantages here:
75-
76-
* Better Code-reuse
77-
* Collaborative Improvements
78-
* Greater Name Consistency
79-
* One-stop Shop and Installation
80-
81-
82-
## Usage
83-
84-
### CORE Library
85-
86-
At the heart of Ruby Facets is the CORE extensions library. CORE provides
87-
a sizable collection of generally useful methods, along with a few supporting
88-
classes, that extend the functionality of Ruby's core classes and modules.
89-
90-
With the exception of a few *uncommon* extensions, CORE contains anything that
91-
will load automatically when issuing:
92-
93-
require 'facets'
94-
95-
This loads all the CORE functionality at once. If you plan to use more then a
96-
handful of Facets core methods it is recommended that you require the library in
97-
this way. However, you can also "cherry pick" the CORE library as you prefer.
98-
And for uncommon extensions this must be done. The general require statement for
99-
a core extension library is:
100-
101-
require 'facets/<class|module>/<method>'
102-
103-
For example:
104-
105-
require 'facets/time/stamp'
106-
107-
Most "atoms" contain only one method, but exceptions occur when methods
108-
are closely tied together.
35+
### One class's core extensions
10936

110-
You can load per-class or per-module groups of core methods by requiring the
111-
class or module by name. For example"
37+
```ruby
38+
require 'facets/string'
11239

113-
require 'facets/time'
40+
'Ruby Facets'.snakecase
41+
#=> "ruby_facets"
42+
```
11443

115-
Will require all the core Time method extensions.
44+
### The core collection
11645

117-
Note that some methods that were part of CORE in 1.8 and earlier are now part
118-
of MORE libraries. A good example is 'random.rb'. There were separated because
119-
they had more specialized use cases, where as CORE extensions are intended as
120-
general purpose.
46+
```ruby
47+
require 'facets'
12148

122-
#### Method File Names
49+
[1, 2, 3].average
50+
#=> 2.0
51+
```
12352

124-
Operator method redirect files are stored using English names. For instance
125-
`Proc#*` is `proc/op_mul`.
53+
`require 'facets'` loads the broadly useful **core** extensions. Some specialized core extensions are opt-in; require their method file directly. To load Facets extensions to a Ruby standard library, require that library through Facets:
12654

127-
For reference, here is the chart.
55+
```ruby
56+
require 'facets/ostruct'
57+
```
12858

129-
+@ => op_plus
130-
-@ => op_minus
131-
+ => op_add
132-
- => op_sub
133-
** => op_pow
134-
* => op_mul
135-
/ => op_div
136-
% => op_mod
137-
~ => op_tilde
138-
<=> => op_cmp
139-
<< => op_lshift
140-
>> => op_rshift
141-
< => op_lt
142-
> => op_gt
143-
=== => op_case
144-
== => op_equal
145-
=~ => op_apply
146-
<= => op_lt_eq
147-
>= => op_gt_eq
148-
| => op_or
149-
& => op_and
150-
^ => op_xor
151-
[]= => op_store
152-
[] => op_fetch
59+
This loads `ostruct` and Facets' OpenStruct extensions. On Ruby 3.5+, declare the `ostruct` gem separately because it is no longer a default gem.
15360

154-
Facets simply takes the '*' and translates it into a string acceptable to all
155-
file systems. Also, if a method ends in '=', '?' or '!' it is simply removed.
156-
157-
158-
### MORE Library (aka Standard Library)
159-
160-
On top of the extensive CORE library, Facets provides extensions for Ruby's
161-
standard library, as well as a small collection of additional modules and
162-
classes to supplement it.
163-
164-
Use this library like you would any other 3rd party library.
165-
The only difference between Facet's Standard library and other libraries
166-
is the lack of any enclosing `Facets::` namespace.
167-
168-
When using Facets extended versions of Ruby's standard libraries,
169-
the libraries have to loaded individually. However you do not need
170-
to load Ruby's library first, as the Facets' library will do that
171-
automatically.
172-
173-
For example, normally one load Ruby's OpenStruct class via:
174-
175-
require 'ostruct'
176-
177-
To load 'ostruct.rb' plus Facets extensions for it simply use:
178-
179-
require 'facets/ostruct'
61+
## Documentation
18062

181-
For details pertaining to the functionality of each feature,
182-
please see the API documentation.
63+
- [Getting started and loading guide](https://rubyworks.github.io/facets/learn.html)
64+
- [Generated API documentation on RubyDoc.info](https://www.rubydoc.info/gems/facets) (check the displayed version)
65+
- [Release history](HISTORY.md)
18366

67+
In the published 3.2.2 gem, the split between `lib/core` and `lib/standard` is visible in API source paths. This helps you tell whether a method is loaded by `require 'facets'` or needs an explicit require. The development branch also has a new `lib/rails` area for Rails-compatible helpers; see the **Unreleased** section of the release history for details.
18468

18569
## Contribute
18670

187-
This project thrives on contribution!
188-
189-
If you have any extension methods, classes or modules that you think have
190-
very general applicability and would like to see them included in
191-
this project, don't hesitate to submit. Also, if you have better versions
192-
of any thing already included or simply have a patch, they are more than
193-
welcome. We want Ruby Facets to be of the highest quality.
194-
195-
196-
## Development
197-
198-
Facets uses the [Lemon](https://rubyworks.github.io/lemon) testing framework
199-
to handle unit testing, while [QED](https://rubyworks.github.io/qed) specifications
200-
provide tested documentation. Run the test suite with [Rake](https://ruby.github.io/rake/):
201-
202-
$ rake test
203-
204-
Continuous integration runs on GitHub Actions (see `.github/workflows/ci.yml`).
205-
206-
207-
## Authors
208-
209-
Much of this collection was written and/or inspired by a variety of great Ruby
210-
developers. Fortunately nearly all utilized works were copyrighted under the same
211-
open licenses, the Ruby License or the more liberal BSD and MIT licenses. In the
212-
one or two exceptions the copyright notice has been included with the source code.
213-
We have since received permission from the various authors to normalize the licensing
214-
to a single license. For this purpose we have chosen the BSD 2 Clause License.
215-
This is the license Ruby itself now uses, so it seemed the most appropriate choice.
216-
It is also almost identical to the MIT license. Any code file not specifically labeled
217-
otherwise shall fall under the this license (which is BSD 2-clause).
218-
219-
In all cases, every effort has been made to give credit where credit is due.
220-
You will find these acknowledgments embedded in the source code. You can see
221-
them in "CREDIT:" and/or "@author" lines.
222-
Also see the [Contributors page](https://github.com/rubyworks/facets/wiki/Contributors)
223-
on the Wiki for a list of all contributing Rubyists. If anyone is missing from
224-
the list, please let us know so we can correct. Thanks.
225-
226-
This collection was put together by, and much of it written by [trans](https://github.com/trans).
227-
If need be, he can be reached via email at transfire at gmail.com.
228-
229-
230-
## License
231-
232-
The collection PER COLLECTION is licensed as follows:
233-
234-
Ruby Facets
235-
Copyright (c) 2005 Rubyworks
236-
237-
Distributed under the terms of the BSD-2 License (same as Ruby license).
238-
239-
The BSD 2 Clause License is a simple open source license. The complete text of the
240-
license accompany this document (see the enclosed LICENSE file).
241-
242-
Acknowledgments and Copyrights for particular snippets of borrowed code
243-
are given in their respective source. At this point, all licensing has been normalized
244-
for all included code. Original authors have given permission for inclusion of their
245-
code under such license, with appropriate credit citations.
71+
Issues and pull requests are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md) for the library's method organization, demos, and test conventions. The test suite runs with:
24672

73+
```sh
74+
bundle install
75+
bundle exec rake test
76+
```
24777

248-
## "ALL YOUR BASE ARE BELONG TO RUBY!"
78+
[Source](https://github.com/rubyworks/facets) · [Issues](https://github.com/rubyworks/facets/issues) · [Website](https://rubyworks.github.io/facets/)
24979

250-
Ruby Facets, Copyright (c) 2005 Rubyworks
80+
## License and credits
25181

252-
Do you Ruby? (https://ruby-lang.org)
82+
Facets is distributed under the [BSD 2-Clause License](LICENSE.txt). Thomas Sawyer started the project, and many Rubyists have contributed code, ideas, tests, and documentation. Individual files record additional credits where applicable.
25383

84+
*All your base are belong to Ruby.*

‎docs/README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Facets website
2+
3+
The current GitHub Pages site is served directly from `docs/`. Edit the four page fragments and historical post fragments in `_src/`, and the shared stylesheet in `assets/styles/site.css`, then run:
4+
5+
```sh
6+
ruby docs/build.rb
7+
```
8+
9+
Commit the generated HTML pages, including pages under `posts/`, with the source changes. The build uses only Ruby's standard library. `atom.xml` is a small static release feed and is edited directly.
10+
11+
The `.page`, `.post`, `brite.yml`, and `assets/layouts/` files are retained from the former Brite site for historical reference; they are not inputs to this build. The article copy in `_src/archive/` was taken from the original posts. It describes its original release period and should not be used as current installation or API guidance.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<p>As programmers are wont to do, I started collecting reusable pieces of
2+
Ruby long ago. At first it was just a small function here, a useful
3+
module there. Eventually the collection became sizable and I called it <i>TomsLib</i>.
4+
As time wore on and my library grew, I started to feel it worth a general
5+
release and I had renamed it <i>Raspberry Lib</i>. But sometime shortly thereafter
6+
I hit upon the idea of <i>atomicity</i> of the core extensions. And that's how the
7+
name Facets came about --it's all about the little things. Of course, that name
8+
took a while to decide upon too. The library was almost called "Atomix &amp; Trix"!</p>
9+
10+
<p>Facets has eveolved considerably over the years --and lessons were learned. Probably
11+
the biggest lesson was the 2.0 release, where the idea of atomicity was eroded and
12+
and alternate means of library requiring was attempted. Both were rectified by 2.4.</p>
13+
14+
<p>Much has changed since those first days. But time has been good to Facets.
15+
Today, Facets is a more solid and leaner library than ever before and will
16+
continue in the fashion for version to come.</p>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<p>Facets 2.4.3 is now out in the wild. The release is primarily a maintenance
2+
release &#8212;fixing a handful of small bugs and adding some small feature
3+
improvements, but a few significant changes are also present.</p>
4+
5+
<ul>
6+
<li>Moved Mentalguy's lazy.rb to CORE!</li>
7+
<li>Moved Indexable and Stackable to core.</li>
8+
<li>Added Time#trunc and Time#round to CORE.</li>
9+
<li>Added Ken Bloom's DictionaryMatcher class (maybe renamed in future version)</li>
10+
<li>Added Array#recursively and fixed bug in Hash#recursively.</li>
11+
<li>Added kernel/instance method which provides a fluent interface to private object space.</li>
12+
<li>Renamed Class#to_pathname and #to_methodname to #pathize and #methodize.</li>
13+
<li>Changed File#rewrite to not use the in-place change of the string.</li>
14+
<li>Changed Dictionary#first and #last to take optional arguments.</li>
15+
<li>Deprecated Hash#keys_to_s and Hash#keys_to_sym (use #rekey).</li>
16+
<li>Deprecated Console:: namespace for ANSICode.</li>
17+
<li>Deprecated ruby.rb, which was a sort 1.9 compatibility layer.</li>
18+
<li>The ruby.rb methods were moved to core, wrapped in a 1.9 condition.</li>
19+
<li>Fixed Time#hence changed years when changing months.</li>
20+
<li>Fixed Time#hence to flip year correctly when adding months.</li>
21+
<li>Improved File#rootname, it is now more robust.</li>
22+
<li>Made FileUtils#whereis a module_function again.</li>
23+
<li>Use "lib/lore" to separate extensions to Ruby's standard library.</li>
24+
</ul>
25+
26+
27+
<p>Note that this release does not include a setup.rb script. We are working
28+
on a new version of this script, which we plan to include in the next
29+
release.</p>
30+
31+
<p>Special thanks to:</p>
32+
33+
<ul>
34+
<li>Ken Bloom</li>
35+
<li>Nick Caruso</li>
36+
<li>Evgeniy Dolzhenko</li>
37+
<li>Andy Freeman</li>
38+
<li>Tomasz Muras</li>
39+
<li>Dave Myron</li>
40+
</ul>
41+
42+
43+
<p>And of course, to anyone else I failed to mention that has contributed.</p>
44+
45+
<p>Finally, Facets 2.4+ now encourages using:</p>
46+
47+
<pre><code>require 'facets'
48+
</code></pre>
49+
50+
<p>when testing, even if you are cherry-picking methods. It may seem counter-intuitive,
51+
but it actually proves more advantages to do this for the sake of improved
52+
interoperability. The practice of cherry-picking can become problematic if
53+
other dependent libraries have cherry-picked different methods, and the
54+
the different choices go unaccounted and untested.</p>
55+
56+
<p>Facets is almost fully interoperable with ActiveSupport and Ruby 1.9. We
57+
will continue to improve this interoperability in upcoming releases.</p>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<p>The old Ruby Facets website was a static 100% XML/XSLT site. When I originally created
2+
the site, I though XML/XSLT suredly was the pinnicale and proper way to build a
3+
modern site --for no other reason that XSL is a pain in the ass! Well, we all know
4+
the ultimate outcome of this story. XML/XSLT is turning out to be an exmplar of
5+
over engineering by academics.</p>
6+
7+
<p>The new Facets website runs of Jekyll, a static site generator supoprted by GitHub.
8+
(another good site tool is Shunman)</p>

0 commit comments

Comments
 (0)