Giter Club home page Giter Club logo

stringex's Introduction

Stringex Build Status Gem Version

Some [hopefully] useful extensions to Ruby's String class. It is made up of three libraries: ActsAsUrl, Unidecoder, and StringExtensions.

NOTE: Stringex 2.0 [and beyond] drops support for Rails 2. If you need support for that version, use 1.5.1 instead.

ActsAsUrl

NOTE: You can now require 'stringex_lite' instead of 'stringex' and skip loading ActsAsUrl functionality if you don't need it.

This library is designed to create URI-friendly representations of an attribute, for use in generating urls from your attributes. Basic usage is just calling the method:

# Inside your model
acts_as_url :title

which will populate the url attribute on the object with the converted contents of the title attribute. acts_as_url takes the following options:

:url_attribute The name of the attribute to use for storing the generated url string. Default is :url
:scope The name of model attribute to scope unique urls to. There is no default here.
:only_when_blank If set to true, the url generation will only happen when :url_attribute is blank. Default is false (meaning url generation will happen always).
:sync_url If set to true, the url field will be updated when changes are made to the attribute it is based on. Default is false.
:allow_slash If set to true, the url field will not convert slashes. Default is false.
:allow_duplicates If set to true, unique urls will not be enforced. Default is false. NOTE: This is strongly not recommended if you are routing solely on the generated slug as you will no longer be guaranteed to lookup the expected record based on a duplicate slug.
:limit If set, will limit length of url generated. Default is nil.
:truncate_words Used with :limit. If set to false, the url will be truncated to the last whole word before the limit was reached. Default is true.
:blacklist List of urls that should not be allowed. Default is %w{new} [which avoids confusion on urls like /documents/new].
:blacklist_policy Proc or lambda defining new naming behavior when blacklisted urls are encountered. Default converts /documents/new to /documents/new-document.

In order to use the generated url attribute, you will probably want to override to_param like so, in your Model:

# Inside your model
def to_param
  url # or whatever you set :url_attribute to
end

Routing called via named routes like foo_path(@foo) will automatically use the url. In your controllers you will need to call Foo.find_by_url(params[:id]) instead of the regular find. Don't look for params[:url] unless you set it explicitly in the routing, to_param will generate params[:id].

Note that if you add acts_as_url to an existing model, the url database column will initially be blank. To set this column for your existing instances, you can use the initialize_urls method. So if your class is Post, just say Post.initialize_urls.

Unlike other permalink solutions, ActsAsUrl doesn't rely on Iconv (which is inconsistent across platforms and doesn't provide great transliteration as is) but instead uses a transliteration scheme (see the code for Unidecoder) which produces much better results for Unicode characters. It also mixes in some custom helpers to translate common characters into a more URI-friendly format rather than just dump them completely. Examples:

# A simple prelude
"simple English".to_url => "simple-english"
"it's nothing at all".to_url => "its-nothing-at-all"
"rock & roll".to_url => "rock-and-roll"

# Let's show off
"$12 worth of Ruby power".to_url => "12-dollars-worth-of-ruby-power"
"10% off if you act now".to_url => "10-percent-off-if-you-act-now"

# You dont EVEN wanna rely on Iconv for this next part
"kick it en Français".to_url => "kick-it-en-francais"
"rock it Español style".to_url => "rock-it-espanol-style"
"tell your readers 你好".to_url => "tell-your-readers-ni-hao"

Compare those results with the ones produced on my Intel Mac by a leading permalink plugin:

"simple English" # => "simple-english"
"it's nothing at all" # => "it-s-nothing-at-all"
"rock & roll" # => "rock-roll"

"$12 worth of Ruby power" # => "12-worth-of-ruby-power"
"10% off if you act now" # => "10-off-if-you-act-now"

"kick it en Français" # => "kick-it-en-francais"
"rock it Español style" # => "rock-it-espan-ol-style"
"tell your readers 你好" # => "tell-your-readers"

Not so great, actually.

Note: No offense is intended to the author(s) of whatever plugins might produce such results. It's not your faults Iconv sucks.

Unidecoder

This library converts Unicode [and accented ASCII] characters to their plain-text ASCII equivalents. This is a port of Perl's Unidecode and provides eminently superior and more reliable results than Iconv. (Seriously, Iconv... A plague on both your houses! [sic])

You may require only the unidecoder (and its dependent localization) via

require "stringex/unidecoder"

You probably won't ever need to run Unidecoder by itself. Thus, you probably would want to add String#to_ascii which wraps all of Unidecoder's functionality, by requiring:

require "stringex/core_ext"

For anyone interested, details of the implementation can be read about in the original implementation of Text::Unidecode. Extensive examples can be found in the tests.

StringExtensions

A small collection of extensions on Ruby's String class. Please see the documentation for StringExtensions module for more information. There's not much to explain about them really.

Localization

With Stringex version 2.0 and higher, you can localize the different conversions in Stringex. Read more here. If you add a new language, please submit a pull request so we can make it available to other users also.

Ruby on Rails Usage

When using Stringex with Ruby on Rails, you automatically get built-in translations for miscellaneous characters, HTML entities, and vulgar fractions. You can see Stringex's standard translations here.

Currently, built-in translations are available for the following languages:

  • English (en)
  • Danish (da)
  • Swedish (sv)
  • Dutch (nl)
  • German (de)
  • Polish (pl)
  • Portuguese Brazilian (pt-BR)
  • Russian (ru)

You can easily add your own or customize the built-in translations - read here. If you add a new language, please submit a pull request so we can make it available to other users also.

If you don't want to use the Stringex built-in translations, you can force Stringex to use English (or another language), regardless what is in your I18n.locale. In an initializer, e.g. config/initializers/stringex.rb:

Stringex::Localization.locale = :en

CanCan Usage Note

You'll need to add a :find_by => :url to your load_and_authorize_resource. Here's an example:

load_and_authorize_resource :class => "Whatever", :message => "Not authorized", :find_by => :url

Semantic Versioning

This project conforms to semver. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:

spec.add_dependency 'stringex', '~> 1.0'

This means your project is compatible with licensee 1.0 up until 2.0. You can also set a higher minimum version:

spec.add_dependency 'stringex', '~> 1.1'

Thanks & Acknowledgements

If it's not obvious, some of the code for ActsAsUrl is based on Rick Olsen's permalink_fu plugin. Unidecoder is a Ruby port of Sean Burke's Text::Unidecode module for Perl. And, finally, the bulk of strip_html_tags in StringExtensions was stolen from Tobias Lütke's Regex in Typo.

GIANT thanks to the many contributors who have helped make Stringex better and better: http://github.com/rsl/stringex/contributors

Copyright (c) 2008-2018 Lucky Sneaks, released under the MIT license

stringex's People

Contributors

dblock avatar dimi-iv avatar ehoch avatar futhr avatar fx avatar giga811 avatar glebtv avatar herwinw avatar iamnader avatar jocmp avatar jtsagata avatar julia-otran avatar lassebunk avatar martio avatar oleriesenberg avatar omegahm avatar pbechu avatar pdlug avatar rsl avatar rubyjedi avatar rwz avatar sarcilav avatar slbug avatar stormsilver avatar tampakis avatar telzul avatar thoraxe avatar utilum avatar vfonic avatar zapnap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stringex's Issues

Equals not stringified

Equals signs seems not to be stringified: "hello=world" seems to end up being "hello=world", when it probably could end up being "hello-equals-world".

optional underscore conversion (and euro sign)

I would like to suggest adding an option to NOT convert underscores into dashes, something like :convert_underscore => true (which would be the default option). It seems quite easy to do, but I rather let you do it than add a fork myself that would never get integrated into the official gem...

And by the way, I am missing a euro sign conversion.

sometimes items with nil urls are created

I have not been able to come up with a 100% reproducible test case, but I have noticed several occasions now where a record is created and somehow stringex/acts_as_url creates a nil url.

even with auto sync set, updating the url attribute for this record does not cause the url to be re-generated.

it may have to do with plurals or creating a record whose url attribute contains a subset of the same url as an existing record like:
"Happy Farm"
"Happy Farms"

Will try some more extensive testing at some point in the near future.

MongoDB (and Mongoid) issue with acts_as_url

class Article
  include Mongoid::Document
  include Stringex::ActsAsUrl

  field :title, type: String

  embeds_many :comments

  acts_as_url :title, sync_url: true

  # using Stringex gem - https://github.com/rsl/stringex
  def to_param
    url # or whatever you set :url_attribute to
  end
end
class Comment
  include Mongoid::Document
  include Stringex::ActsAsUrl

  embedded_in :article

  field :subject, type: String

  acts_as_url :subject, sync_url: true

  # using Stringex gem - https://github.com/rsl/stringex
  def to_param
    url # or whatever you set :url_attribute to
  end
end
article = Article.create title: 'hello'
Comment.create subject: 'nice one', article: article

$ rake db:seed

Problem:
Problem:
  Document(s) not found for class Article with id(s) all, {:conditions=>["url LIKE ?", "hello%"]}.
Summary:
  When calling Article.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): all, {:conditions=>["url LIKE ?", "hello%"]} ... (2 total) and the following ids were not found: all, {:conditions=>["url LIKE ?", "hello%"]}.
Resolution:
  Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.

Looks like it is hardcoded to use SQL like syntax such as "url LIKE".

From MongoDB documentation...

http://api.mongodb.org/wiki/current/Advanced%20Queries.html

You may use regexes in database query expressions:

db.customers.find( { name : /acme.*corp/i } );

Translating this to Mongoid 3.x

article = Article.create title: 'hello you'
puts Article.where(title: /hello.*/).first.inspect

=>
#<Article _id: 50b88995ff0961046e000001, _type: nil, created_at: 2012-11-30 10:25:25 UTC, updated_at: 2012-11-30 10:25:25 UTC, title: "hello you">

The key is to replace the {:conditions=>["url LIKE ?", "hello%"]} with where(title: /hello.*/).first for mongoid.

It would be nice to abstract the SQL part into an SQL adapter and then also include a Mongoid adapter as well IMO. I will fork the project and see if I can make such a solution, then make a pull request.
For now, please mention that it only works for "SQL based" models.
Thanks!

incompatible character encodings: UTF-8 and ASCII-8BIT

I encounter this bug on my machine with ruby 1.9.2dev (2010-04-24 trunk 27474) [x86_64-darwin10.3.0] and ruby-1.9.1-p376

@@@

trung-les-mac-pro:stringex MAC$ gem install stringex-1.1.0.gem
Successfully installed stringex-1.1.0
1 gem installed
Installing ri documentation for stringex-1.1.0...
Installing RDoc documentation for stringex-1.1.0...
ERROR: While executing gem ... (Encoding::CompatibilityError)
incompatible character encodings: UTF-8 and ASCII-8BIT

@@@

ellipsis converts to ...

If you to_url on an ellipsis you get ... (three dots). If you to_url those dots again you get "dot-dot-dot"

Having dots in a to_param slug messes up a lot of stuff in rails, so I think you should translate an ellipsis directly to dot-dot-dot

Checking for duplicates across other models

Currently duplicates in ActsAsUrl are checked only within the scope of the current class (see https://github.com/rsl/stringex/blob/master/lib/stringex/acts_as_url.rb#L97).

When using Single Table Inheritance this may sometimes be the wanted behaviour but there could be some cases where duplicates should be checked across the differents submodels.

I'd submit a patch but I don't see how to change the current implementation. Maybe adding an option to specify the class name of the model to check for duplicates ?

When using acts_as_url is there a way to directly set the value of the url_attribute?

I'm trying to use stringex and acts_as_url on a model.

I've got my model set up like this:
acts_as_url :name, :url_attribute => :permalink, :only_when_blank => true

However, there are times where I'd like to to directly set a value of :permalink that's not generated from the :name, but it seems that acts_as_url isn't allowing it to happen.

Is there a way to allow this to happen?

before_validation_on_create removed in Rails 3

In the current edge rails it seems before_validation_on_create is deprecated in favor of
before_validation :asdf, :on => :create

Acts as url would need to be patched to conform to this.

url should not be updated if model fails validation?

Use case: I have a model whose title is used to create the url / permalink. I'm using sync_url => true. update_attributes is called with a title value that fails validation (blank value when presence is required, for example).

When this happens, my Rails application re-renders the template with errors so the user can fix the validation problems. However, the url value has changed. Now, route shortcuts are broken because the model instance has an empty url, when the url probably never should have been updated at all.

I created a failing test to demonstrate the scenario. Can work on a patch if this makes sense (note that an after_validation callback won't fire if validation fails):

zapnap@00ada38

edge case handling

is there any good workaround for edge cases such as an input value of "???" which will be turned into the empty string "" by the to_url method

Those should be avoided, as rails cannot handle it as an id to search by.

best regards,

Lennart

Strange conversion

Shouldn't this work?

assert_equal 'utf', 'μ†ℱ'.to_url

It's translated to

  • m+f in 1.4
  • m-plus-f in 1.5

| in urls

As far as I know, | symbol is not allowed in urls, but .to_url method doesn't remove it.

Better behavior with duplicates?

I propose that the duplicate urls be distinguished with two dashes instead of one. I think that it provides a better semantic.

ex: /peugeot-206--2/ instead of /peugeot-206-2/

This, I think, means that the line 82 of acts_as_url.rb should be "#{base_url}--#{n}".

How to include year and month in URL?

Hi

I'm successfully using stringex for URLs like /blog/the-title-of-my-post

Is it possible to achieve something like /blog/2010/08/the-title-of-my-post?

One solution I'm thinking of is to populate a 'year_month_title' field on creation that contains both the year, month and title, then use said field with :acts_as_url. Is this the easiest way or have I overlooked an alternative?

Thanks!

Ben

Error in `to_ascii` example

CAUTION: this is hella nitpicky and probably doesn't matter at all, but i'm an OCD freak, what can i say?

module Stringex
  module StringExtensions
    # Returns string with its UTF-8 characters transliterated to ASCII ones. Example:
    #
    #   "⠋⠗⠁⠝⠉⠑".to_ascii #=> "braille"
    def to_ascii
      Stringex::Unidecoder.decode(self)
    end
  end
end

but when i actually run that code:

[Dev]> "⠋⠗⠁⠝⠉⠑".to_ascii #=> "braille"
=> "france"

I18n and the empty string

The following spec fails:

def test_localized_html_entities_conversion_with_blank_replacement
    Stringex::Localization.backend = :internal
    Stringex::Localization.store_translations :da, :html_entities, {
       :nbsp => ""
    }
    Stringex::Localization.locale = :da

    {
      "Det var blå&nbsp;sort" => "Det var blåsort"
    }.each do |entitied, plain|
      assert_equal plain, entitied.convert_miscellaneous_html_entities
    end
end

"Det var blå&nbsp;sort".convert_miscellaneous_html_entities returns "Det var blå sort" with the default replacement for &nbsp; still in place.

"dot" used for abbreviations

I understand the reasoning behind something like "google.com" -> "google dot com"

However, I feel that for abbreviations, "D.N.A." would be better converted to "dna"

Yay/nay ? I'd be happy to work on and submit a patch.

"ǝ".to_url == "@"

The transliteration of ǝ produces an @ in the final URL which isn't legal :(

Generate real Unicode URL

Hello,
Thank you for create very nice module.
When I read a document, I found the example below.
"tell your readers 你好".to_url => "tell-your-readers-ni-hao"

Could I make a slug as real Unicode likes below one?

"tell your readers 你好 bla".to_url => "tell-your-readers-你好-bla"

Have a nice day!

puzzle for mixture of Chinese and English

when I test with mixture of Chinese and English. The result is puzzled

1.9.3-p327-falcon :001 > require 'stringex'
 => true 
1.9.3-p327-falcon :002 > "中文yinwen混合".to_url
 => "zhong-wen-yinwenhun-he"

maybe zhong-wen-yinwen-hun-he is better?

"to_url" method returns string with comma and apostrophe

I have next Japanease and Russian strings:
"AVアンプ、ホームシアターシステム、スピーカーシステム等".to_url
"У лукоморья дуб зеленый".to_url
This returns:
avanpu,-homusiatasisutemu,-supikasisutemudeng
u-lukomor'ia-dub-zielienyi
I think it's no good to have commas or apostrophes in the url.
Maybe will be fine to add somethig like that to the end of "to_url" method:
.gsub(/[^a-zA-Z0-9-]/, '')
or just add standard
.parameterize
What do you think about that?

Add ability to exclude loading parts of Stringex

Working on configuration changes right now so great time to do it. akradev@1ec9a04 is an example of a user needing to skip loading acts_as_url. Could be a sign of need to separate concerns into separate gems in the future but just looking at configuration concerns for the moment.

Ruby 1.9.1 support

Here is the backtrace when I require 'stringex' with Ruby 1.9.1.
Did you plan Ruby 1.9.1 support ? As strings are handled differently, I suppose that it's a big work.

irb(main):001:0> require 'stringex'
SyntaxError: /opt/local/lib/ruby/gems/1.9.1/gems/rsl-stringex-1.0.0/lib/lucky_sneaks/string_extensions.rb:123: invalid multibyte char (US-ASCII)
/opt/local/lib/ruby/gems/1.9.1/gems/rsl-stringex-1.0.0/lib/lucky_sneaks/string_extensions.rb:123: invalid multibyte char (US-ASCII)
/opt/local/lib/ruby/gems/1.9.1/gems/rsl-stringex-1.0.0/lib/lucky_sneaks/string_extensions.rb:123: syntax error, unexpected $end, expecting tASSOC
        /(\s|^)£(\d+)\.(\d+)(\s|$)/u => '\2 pounds \3 pence',
                 ^
    from /opt/local/lib/ruby/gems/1.9.1/gems/rsl-stringex-1.0.0/lib/stringex.rb:1:in `require'
    from /opt/local/lib/ruby/gems/1.9.1/gems/rsl-stringex-1.0.0/lib/stringex.rb:1:in `'
    from (irb):1:in `require'
    from (irb):1
    from /opt/local/bin/irb:12:in `'

Comma as hundreds separator in to_url

When using comma as a hundreds separator, e.g.

"Save $1,000 now".to_url

becomes

"save-1-dollar-000-now"

instead of

"save-1000-dollars-now"

The correct output would be the same output as

"Save $1000 now".to_url

to_url returns punctuation '&', ',', etc

"カッページ・テラスに日系カフェ&バー、店内にDJブースも - シンガポール経済新聞".to_url
=> "katupeziterasuniri-xi-kahue&ba,-dian-nei-nidjbusumo-singaporujing-ji-xin-wen"

Suggestion: Global configuration of default options

Would be nice to be able to set the global defaults for Config, such as:

# config/initializers/acts_as_url.rb

StringEx::ActsAsUrl.config do |c|
  c.sync_url = true
  ...
end

So I won't have to set this option for all my models if they should all be synced ;) A common use case I would suspect.

Grave accent ` symbol in urls

to_url doesn't remove the grave accent symbol despite the fact, that it's not allowed in urls.
Also okina symbol ʻ is replaced with the grave accent instead of being removed.

Can not generate rdoc in ruby 1.9.1

I use ruby 1.9.1(p376)
gem rdoc stringex --no-ri -V
Installing RDoc documentation for stringex-1.1.0...
ERROR: While executing gem ... (Encoding::CompatibilityError)
incompatible character encodings: UTF-8 and ASCII-8BIT

Allow underscore in url

We have a feature where users can input custom urls, and we allow '' in those urls. Is there a simple way to disable the current conversation from '' to '-' in stringex?

When using translations it removes more than necessary

I have the following in my da.yml-file:

stringex:
  characters:
    dot: "-"

When I do

"Spar 1.000 kr".to_url

I get

spar-00-kr

in return, where I should get

spar-1-000-kr

Also, having dot: '' and doing the same conversion yields:

spar-1-dot-000-kr

Meaning that it doesn't respect my choice of the empty string.

Documentation issue (small fix)

Looks like you need to explicitly include the Stringex::ActsAsUrl module in your model in order to add the acts_as_url class method.

Please add this to the top of the README for newbies ;) hehe

Adding a :ensure_unique => false option?

I think it would be cool if you could set a flag on the the acts_as_url call to disable the ensure unique behavior altogether. I sometimes just want a failing validation. If this happened then we would need to change ensure_unique_url to something like format_url which then calls the unique check only if the option is selected (which would be the default for compat). I can fork and code this up...

suggestion to add Unicode::normalize_KD

I have next string:
"éç™①".to_ascii => "ec"
So "TM1" is missing.
I propose to add Unicode::normalize_KD to "to_ascii" method.
Like that:
require "unicode"
def to_ascii
LuckySneaks::Unidecoder.decode(Unicode::normalize_KD(self))
end
Than would be:
"éç™①".to_ascii => "ecTM1"
I think this much great!..

Unidecoder.decode returns unexpected strings under JRuby 1.6 in --1.9 mode

When LuckySneaks::Unidecoder.decode is used in JRuby 1.6 under --1.9 mode, it returns strings that are completely different from --1.8 mode (the default), MRI and Rubinius.

See the attached test case: https://gist.github.com/886474

I looked into this a bit and it appears as if the psych YAML parser, being used in --1.9 mode (and slated for future use by MRI), is failing to parse all the unidecoder_data files. I couldn't see this until I commented out the rescue block in the code and let the exceptions propagate up the stack.

I'm not sure whether the YAML files are invalid, or psych is raising an exception when it shouldn't. I was thinking that maybe if the YAML files could be regenerated from the original source using psych that it might escape things in a way that is closer to the current YAML standard, and easier for psych to parse.

Specify Limit

What do we think of allowing acts_as_url to allow a limit to be specified? The reason I ask is because I set a limit on my slug fields in my database to keep index key lengths sane.

Psych yaml parsing issue

When using stringex with PSYCH as a YAML backend, .to_url fails throwing a : Psych::SyntaxError
alex@1:~/diveboard-web$ rails console
Loading development_alex environment (Rails 3.0.6)
irb(main):001:0> require 'stringex'
=> nil
irb(main):002:0> "Sébastien".to_url
Psych::SyntaxError: couldn't parse YAML at line 2 column 3
from /usr/lib/ruby/1.9.1/psych.rb:148:in parse' from /usr/lib/ruby/1.9.1/psych.rb:148:inparse_stream'
from /usr/lib/ruby/1.9.1/psych.rb:119:in parse' from /usr/lib/ruby/1.9.1/psych.rb:106:inload'
from /usr/lib/ruby/1.9.1/psych.rb:205:in load_file' from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:8:inblock in module:Unidecoder'
from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:19:in yield' from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:19:indefault'
from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:19:in block in decode' from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:16:ingsub'
from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:16:in decode' from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/unidecoder.rb:59:into_ascii'
from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/string_extensions.rb:45:in remove_formatting' from /var/lib/gems/1.9.1/gems/stringex-1.2.1/lib/lucky_sneaks/string_extensions.rb:39:into_url'
from (irb):2
from /var/lib/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands/console.rb:44:in start' from /var/lib/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands/console.rb:8:instart'
from /var/lib/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'irb(main):003:0>

A quick temporary fix is to force the use of old syck parser :
in : config/boot.rb

require 'yaml'
YAML::ENGINE.yamler= 'syck'

yet ultimately this issue should be properly addressed :) (syck is not maintained anymore)

initialize_urls just hangs

Rails 3.2.3 , Ruby 1.9.3-p125 , Stringex 1.4.0

Klass.initialize_urls is just hanging... no progress for hours

Klass is the base-class of an STI class hierarchy.

Exclusion option

Options should enable passing an array of strings to exclude from to_url. This allows handling of special cases where it's not desirable to alter the input. Example use.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.