[bug#34514,01/34] gnu: Add ruby-hamster.

Message ID 20190217192314.5666-1-mail@cbaines.net
State Accepted
Commit 353b7eb8c5e35beb94b4ad7208a0d72704e7c9fb
Headers show
Series Add more Ruby gems, some Rails related | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied
cbaines/applying patch success Successfully applied

Commit Message

Christopher Baines Feb. 17, 2019, 7:22 p.m. UTC
* gnu/packages/ruby.scm (ruby-hamster): New variable.
---
 gnu/packages/ruby.scm | 46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

Comments

Ricardo Wurmus Feb. 18, 2019, 10:40 p.m. UTC | #1
Christopher Baines <mail@cbaines.net> writes:

> * gnu/packages/ruby.scm (ruby-hamster): New variable.
[…]
> +       (add-after 'unpack 'remove-unnecessary-dependencies
> +         (lambda _
> +           ;; pry is a debugging tool, and is unnecessary when running the
> +           ;; tests
> +           (substitute* "spec/lib/hamster/vector/insert_spec.rb"
> +             (("require 'pry'") ""))
> +           (substitute* "spec/spec_helper.rb"
> +             (("require \"pry\"") "")

We have a ruby-pry package.  Wouldn’t it be nicer to add it instead of
patching the sources?

> +             ;; CodeClimate is an online service, and is unnecessary for
> +             ;; running the tests
> +             (("require \"codeclimate-test-reporter\"") "")
> +             (("CodeClimate.*\n") ""))

Okay.
Christopher Baines Feb. 19, 2019, 10:55 p.m. UTC | #2
Ricardo Wurmus <rekado@elephly.net> writes:

> Christopher Baines <mail@cbaines.net> writes:
>
>> * gnu/packages/ruby.scm (ruby-hamster): New variable.
> […]
>> +       (add-after 'unpack 'remove-unnecessary-dependencies
>> +         (lambda _
>> +           ;; pry is a debugging tool, and is unnecessary when running the
>> +           ;; tests
>> +           (substitute* "spec/lib/hamster/vector/insert_spec.rb"
>> +             (("require 'pry'") ""))
>> +           (substitute* "spec/spec_helper.rb"
>> +             (("require \"pry\"") "")
>
> We have a ruby-pry package.  Wouldn’t it be nicer to add it instead of
> patching the sources?

It would make the package definition simpler, but it would lead to
redundant rebuilds of this package, and all of it's dependants if the
ruby-pry package changed.

The ideal situation would be for things like this to be optional, but I
think where this isn't the case, it's worth putting some effort in to
the package definition to avoid unnecessary dependencies.

>> +             ;; CodeClimate is an online service, and is unnecessary for
>> +             ;; running the tests
>> +             (("require \"codeclimate-test-reporter\"") "")
>> +             (("CodeClimate.*\n") ""))
>
> Okay.
Ricardo Wurmus Feb. 20, 2019, 7:48 a.m. UTC | #3
Christopher Baines <mail@cbaines.net> writes:

> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> Christopher Baines <mail@cbaines.net> writes:
>>
>>> * gnu/packages/ruby.scm (ruby-hamster): New variable.
>> […]
>>> +       (add-after 'unpack 'remove-unnecessary-dependencies
>>> +         (lambda _
>>> +           ;; pry is a debugging tool, and is unnecessary when running the
>>> +           ;; tests
>>> +           (substitute* "spec/lib/hamster/vector/insert_spec.rb"
>>> +             (("require 'pry'") ""))
>>> +           (substitute* "spec/spec_helper.rb"
>>> +             (("require \"pry\"") "")
>>
>> We have a ruby-pry package.  Wouldn’t it be nicer to add it instead of
>> patching the sources?
>
> It would make the package definition simpler, but it would lead to
> redundant rebuilds of this package, and all of it's dependants if the
> ruby-pry package changed.
>
> The ideal situation would be for things like this to be optional, but I
> think where this isn't the case, it's worth putting some effort in to
> the package definition to avoid unnecessary dependencies.

Okay, sounds fine to me.

Patch

diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm
index a34fb84ae7..a0b7ea86ad 100644
--- a/gnu/packages/ruby.scm
+++ b/gnu/packages/ruby.scm
@@ -1484,6 +1484,52 @@  failure.")
     (home-page "https://github.com/thekompanee/fuubar")
     (license license:expat)))
 
+(define-public ruby-hamster
+  (package
+  (name "ruby-hamster")
+  (version "3.0.0")
+  (source
+    (origin
+      (method url-fetch)
+      (uri (rubygems-uri "hamster" version))
+      (sha256
+        (base32
+          "1n1lsh96vnyc1pnzyd30f9prcsclmvmkdb3nm5aahnyizyiy6lar"))))
+  (build-system ruby-build-system)
+  (arguments
+   '(#:phases
+     (modify-phases %standard-phases
+       (add-after 'unpack 'remove-unnecessary-dependencies
+         (lambda _
+           ;; pry is a debugging tool, and is unnecessary when running the
+           ;; tests
+           (substitute* "spec/lib/hamster/vector/insert_spec.rb"
+             (("require 'pry'") ""))
+           (substitute* "spec/spec_helper.rb"
+             (("require \"pry\"") "")
+             ;; CodeClimate is an online service, and is unnecessary for
+             ;; running the tests
+             (("require \"codeclimate-test-reporter\"") "")
+             (("CodeClimate.*\n") ""))
+           #t))
+       ;; No Rakefile is included, so run rspec directly.
+       (replace 'check
+         (lambda* (#:key tests? #:allow-other-keys)
+           (when tests?
+             (invoke "rspec"))
+           #t)))))
+  (propagated-inputs
+   `(("ruby-concurrent" ,ruby-concurrent)))
+  (native-inputs
+   `(("ruby-rspec" ,ruby-rspec)))
+  (synopsis "Efficient, immutable, thread-safe collection classes for Ruby")
+  (description
+    "Hamster provides 6 persistent data structures: @code{Hash}, @code{Vector},
+@code{Set}, @code{SortedSet}, @code{List}, and @code{Deque} (which works as an
+immutable queue or stack).")
+  (home-page "https://github.com/hamstergem/hamster")
+  (license license:expat)))
+
 (define-public ruby-hashdiff
   (package
     (name "ruby-hashdiff")