motion-phony 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef81826ab552f0044eacd3541bc5dd7db39817db
4
+ data.tar.gz: e962f43291560a0af3e2a9fb59621fb542134be4
5
+ SHA512:
6
+ metadata.gz: 81775166a9ef4ae313a2e1a4b47e409ce3ece3106e31f6ba8b5f19cd847468e3f704eaeb6d6fbfc53077d5748790e3c9d6dc4201d6cb4b7a79ca23ed026fa5f7
7
+ data.tar.gz: a9226b1c54b620b1a0bc5f825e3d0fb3cb63b0760cf72e2dfca1cb54f76fa253f9f0fb442cf557601bfb359a12d9beda4ccbab92c52db9e59c896010071bf58c
data/.gitignore ADDED
@@ -0,0 +1,33 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ /build
20
+ .repl_history
21
+ .rvmrc
22
+ .ruby-gemset
23
+ .ruby-version
24
+ .DS_Store
25
+ .dat*
26
+ .rake_tasks*
27
+
28
+ # IDE / editor files
29
+ .idea/
30
+ *.tmproj
31
+ *.tmproject
32
+ tmtags
33
+ *.sublime-workspace
data/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Christopher Speer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # README
2
+
3
+ This is a [RubyMotion](http://www.rubymotion.com/) wrapper for the very awesome [Phony gem](https://github.com/floere/phony).
4
+
5
+ ## Usage
6
+ If you are using Bundle, install `motion-phony` via Gemfile:
7
+ ```ruby
8
+ gem 'motion-phony'
9
+ ```
10
+ Otherwise `gem install motion-phony` and `require 'motion-phony`.
11
+
12
+
13
+ ## Contact
14
+ Feel free to shoot me a tweet [@_cspeer](https://twitter.com/_cspeer)
@@ -0,0 +1,94 @@
1
+ # Basically this is just
2
+ # https://github.com/floere/phony/blob/master/lib/phony.rb
3
+ # without the dependencies.
4
+ # Needs regular updates
5
+
6
+ module Phony
7
+
8
+ class NormalizationError < StandardError
9
+ def initialize
10
+ super %Q{Phony could not normalize the given number. Is it a phone number?}
11
+ end
12
+ end
13
+
14
+ # Phony uses a single country codes instance.
15
+ #
16
+ @codes = CountryCodes.instance
17
+
18
+ class << self
19
+
20
+ # Get the Country for the given CC.
21
+ #
22
+ # Example:
23
+ # us = Phony['1']
24
+ # normalized_number = us.normalize number
25
+ #
26
+ def [] cc
27
+ @codes[cc]
28
+ end
29
+
30
+ # Normalizes the given number.
31
+ #
32
+ # Useful before inserting the number into a database.
33
+ #
34
+ def normalize phone_number, options = {}
35
+ raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.normalize(number)." unless phone_number
36
+ normalize! phone_number.dup, options
37
+ end
38
+ def normalize! phone_number, options = {}
39
+ @codes.normalize phone_number, options
40
+ rescue
41
+ raise NormalizationError.new
42
+ end
43
+
44
+ # Splits the phone number into pieces according to the country codes.
45
+ #
46
+ def split phone_number
47
+ raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.split(number)." unless phone_number
48
+ split! phone_number.dup
49
+ end
50
+ def split! phone_number
51
+ parts = @codes.split phone_number
52
+ parts.delete_at 1
53
+ parts
54
+ end
55
+
56
+ # Formats a E164 number according to local customs.
57
+ #
58
+ def format phone_number, options = {}
59
+ raise ArgumentError, "Phone number cannot be nil. Use e.g. number && Phony.format(number)." unless phone_number
60
+ format! phone_number.dup, options
61
+ end
62
+ def format! phone_number, options = {}
63
+ @codes.format phone_number, options
64
+ end
65
+ alias formatted format
66
+ alias formatted! format!
67
+
68
+ # Makes a plausibility check.
69
+ #
70
+ # If it returns false, it is not plausible.
71
+ # If it returns true, it is unclear whether it is plausible,
72
+ # leaning towards being plausible.
73
+ #
74
+ def plausible? number, hints = {}
75
+ @codes.plausible? number, hints
76
+ end
77
+
78
+ # Returns true if there is a character in the number
79
+ # after the first four numbers.
80
+ #
81
+ def vanity? phone_number
82
+ @codes.vanity? phone_number.dup
83
+ end
84
+
85
+ # Converts any character in the vanity_number to its numeric representation.
86
+ # Does not check if the passed number is a valid vanity_number, simply does replacement.
87
+ #
88
+ def vanity_to_number vanity_number
89
+ @codes.vanity_to_number vanity_number.dup
90
+ end
91
+
92
+ end
93
+
94
+ end
@@ -0,0 +1,64 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise 'This file must be required within a RubyMotion project Rakefile.'
3
+ end
4
+
5
+
6
+ require 'motion-require'
7
+
8
+ # respect the order!
9
+ files = [
10
+ 'vanity',
11
+ 'local_splitters/fixed',
12
+ 'local_splitters/regex',
13
+ 'national_splitters/dsl',
14
+ 'national_splitters/fixed',
15
+ 'national_splitters/variable',
16
+ 'national_splitters/regex',
17
+ 'national_splitters/default',
18
+ 'national_splitters/none',
19
+ 'national_code',
20
+ 'country',
21
+ 'trunk_code',
22
+ 'country_codes',
23
+ 'dsl',
24
+ 'countries/austria',
25
+ 'countries/bangladesh',
26
+ 'countries/belarus',
27
+ 'countries/brazil',
28
+ 'countries/cambodia',
29
+ 'countries/china',
30
+ 'countries/georgia',
31
+ 'countries/germany',
32
+ 'countries/india',
33
+ 'countries/indonesia',
34
+ 'countries/ireland',
35
+ 'countries/italy',
36
+ 'countries/japan',
37
+ 'countries/kyrgyzstan',
38
+ 'countries/latvia',
39
+ 'countries/libya',
40
+ 'countries/malaysia',
41
+ 'countries/moldova',
42
+ 'countries/montenegro',
43
+ 'countries/namibia',
44
+ 'countries/nepal',
45
+ 'countries/netherlands',
46
+ 'countries/pakistan',
47
+ 'countries/paraguay',
48
+ 'countries/russia_kazakhstan_abkhasia_south_ossetia',
49
+ 'countries/serbia',
50
+ 'countries/somalia',
51
+ 'countries/south_korea',
52
+ 'countries/sweden',
53
+ 'countries/taiwan',
54
+ 'countries/tajikistan',
55
+ 'countries/turkmenistan',
56
+ 'countries/ukraine',
57
+ 'countries/united_kingdom',
58
+ 'countries/uruguay',
59
+ 'countries/zimbabwe',
60
+ 'countries'
61
+ ].map { |file| "#{Gem.loaded_specs['phony'].full_gem_path}/lib/phony/#{file}.rb" }
62
+
63
+ Motion::Require.all(files)
64
+ Motion::Require.all(Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'motion-phony/*.rb')))
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'motion-phony'
3
+ spec.version = '0.0.2'
4
+ spec.license = 'MIT'
5
+
6
+ spec.authors = ['Christopher Speer']
7
+ spec.email = ['cspeer@maxdufa.com']
8
+ spec.description = 'A RubyMotion wrapper around the awesome Phony gem'
9
+ spec.summary = 'A RubyMotion wrapper around the awesome Phony gem'
10
+ spec.homepage = 'https://github.com/cspeer/motion-phony'
11
+
12
+ spec.files = `git ls-files`.split($\)
13
+ spec.require_paths = ['lib']
14
+
15
+ spec.add_dependency 'phony', '~> 2.2.4'
16
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-phony
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Speer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: phony
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.4
27
+ description: A RubyMotion wrapper around the awesome Phony gem
28
+ email:
29
+ - cspeer@maxdufa.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - LICENSE.md
36
+ - README.md
37
+ - lib/motion-phony.rb
38
+ - lib/motion-phony/phony-base.rb
39
+ - motion-phony.gemspec
40
+ homepage: https://github.com/cspeer/motion-phony
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.1.11
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: A RubyMotion wrapper around the awesome Phony gem
64
+ test_files: []