Project

gadgeto

0.0
No commit activity in last 3 years
No release in over 3 years
collection of useful code snippets
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.3
>= 0.9.2.2
>= 0
>= 2.8.0
 Project Readme

Gadgeto

Build Status Dependency Status Code Climate

Collection of ruby code snippets.

Usage

All functionality is loaded issuing:

require 'gadgeto/all'

If you plan to use only a handful of snippets, it is recommended to require explicitly each snippet:

require 'gadgeto/<snippet>'

For example:

require 'gadgeto/dslable' # loads Gadgeto::Dslable

Overview

Gadgeto::Domain

require 'gadgeto/domain'

Gadgeto::Domain.valid?("de")         #=> true
Gadgeto::Domain.valid?("test.de")    #=> true
Gadgeto::Domain.valid?("-.test.de")  #=> false

domain = Gadgeto::Domain.new("m.test.de")
domain.third_level_domain?           #=> true

Gadgeto::Dslable

require 'gadgeto/dslable'

class Foo
  include Gadgeto::Dslable
  include Gadgeto::Dslable::Display

  dslable_method :item, :key, '*arguments'

  def inspect
    attributes[:key]
  end
end

f = Foo.new

f.draw do
  item 'home', :baem => :bum do
    item 'terms'
    item 'imprint'
  end

  item 'products' do
    item 'kitchen' do
      item 'forks'
    end
  end
end

f.display :items
f.items[0].attributes[:key] #=> "home"

Gadgeto::Email

require 'gadgeto/email'

Gadgeto::Email.valid?("user@example.com")      #=> true
Gadgeto::Email.valid?("user+name@example.com") #=> true

Gadgeto::SanitizeFilename (Module)

require 'gadgeto/sanitize_filename'

obj = Object.new
obj.extend(Gadgeto::SanitizeFilename)
obj.sanitize_filename("foo bar.zip") #=> "foo_bar.zip"

Gadgeto::TimeOfDay

require 'gadgeto/time_of_day'

Gadgeto::TimeOfDay.valid?("09:15")   #=> true

t = Gadgeto::TimeOfDay.new("08:30")  #=> 08:30
t.hour                               #=> 8
t.minute                             #=> 30
t.to_i                               #=> 480
t.add_minutes(30)                    #=> 09:00

t1 = Gadgeto::TimeOfDay.new("08:30") #=> 08:30
t2 = Gadgeto::TimeOfDay.new("09:30") #=> 09:30
t1 < t2                              #=> true
t1 > t2                              #=> false
t1.minutes_till(t2)                  #=> 60
t1 == t2                             #=> false

Gadgeto::VideoUrl

require 'gadgeto/video_url'

Gadgeto::VideoUrl.valid?("http://vimeo.com/11384488") #=> true
Gadgeto::VideoUrl.supported_services                  #=> [:youtube, :vimeo]

video_url = Gadgeto::VideoUrl.new('http://www.youtube.com/watch?v=0zM3nApSvMg')
video_url.valid?  #=> true
video_url.service #=> :youtube
video_url.id      #=> "0zM3nApSvMg"

Contributors

See https://github.com/avarteqgmbh/gadgeto/contributors