Giter Site home page Giter Site logo

global_phone's Introduction

GlobalPhone

GlobalPhone parses, validates, and formats local and international phone numbers according to the E.164 standard.

Store and display phone numbers in your app. Accept phone number input in national or international format. Convert phone numbers to international strings (+13125551212) for storage and retrieval. Present numbers in national format ((312) 555-1212) in your UI.

Designed with the future in mind. GlobalPhone uses format specifications from Google's open-source libphonenumber database. No need to upgrade the library when a new phone format is introduced—just generate a new copy of the database and check it into your app.

Pure Ruby. No dependencies. GlobalPhone is designed for Ruby 1.9.3 and up. (Works in 1.8.7, too—just bring your own json gem.)

Installation

  1. Add the global_phone gem to your app. For example, using Bundler:

     $ echo "gem 'global_phone'" >> Gemfile
     $ bundle install
    
  2. Use global_phone_dbgen to convert Google's libphonenumber PhoneNumberMetaData.xml file into a JSON database for GlobalPhone.

     $ gem install global_phone_dbgen
     $ global_phone_dbgen > db/global_phone.json
    
  3. Tell GlobalPhone where to find the database. For example, in a Rails app, create an initializer in config/initializers/global_phone.rb:

    require 'global_phone'
    GlobalPhone.db_path = Rails.root.join('db/global_phone.json')

Examples

Parse an international number string into a GlobalPhone::Number object:

number = GlobalPhone.parse('+1-312-555-1212')
# => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="3125551212">

Query the country code and likely territory name of the number:

number.country_code
# => "1"

number.territory.name
# => "US"

Present the number in national and international formats:

number.national_format
# => "(312) 555-1212"

number.international_format
# => "+1 312-555-1212"

Is the number valid? (Note: this is not definitive. For example, the number here is "valid" by format, but there are no US numbers that start with 555. The valid? method may return false positives, but should not return false negatives unless the database is out of date.)

number.valid?
# => true

Get the number's normalized E.164 international string:

number.international_string
# => "+13125551212"

Parse a number in national format for a given territory:

number = GlobalPhone.parse("(0) 20-7031-3000", :gb)
# => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=44 name=GB> national_string="2070313000">

Parse an international number using a territory's international dialing prefix:

number = GlobalPhone.parse("00 1 3125551212", :gb)
# => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="3125551212">

Set the default territory to Great Britain (territory names are ISO 3166-1 Alpha-2 codes):

GlobalPhone.default_territory_name = :gb
# => :gb

GlobalPhone.parse("(0) 20-7031-3000")
# => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=44 name=GB> national_string="2070313000">

Shortcuts for validating a phone number:

GlobalPhone.validate("+1 312-555-1212")
# => true

GlobalPhone.validate("+442070313000")
# => true

GlobalPhone.validate("(0) 20-7031-3000")
# => false

GlobalPhone.validate("(0) 20-7031-3000", :gb)
# => true

Shortcuts for normalizing a phone number in E.164 format:

GlobalPhone.normalize("(312) 555-1212")
# => "+13125551212"

GlobalPhone.normalize("+442070313000")
# => "+442070313000"

GlobalPhone.normalize("(0) 20-7031-3000")
# => nil

GlobalPhone.normalize("(0) 20-7031-3000", :gb)
# => "+442070313000"

Caveats

GlobalPhone currently does not parse emergency numbers or SMS short code numbers.

Validation is not definitive and may return false positives, but should not return false negatives unless the database is out of date.

Territory heuristics are imprecise. Parsing a number will usually result in the territory being set to the primary territory of the region. For example, Canadian numbers will be parsed with a territory of US. (In most cases this does not matter, but if your application needs to perform geolocation using phone numbers, GlobalPhone may not be a good fit.)

Development

The GlobalPhone source code is hosted on GitHub. You can check out a copy of the latest code using Git:

$ git clone https://github.com/sstephenson/global_phone.git

If you've found a bug or have a question, please open an issue on the issue tracker. Or, clone the GlobalPhone repository, write a failing test case, fix the bug, and submit a pull request.

GlobalPhone is heavily inspired by Andreas Gal's PhoneNumber.js library.

Version History

1.0.1 (May 29, 2013)

  • GlobalPhone::Number#to_s returns the E.164 international string.
  • Ensure GlobalPhone::Number always returns strings for #national_format, #international_format, and #international_string, regardless of validity.
  • Relax format restrictions to more loosely match available national number patterns.

1.0.0 (May 28, 2013)

  • Initial public release.

License

Copyright © 2013 Sam Stephenson

Released under the MIT license. See LICENSE for details.

global_phone's People

Contributors

abookyun avatar apuratepp avatar bwilkins avatar cgunther avatar eileencodes avatar josh avatar sstephenson 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  avatar

global_phone's Issues

Unable to Parse Twilio strange number

I have a twilio strange numbers in a hash and i need to check the incoming numbers against it.

TWILIO Strange Numbers

In that, i could parse and check for equality for the UNKNOWN,BLOCKED & RESTRICTED by using the below code,

GlobalPhone.parse(twilio_strange_num).international_format == GlobalPhone.parse(incoming_number).international_format

The above condition is not working for ANONYMOUS Number 266696687 alone.
EMPTY number im handling seperately.

Please help me out and Suggest any other better approach to do this.

leadingDigits dbgen - busted

There's a fairly serious bug in the db generator. Some of the elements have multiple children. When nodes.text is called in text_or_nil they end up getting concatenated together, which obviously isn't correct. See Korea (KR) for an example. I don't have the full pull request but you can fix this by adding something like this to database_generator.rb:

      def leadingDigits(node)
        nodes = node.search("leadingDigits")
        case nodes.length
        when 0 # nop
        when 1
          nodes.text
        else
          nodes.map { |i| "(?:#{i.text)})" }.join("|")
        end
      end

Not sure if this is the fix you're looking for, but it's definitely an issue. I'm happy to put together a full pull request if there's interest in this fix.

Incorrect validation of Russian numbers

I'm not sure if this is an error in the nationalNumberPattern node of the libphonenumber metadata, or if it has to do with global phone's parsing of the data, but the compiled territory data for Russia does not seem to allow for area codes starting with 7.

  [
    "7",
    [
      [
        "(\\d{3})(\\d{2})(\\d{2})",
        "$1-$2-$3",
        "[1-79]",
        "$FG",
        "NA"
      ],
      [
        "([3489]\\d{2})(\\d{3})(\\d{2})(\\d{2})",
        "$1 $2-$3-$4",
        "[34689]"
      ],
      [
        "(7\\d{2})(\\d{3})(\\d{4})",
        "$1 $2 $3",
        "7"
      ]
    ],
    [
      [
        "RU",
        "\\d{10}",
        "[3489]\\d{9}",
        "$NP($FG)"
      ],
      [
        "KZ",
        "\\d{10}",
        "(?:33\\d|7\\d{2}|80[09])\\d{7}"
      ]
    ],
    "810",
    "8"
  ]

I'm looking at switching our phone number validation to global phone, but I have a few Russian phone numbers in our DB with area codes 705, 701, and 777. A bit of Googling suggests that these are valid numbers and Twilio has has no issue sending to them.

If this is a libphonenumber issue, I can open an issue there.

/cc @josh

Release new version of gem for global_phone_dbgen

Hi guys, this commit changes the remote URL.

Commit 7030736

I just installed the gem, bumped into the 404 and took a while to fix the issue.

Wanted to do a PR to help future users but realised it's already done.

Would be nice if you realise a bump for rubygems, so new users don't bump into this problem.

Parsing Phone Numbers from Argentina

Firstly, thank you for great library, we use it actively at work to parse phone numbers.

There seems to be an issue with parsing phone numbers from Argentina.

Given a number, +54 11 4799 9350, it should be formatted as +54 11 4799-9350.

GlobalPhone.parse("+54 11 4799 9350") # +54 9 11 4799-9350

The extra 9 breaks the number because it is only supposed to be prefixed in front of mobile numbers. (Wikipedia)[http://en.wikipedia.org/wiki/Telephone_numbers_in_Argentina]

I generated the the JSON file just today, supposed it's not because of libphonenumber and also, Google's Javascript Demo returns the right number.

Would love to help if we can confirm this is some form of bug some pointers of where it might have gone wrong. It seems like the 9 is added in the method apply_national_prefix_format

doesn't parse numbers with extensions?

2.0.0-p247 :013 > GlobalPhone.parse('(201) 482-4764x1234')
=> nil
2.0.0-p247 :014 > GlobalPhone.parse('+12014824764x1234')
=> nil
2.0.0-p247 :015 > GlobalPhone.parse('+12014824764 ext. 1234')
=> nil

recognizing Vatican, Kosovo, etc.

I realize that GlobalPhone seems to be more focused on formatting than lookup of number to country code, but it seems that it ignores info that has, for instance the "exception" for the Vatican it clearly knows about, but doesn't return. (Similar things would be for Kosovo and some other places)

2.1.5 :014 > number = GlobalPhone.parse('+390669822222')
 => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=39 name=IT> national_string="0669822222"> 
2.1.5 :015 > number.territory 
 => #<GlobalPhone::Territory country_code=39 name=IT> 
2.1.5 :016 > number.region   
 => #<GlobalPhone::Region country_code=39 territories=[IT,VA]> 
2.1.5 :017 > 

I think it ought to return name=VA for this, since clearly it knows about VA's use of an IT prefix.
I could write a test and fix this, but maybe it's not important enough for others. https://github.com/hemligabyran/calling_codes probably satisfies my needs, except I worry about it getting out of date.

global_phone_dbgen --test doesn't always generate valid phone numbers

An easy way to see this error happening is adding to this test case the following assertion (since its fixture was generated by global_phone_dbgen --test):

assert number.valid?, "expected #{string} be valid for territory #{territory_name}"

And looks like this error is happening because for some country codes the phone formats are missing.

I'm hoping to use the generated list of phones as fixture to my tests, but it would need to always have valid phone numbers generated.

Country Code for Cameroon

Hello,

I am facing Country code issue of Cameroon.
In past Cameroon has 237 Country code.
But in 2014 cameroon has added 6 after Country Code 237-6.

so now your API fails when check for Cameroon Phone Number.

number = GlobalPhone.parse('+237-6-95-22-95-11')
nil
number = GlobalPhone.parse('+237-95-22-95-11')
#<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=237 name=CM> national_string="95229511">
**

Can anyone please Guide in this matter?

Parse e164 numbers

Right now if you try and run the parse method on a e164 number you get null. It would be helpful to be able to get the territory information from e164 numbers.

Segfault trying to execute global_phone_dbgen > db/global_phone.json

global_phone_dbgen > db/global_phone.json
/Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb:67: [BUG] Segmentation fault at 0x00000000000018
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]

-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.

-- Control frame information -----------------------------------------------
c:0019 p:---- s:0089 e:000088 CFUNC :initialize
c:0018 p:---- s:0087 e:000086 CFUNC :new
c:0017 p:0075 s:0084 e:000081 METHOD /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb:67
c:0016 p:0070 s:0073 e:000071 CLASS /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:17
c:0015 p:0011 s:0070 e:000069 CLASS /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:12
c:0014 p:0056 s:0068 e:000067 TOP /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:9 [FINISH]
c:0013 p:---- s:0066 e:000065 CFUNC :require
c:0012 p:0113 s:0062 e:000061 METHOD /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
c:0011 p:0019 s:0052 e:000051 CLASS /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json.rb:58
c:0010 p:0017 s:0050 e:000049 TOP /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json.rb:54 [FINISH]
c:0009 p:---- s:0048 e:000047 CFUNC :require
c:0008 p:0113 s:0044 e:000043 METHOD /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
c:0007 p:0007 s:0034 e:000033 TOP /Users/herbyraynaud/.gem/gems/global_phone_dbgen-1.0.0/lib/global_phone/database_generator.rb:1 [FINISH]
c:0006 p:---- s:0032 e:000031 CFUNC :require
c:0005 p:0113 s:0028 e:000027 METHOD /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54
c:0004 p:0007 s:0018 e:000017 TOP /Users/herbyraynaud/.gem/gems/global_phone_dbgen-1.0.0/bin/global_phone_dbgen:2 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :load
c:0002 p:0135 s:0006 E:002700 EVAL /Users/herbyraynaud/.gem/bin/global_phone_dbgen:23 [FINISH]
c:0001 p:0000 s:0002 E:002470 TOP [FINISH]

-- Ruby level backtrace information ----------------------------------------
/Users/herbyraynaud/.gem/bin/global_phone_dbgen:23:in <main>' /Users/herbyraynaud/.gem/bin/global_phone_dbgen:23:inload'
/Users/herbyraynaud/.gem/gems/global_phone_dbgen-1.0.0/bin/global_phone_dbgen:2:in <top (required)>' /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
/Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' /Users/herbyraynaud/.gem/gems/global_phone_dbgen-1.0.0/lib/global_phone/database_generator.rb:1:in<top (required)>'
/Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
/Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json.rb:54:in <top (required)>' /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json.rb:58:inmodule:JSON'
/Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in require' /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'
/Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:9:in <top (required)>' /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:12:inmodule:JSON'
/Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext.rb:17:in <module:Ext>' /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb:67:ingenerator='
/Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb:67:in new' /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb:67:ininitialize'

-- Machine register context ------------------------------------------------
rax: 0x0000000000000008 rbx: 0x0000000000000008 rcx: 0x0000000000000008
rdx: 0x00007f9672c2d330 rdi: 0x0000000000000008 rsi: 0x0000000000a8110e
rbp: 0x00007fff5e3db830 rsp: 0x00007fff5e3db810 r8: 0x0000000000000001
r9: 0x0000000000000400 r10: 0x0000000000007000 r11: 0x0000000101890b90
r12: 0x0000000000000008 r13: 0x00007f967408c890 r14: 0x0000000000a8110e
r15: 0x00007f9672e4e8f0 rip: 0x0000000101890ba1 rfl: 0x0000000000010202

-- C level backtrace information -------------------------------------------
0 ruby 0x00000001019bcdfb rb_vm_bugreport + 155
1 ruby 0x00000001018613e0 rb_bug_context + 480
2 ruby 0x0000000101939743 sigsegv + 83
3 libsystem_platform.dylib 0x00007fff925b5f1a _sigtramp + 26
4 ruby 0x0000000101890ba1 rb_hash_aref + 17
5 ??? 0x0000000000a8110e 0x0 + 11014414

-- Other runtime information -----------------------------------------------

  • Loaded script: /Users/herbyraynaud/.gem/bin/global_phone_dbgen

  • Loaded features:

    0 enumerator.so
    1 rational.so
    2 complex.so
    3 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/encdb.bundle
    4 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/trans/transdb.bundle
    5 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/unicode_normalize.rb
    6 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/rbconfig.rb
    7 thread.rb
    8 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/thread.bundle
    9 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/compatibility.rb
    10 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/defaults.rb
    11 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/deprecate.rb
    12 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/errors.rb
    13 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/version.rb
    14 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/requirement.rb
    15 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/platform.rb
    16 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/basic_specification.rb
    17 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/stub_specification.rb
    18 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/util/stringio.rb
    19 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/specification.rb
    20 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/exceptions.rb
    21 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb
    22 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/monitor.rb
    23 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb
    24 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems.rb
    25 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/dependency.rb
    26 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/path_support.rb
    27 /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/version.rb
    28 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/ostruct.rb
    29 /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/generic_object.rb
    30 /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/common.rb
    31 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/utf_16be.bundle
    32 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/utf_16le.bundle
    33 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/utf_32be.bundle
    34 /Users/herbyraynaud/.rbenv/versions/2.2.1/lib/ruby/2.2.0/x86_64-darwin14/enc/utf_32le.bundle
    35 /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext/parser.bundle
    36 /Users/herbyraynaud/.gem/gems/json-1.8.2/lib/json/ext/generator.bundle

Seven character strings come back as a valid number?

2.2.0 :016 > number = GlobalPhone.parse "aaaaaaa"
 => #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="2222222"> 

That is deeply weird. Anyone know why or have a fix?

Local phone number formatting issue

The national_format returns wrong results in many cases:

GlobalPhone.parse('+4372762580').national_format
=> "0727  62580"

(correct: 07276 2580)

GlobalPhone.parse('+49907896890').national_format
=> "090  7896890"

(correct: 09078 96890)

I think that the problem is not caused by wrong rules in the DB since libPhoneNumber-iOS yields correct results.

404 Not Found (OpenURI::HTTPError)

I have just installed you gem and when I try the global_phone_dbgen command I get this 404 error.

I saw in a previous issue that it could be simply due to a bad URL, what should I do?

validate is returning nil instead of false

I just installed the gem and noticed that one of the examples in the wiki does not work as expected.

GlobalPhone.validate("(0) 20-7031-3000") should return false but it's returning nil

GlobalPhone::Number.to_json throws CircularReferenceError

Calling .to_json on a GlobalPhone::Number throws a CircularReferenceError. This is in Rails v4.0.5 with Ruby v.1.9.3.

1.9.3-p547 :001 > number = GlobalPhone.parse("6541238888")
=> #<GlobalPhone::Number territory=#<GlobalPhone::Territory country_code=1 name=US> national_string="6541238888">
1.9.3-p547 :002 > number.to_json
ActiveSupport::JSON::Encoding::CircularReferenceError: object references itself
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:79:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:ineach'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inencode_json'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:inmap'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:275:in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:inblock in encode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in block in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:ineach'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in map' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inencode_json'
... 9 levels...
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:in encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inblock in encode_json'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in each' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:inmap'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:306:in encode_json' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:51:inblock in encode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:81:in check_for_circular_references' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:49:inencode'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/json/encoding.rb:34:in encode' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.0.5/lib/active_support/core_ext/object/to_json.rb:16:into_json'
from (irb):2
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:90:in start' from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands/console.rb:9:instart'
from /Users/chris/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.0.5/lib/rails/commands.rb:62:in <top (required)>' from bin/rails:4:inrequire'
from bin/rails:4:in `

'1.9.3-p547

New gem version?

Hi, I see there's been a few commits by @eileencodes over the last two months. Mighty thanks for that!

Is there any plans to release a new version after these changes? It actually fixes an issue we had and we're pointing to master branch now, but I imagine we want to help to get a new version released.

Thanks.

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.