https://github.com/flori/tins
This Is Not Spruz
https://github.com/flori/tins
Last synced: about 11 hours ago
JSON representation
Repository metadata
This Is Not Spruz
- Host: GitHub
- URL: https://github.com/flori/tins
- Owner: flori
- License: other
- Created: 2011-09-23T19:04:03.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2026-07-25T12:18:37.000Z (23 days ago)
- Last Synced: 2026-07-30T20:06:01.959Z (18 days ago)
- Language: Ruby
- Homepage:
- Size: 740 KB
- Stars: 22
- Watchers: 1
- Forks: 11
- Open Issues: 0
- Releases: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
README.md
Tins - Useful tools library in Ruby
Description
A collection of useful Ruby utilities that extend the standard library with
practical conveniences. Tins provides lightweight, dependency-free tools for
common programming tasks.
Documentation
Complete API documentation is available at: GitHub.io
Installation
Add this line to your application's Gemfile:
gem 'tins'
Or:
gem 'tins', require 'tins/xt'
to automatically extend some core classes with useful methods.
And then execute:
$ bundle install
Or install it yourself as:
$ gem install tins
Usage
# Load all utilities
require 'tins'
# Load all utilities and extends core classes with useful methods
require 'tins/xt'
Some Usage Examples
Duration Handling
require 'tins/duration'
duration = Tins::Duration.new(9000)
puts duration.to_s # "02:30:00"
puts duration.to_i # 9000 (seconds)
# Parse durations from strings
Tins::Duration.parse('2h 30m', template: '%hh %mm') # 9000 (seconds)
Unit Conversion
require 'tins/unit'
bytes = Tins::Unit.parse('1.5 GB', unit: ?B).to_i # => 1610612736
puts Tins::Unit.format(bytes, unit: 'B') # "1.500000 GB"
Secure File Writing
require 'tins/xt/secure_write'
# Write files safely (atomic operation)
File.secure_write('config.json', '{"key": "value"}')
Time Freezing for Testing
require 'tins/xt/time_freezer'
# Freeze time during testing
Tins::TimeFreezer.freeze(Time.new('2011-12-13 14:15:16')) do
puts Time.now # Always returns the frozen time
end
Building blocks for DSLs
class Foo
include Tins::DynamicScope
def let(bindings = {})
dynamic_scope do
bindings.each { |name, value| send("#{name}=", value) }
yield
end
end
def twice(x)
2 * x
end
def test
let x: 1, y: twice(1) do
let z: twice(x) do
"#{x} * #{y} == #{z} # => #{x * y == twice(x)}"
end
end
end
end
Foo.new.test # "1 * 2 == 2 # => true"
Core Class Extensions (xt)
When you require tins/xt, some useful methods are added to core classes:
default_options = {
format: :json,
timeout: 30,
retries: 3
}
user_options = { timeout: 60 }
options = user_options | default_options
# => { format: :json, timeout: 60, retries: 3 }
'1.10.3'.version < '1.9.2'.version # => false
add_one = -> x { x + 1 }
multiply_by_two = -> x { x * 2 }
composed = multiply_by_two * add_one
composed.(5) # => 12
# For Testing
>> o = Object.new
>> o.puts # => private method, NoMethodError
>> o = o.expose
>> o.puts "hello"
hello
Hash Symbolization
require 'tins/xt/hash_symbolize_keys_recursive'
hash = {
'name' => 'John',
'age' => 30,
'address' => {
'street' => '123 Main St'
}
}
hash.symbolize_keys_recursive! # Converts all keys to symbols using a stack-safe deep transformation
Deep Hash and Array Transformation
require 'tins/xt/deep_transform'
h = { "name" => "john", "details" => { "city" => "berlin", "tags" => ["ruby", "dev"] } }
# Transform keys to symbols and values (if strings) to uppercase
result = h.deep_transform(
key: -> k { k.to_sym },
value: -> v { v.is_a?(String) ? v.upcase : v }
)
# => { name: "JOHN", details: { city: "BERLIN", tags: ["RUBY", "DEV"] } }
Advanced Usage (Contextual Transformations)
The value lambda can accept 1, 2, or 3 arguments depending on the level of context required for each node's transformation:
-> v { ... }: Global transform (node only).-> k, v { ... }: Contextual transform (key/index and node).-> k, v, c { ... }: Full structural transform (key/index, node, and parent container).
🧮 Example: Calculating a moving average on a nested array structure
require 'tins/xt/deep_transform'
# Root can be an Array as well
a = (1..10).each_slice(5).map(&:to_a)
# => [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]
result = a.deep_transform(value: -> i, x, c {
Array === c && Numeric === x && i > 0 ? (c[i-1] + x) / 2.0 : x
})
# => [[1, 1.5, 2.5, 3.5, 4.5], [6, 6.5, 7.5, 8.5, 9.5]]
🛡️ Example: Structural Pruning & Sanitization
Because deep_transform processes nodes bottom-up, you can effectively prune
entire branches of a tree by returning an empty container when a specific
condition (like a "private" flag) is met.
require 'tins/xt/deep_transform'
# A nested data structure with some sections marked for pruning
api_response = {
user: {
name: "Florian",
profile: { bio: "Ruby Expert", internal_id: "SECRET_123", noindex: true }
},
settings: {
theme: "dark",
debug_info: { logs: ["Error 404"], noindex: true }
}
}
# Prune any Hash that is marked with `noindex: true`
sanitized = api_response.deep_transform(value: -> v {
(v.is_a?(Hash) && v[:noindex]) ? {} : v
})
# => { user: { name: "Florian", profile: {} }, settings: { theme: "dark", debug_info: {} } }
Author
License
Owner metadata
- Name: Florian Frank
- Login: flori
- Email:
- Kind: user
- Description:
- Website:
- Location: Berlin, Germany
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/15918?u=7fbe6878fe6f97c20d1a5a4fce900dae1154c98e&v=4
- Repositories: 97
- Last ynced at: 2024-04-23T11:23:12.550Z
- Profile URL: https://github.com/flori
GitHub Events
Total
- Release event: 8
- Fork event: 1
- Issue comment event: 3
- Push event: 22
- Create event: 7
Last Year
- Release event: 5
- Fork event: 1
- Issue comment event: 3
- Push event: 16
- Create event: 3
Committers metadata
Last synced: 1 day ago
Total Commits: 556
Total Committers: 7
Avg Commits per committer: 79.429
Development Distribution Score (DDS): 0.018
Commits in past year: 181
Committers in past year: 2
Avg Commits per committer in past year: 90.5
Development Distribution Score (DDS) in past year: 0.011
| Name | Commits | |
|---|---|---|
| Florian Frank | f****i@p****e | 546 |
| Tobias | t@t****e | 3 |
| Diego Elio Pettenò | f****s@f****u | 2 |
| Colin Kelley | c****n@i****m | 2 |
| Otto Urpelainen | o****e@i****i | 1 |
| Jens Fahnenbruck | j****x@m****m | 1 |
| Janosch Müller | j****r@b****g | 1 |
Committer domains:
- betterplace.org: 1
- me.com: 1
- iki.fi: 1
- invoca.com: 1
- flameeyes.eu: 1
- tobiasjordans.de: 1
- ping.de: 1
Issue and Pull Request metadata
Last synced: 11 days ago
Total issues: 12
Total pull requests: 13
Average time to close issues: about 2 years
Average time to close pull requests: 3 months
Total issue authors: 12
Total pull request authors: 8
Average comments per issue: 1.33
Average comments per pull request: 0.92
Merged pull request: 5
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 3
Past year average time to close issues: N/A
Past year average time to close pull requests: 3 months
Past year issue authors: 0
Past year pull request authors: 2
Past year average comments per issue: 0
Past year average comments per pull request: 1.67
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- arfl (1)
- Peeja (1)
- ppeble (1)
- jaynetics (1)
- lion-man44 (1)
- tordans (1)
- axilleas (1)
- wildlyinaccurate (1)
- Ana06 (1)
- graaff (1)
- PikachuEXE (1)
- oturpe (1)
Top Pull Request Authors
- tordans (3)
- oturpe (3)
- parkr (2)
- Flameeyes (1)
- jigfox (1)
- katrinundfritz (1)
- jaynetics (1)
- ColinDKelley (1)
Top Issue Labels
Top Pull Request Labels
Package metadata
- Total packages: 16
-
Total downloads:
- rubygems: 244,146,080 total
- Total docker downloads: 1,222,647,138
- Total dependent packages: 133 (may contain duplicates)
- Total dependent repositories: 17,966 (may contain duplicates)
- Total versions: 425
- Total maintainers: 1
gem.coop: tins
All the stuff that isn't good/big enough for a real library.
- Homepage: https://github.com/flori/tins
- Documentation: http://www.rubydoc.info/gems/tins/
- Licenses: MIT
- Latest release: 1.54.0 (published 3 months ago)
- Last Synced: 2026-07-09T21:01:40.553Z (about 1 month ago)
- Versions: 136
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 122,119,716 Total
- Docker Downloads: 611,323,569
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 0.071%
- Downloads: 0.213%
- Maintainers (1)
ubuntu-20.04: ruby-tins
- Homepage: https://github.com/flori/tins
- Licenses: other
- Latest release: 1.1.0-2 (published 6 months ago)
- Last Synced: 2026-03-13T14:25:41.679Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Forks count: 0.685%
- Average: 0.727%
- Stargazers count: 2.222%
rubygems.org: tins
All the stuff that isn't good/big enough for a real library.
- Homepage: https://github.com/flori/tins
- Documentation: http://www.rubydoc.info/gems/tins/
- Licenses: MIT
- Latest release: 1.54.0 (published 3 months ago)
- Last Synced: 2026-07-07T15:11:48.658Z (about 1 month ago)
- Versions: 136
- Dependent Packages: 133
- Dependent Repositories: 17,966
- Downloads: 122,026,364 Total
- Docker Downloads: 611,323,569
-
Rankings:
- Downloads: 0.206%
- Docker downloads count: 0.248%
- Dependent packages count: 0.26%
- Dependent repos count: 0.268%
- Average: 3.437%
- Forks count: 8.314%
- Stargazers count: 11.323%
- Maintainers (1)
proxy.golang.org: github.com/flori/tins
- Homepage:
- Documentation: https://pkg.go.dev/github.com/flori/tins#section-documentation
- Licenses: other
- Latest release: v1.54.0 (published 3 months ago)
- Last Synced: 2026-07-07T15:11:48.790Z (about 1 month ago)
- Versions: 137
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Forks count: 6.374%
- Stargazers count: 7.895%
- Average: 8.662%
- Dependent packages count: 9.576%
- Dependent repos count: 10.802%
debian-11: ruby-tins
- Homepage: https://github.com/flori/tins
- Documentation: https://packages.debian.org/bullseye/ruby-tins
- Licenses:
- Latest release: 1.1.0-2 (published 6 months ago)
- Last Synced: 2026-03-13T10:28:26.264Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-10: ruby-tins
- Homepage: https://github.com/flori/tins
- Documentation: https://packages.debian.org/buster/ruby-tins
- Licenses:
- Latest release: 1.1.0-1 (published 6 months ago)
- Last Synced: 2026-03-14T03:02:25.347Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
gentoo-portage: dev-ruby/tins
All the stuff that isn't good enough for a real library
- Homepage: https://github.com/flori/tins
- Documentation: https://packages.gentoo.org/packages/dev-ruby/tins
- Licenses: MIT
- Latest release: 1.49.0 (published 4 months ago)
- Last Synced: 2026-05-27T02:51:52.518Z (3 months ago)
- Versions: 4
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
pkgsrc-netbsd-x86_64-10.1-all: devel/ruby-tins
Not good/big enough for a real library
- Homepage: https://github.com/flori/tins
- Documentation: https://pkgsrc.se/devel/ruby-tins
- Licenses: mit
- Latest release: 1.52.0 (published 4 months ago)
- Last Synced: 2026-05-27T06:48:03.739Z (3 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
guix: ruby-tins
Assorted tools for Ruby
- Homepage: https://github.com/flori/tins
- Documentation: https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/ruby-xyz.scm#n7236
- Licenses: expat
- Latest release: 1.29.1 (published 6 months ago)
- Last Synced: 2026-04-27T16:17:08.712Z (4 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-12: ruby-tins
- Homepage: https://github.com/flori/tins
- Documentation: https://packages.debian.org/bookworm/ruby-tins
- Licenses:
- Latest release: 1.1.0-2 (published 6 months ago)
- Last Synced: 2026-03-13T03:29:11.266Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
debian-13: ruby-tins
- Homepage: https://github.com/flori/tins
- Documentation: https://packages.debian.org/trixie/ruby-tins
- Licenses:
- Latest release: 1.32.1-1 (published 6 months ago)
- Last Synced: 2026-03-14T18:11:55.629Z (5 months ago)
- Versions: 1
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent repos count: 0.0%
- Dependent packages count: 0.0%
- Average: 100%
Dependencies
- byebug >= 0 development
- term-ansicolor >= 0 development
- actions/checkout v3 composite
- github/codeql-action/analyze v2 composite
- github/codeql-action/autobuild v2 composite
- github/codeql-action/init v2 composite
- actions/checkout v4 composite
- actions/configure-pages v5 composite
- actions/deploy-pages v4 composite
- actions/upload-pages-artifact v3 composite
- ruby/setup-ruby v1 composite
Score: 26.143310159396332