smshelper 0.1.3 → 0.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -31,6 +31,7 @@ module Smshelper
31
31
  end
32
32
 
33
33
  class Charset
34
+ include Singleton
34
35
  GSM_CHARSET = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u)
35
36
  ESCAPED_CHARS = "{}\\~[]|€"
36
37
  # Returns +true+ if the supplied text contains only characters from
@@ -1,6 +1,5 @@
1
1
  module Smshelper
2
2
  class Message
3
- #1st sms = 160 chars, 2nd+ = 153 chars.
4
3
  attr_accessor :recipient, :text, :sender
5
4
  attr_reader :utf_8
6
5
 
@@ -8,22 +7,19 @@ module Smshelper
8
7
  @recipient = attributes[:recipient]
9
8
  @text = attributes[:text]
10
9
  @sender = attributes[:sender]
11
- @lt_dl, @lt_al = attributes[:api].detectlanguage_dot_com, attributes[:api].alchemy_language
12
-
13
- (wtf_lang(@text) == (:en || :english)) ? (@utf_8 = false) : (@utf_8 = true)
10
+ is_gsm(@text) ? (@utf_8 = false) : (@utf_8 = true)
14
11
  end
15
12
 
16
- #TODO: Id the language with both APIs, fallback to charset != gsm if api isn't available
17
- def wtf_lang(text)
18
- dl = Smshelper::Languagetools::DetectLanguageDotCom.new @lt_dl
19
- lang = dl.detect text
20
- return lang.to_sym
13
+ def is_gsm(text)
14
+ dl = Smshelper::Languagetools::Charset.instance
15
+ lang = dl.is_gsm(text)
21
16
  end
22
17
 
23
- def to_hex
24
- @text = @text.unpack('U*').collect {|x| sprintf '%02X', x}.join
25
- end
18
+ # def to_hex
19
+ # @text = @text.unpack('U*').collect {|x| sprintf '%02X', x}.join
20
+ # end
26
21
 
22
+ # convert text to UCS-2 BigEndian
27
23
  def to_hex_be
28
24
  @text = @text.unpack('U*').collect {|x| sprintf '%04X', x}.join
29
25
  end
data/smshelper.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "smshelper"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Voip Scout"]
12
- s.date = "2012-03-19"
12
+ s.date = "2012-03-20"
13
13
  s.description = "works with esendex, textmagic, smstrade, bulksms, routomessaging, smswarehouse, mediaburst, clickatell, webtext"
14
14
  s.email = "voipscout@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: smshelper
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.3
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Voip Scout
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-19 00:00:00.000000000Z
12
+ date: 2012-03-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: api_smith