Arroyo is a collection of ruby monkey-patches, ideas and concepts, and other random bits culled from multiple sources.
Arroyo packages
- Timerizer
- Github-ds for Resiliancy
- Backtrace Shortener - Modified version of the backtrace_shortener gem
- mini_cache
Add this line to your application's Gemfile:
gem 'arroyo'
# or
gem "arroyo", :git => 'git@github.com:marshallmick007/arroyo.git', :submodules => true
And then execute:
$ bundle
Or install it yourself as:
$ gem install arroyo
Arroyo offers a global configuration pattern
Arroyo.configure do |config|
config.app_root = '/path/to/app/root'
end
Supported options are:
app_root
: A path to your applications root directory
Cleans up backtraces by monkey-patching the Exception class. Modified version of backtrace_shortener with a built in filter to remove all backtraces for anything other than your app.
# enable the patch
Arroyo::Backtrace.monkey_patch!
# reject all backtraces that to not originate from your app
Arroyo::Backtrace.show_only_app_exceptions!
# or to specify a directory root to ignore...
Arroyo::Backtrace.show_only_app_exceptions!(File.dirname(__FILE__))
Arroyo::RandomString.random_string :chars
#> "KvnVAnd3rxHvw1ziikvz6nG0sPeS7c"
Arroyo::RandomString.random_string :chars, :length => 12, :symbols => true
#> "jd-X3C9XHb%e"
Arroyo::RandomString.random_string :chars, :length => 12, :upper_letters_only => true
#> "IOEDTKEFOWUW"
Arroyo::RandomString.random_string :uuid
#> "24a58f79-33ae-4a5d-9a1c-37cda2080bc8"
Arroyo::RandomString.random_string :guid
#> "e628c8e9-38fa-4e89-985a-9f96eb6e368d"
Arroyo::RandomString.random_string :hex
#> "ed5693d8b28089f81144621336357dc7aa60cd9c84e69e41"
Arroyo::RandomString.random_string :hex, :length => 8
#> "d3621e17ba8fb9e4"
Arroyo::RandomString.guid
#> "84ffe4f3-91ba-4ba2-aee2-5c1cf1305889"
Monkey-patches the Numeric
class. Converts an integer, float, etc to the proper
representation of the number of bytes
4.12.MB
#> 4320133.12
13.GB
#> 13958643712
Adds a wrapper around URI.parse
u = Arroyo::Url.create("www.test.com")
u.ok?
#> true
u.value
#> #<URI::HTTP http://www.test.com>
u.host
#> www.test.com
u.tld
#> com
w = u.remove_www
w.host
#> test.com
Arroyo::Url
takes an optional hash of additional settings that the
create
method will use when constructing a URL. The defaults for this
hash are:
DEFAULT_OPTS = {
:scheme => 'http',
:strict => false,
:strip_www => false
}
:strict
will cause the result to fail if the host name supplied does
not look like an internet address (eg: domain.tld, www.domain.co.tld,
etc)
Arroyo::HumanTime.humanize(time)
#> "4 minutes ago"
Useful to pull information about a deploy of an application. It will try to fetch the git sha of the deployed application by either inspecting the .git folder on a server, if available, or by reading the Capistrano REVISION file.
If Arroyo could determine a git sha hash, the deployed?
property
will be true
.
Arroyo reviews the RACK_ENV
environment variable to understand if the
application is in production mode or development mode
Arroyo.environment
#> #<Arroyo::Environment:0x005615faab6920 @env=:development, @deploy_version="ee2ec43", @deploy_date="2017-07-05 21:47:06 -0600\n5183ad7", @deploy_mode=:git>
Arroyo.environment.dev?
#> true
Arroyo.environment.prod?
#> false
Arroyo.environment.deployed?
#> false
- 0.1.7 - Added
mini_cache
- 0.1.6 - Added
Arroyo::Configuration
,RandomString.guid
convienence method, andArroyo::HumanTime
- 0.1.3 - Add
remove_www
,is_http?
,is_https?
methods toArroyo::Url
class - 0.1.1 - Add support for passing an options hash to
Arroyo::Url.create
- Add
retryable
from https://github.com/kamui/retriable - Date extensions from Rails PR 24930. Sequel supports Range
where
clauses - PowerCore, or PowerPack
- Pretty Backtrace
- Haikuinator
- Nifty-Utils
DATA constant - https://github.com/thoughtbot/til/blob/master/ruby/the-data-constant.md
TODO: Write usage instructions here
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/marshallmick007/arroyo.
The gem is available as open source under the terms of the MIT License.