smpp_encoding 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smpp_encoding.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ require 'gsm_encoder'
2
+
3
+ module SmppEncoding
4
+ class Encoder
5
+
6
+ # currently support only GSM and UNICODE
7
+ ENCODING_GSM = 0
8
+ ENCODING_UNICODE = 8
9
+
10
+ def auto_encode message
11
+ if GSMEncoder.can_encode?(message)
12
+ {
13
+ data_coding: ENCODING_GSM,
14
+ payload: encode(ENCODING_GSM, message)
15
+ }
16
+ else
17
+ {
18
+ data_coding: ENCODING_UNICODE,
19
+ payload: encode(ENCODING_UNICODE, message)
20
+ }
21
+ end
22
+ end
23
+
24
+ def encode encoding, message
25
+ if (encoding < 2)
26
+ GSMEncoder.encode(message)
27
+ else
28
+ message.encode('UTF-16BE').force_encoding('binary')
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module SmppEncoding
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "smpp_encoding/version"
2
+
3
+ module SmppEncoding
4
+ autoload :Encoder, 'smpp_encoding/encoder'
5
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/smpp_encoding/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["yury"]
6
+ gem.email = ["yury.korolev@gmail.com"]
7
+ gem.description = %q{Encodings for ruby-smpp gem}
8
+ gem.summary = %q{Supports auto encoding messages to GSM and UNICODE}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "smpp_encoding"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SmppEncoding::VERSION
17
+
18
+ gem.add_dependency "gsm_encoder", "~> 0.1.0"
19
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smpp_encoding
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - yury
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gsm_encoder
16
+ requirement: &70093431418100 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70093431418100
25
+ description: Encodings for ruby-smpp gem
26
+ email:
27
+ - yury.korolev@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - lib/smpp_encoding.rb
36
+ - lib/smpp_encoding/encoder.rb
37
+ - lib/smpp_encoding/version.rb
38
+ - smpp_encoding.gemspec
39
+ homepage: ''
40
+ licenses: []
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 1.8.11
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: Supports auto encoding messages to GSM and UNICODE
63
+ test_files: []