# Generated from sms_validation-0.0.2.gem by gem2rpm -*- rpm-spec -*- %global gem_name sms_validation Name: rubygem-%{gem_name} Version: 0.0.2 Release: 1%{?dist} Summary: # SmsValidation This gem does not send SMS messages. It just makes sure the arguments are valid. ## What are valid arguments for an SMS message? - Phone number: 10 digits, does not begin with 0 or 1 - Message: Not longer than 160 characters. ## What if my message is longer than 160 characters? You have 3 choices: - Truncate the message to the first 160 characters - Split it into multiple messages - Raise a SmsValidation::Sms::MessageTooLongError error You can configure at any time using: SmsValidation.configuration.on_message_too_long = :truncate # or :split or :raise_error It defaults to :raise_error ## Installation Add this line to your application's Gemfile: ```ruby gem 'sms_validation' ``` And then execute: $ bundle Or install it yourself as: $ gem install sms_validation ## Usage ### Configuration SmsValidation.configure do |config| config.on_message_too_long = :truncate # or :split or :raise_error config.logger = ::Logger.new(STDOUT) # Defaults to ::Rails.logger if ::Rails.logger is defined # This DOES NOT change the log_level of the logger--use `config.logger.level = :debug` for that # This DOES determine the log level at which messages should be logged. # This provides a convenient way to toggle whether this gem should log without interfering with the log level of others processes sharing the logger. # For instance, if you're using Rails, you probably don't want to set the log_level to DEBUG, because then ActiveRecord will log every query. # But you may still want SmsValidation to log everything it does. config.log_at :info # OR you may want SmsValidation to log only when you're logging all other DEBUG messages. config.log_at :debug end ### Validation sms = SmsValidation::Sms.new(8889999999, "The quick brown fox jumps over the lazy dog") puts sms.phone # => 8889999999 puts sms.message # => "The quick brown fox jumps over the lazy dog" sms = SmsValidation::Sms.new(889999999, "The quick brown fox jumps over the lazy dog") # => SmsValidation::Sms::InvalidPhoneNumberError: "Phone number must be ten digits" SmsValidation.configuration.on_message_too_long = :split sms = SmsValidation::Sms.new(8889999999, "The quick brown fox jumps over the lazy dog" * 4) puts sms.phone # => 8889999999 puts sms.messages # => ["(MSG 1/2): The quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dogThe quick brown ", "(MSG 2/2): fox jumps over the lazy dog"] SmsValidation.configuration.on_message_too_long = :truncate sms = SmsValidation::Sms.new(8889999999, "The quick brown fox jumps over the lazy dog" * 4) puts sms.phone # => 8889999999 puts sms.message # => ["The quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dogThe quick brown fox jumps over the lazy dogThe quick brown fox jumps over "] SmsValidation.configuration.on_message_too_long = :raise_error sms = SmsValidation::Sms.new(8889999999, "The quick brown fox jumps over the lazy dog" * 4) # => SmsValidation::Sms::MessageTooLongError, "Message cannot be longer than 160 characters" ## Contributing 1. Fork it ( https://github.com/[my-github-username]/sms_validation/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request License: MIT URL: https://github.com/betesh/sms_validation/ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem BuildRequires: ruby(release) BuildRequires: rubygems-devel BuildRequires: ruby # BuildRequires: rubygem(rspec) BuildArch: noarch %description Validate the phone number and content of an SMS Message. This gem does not send SMS messages. It just makes sure the arguments are valid. %package doc Summary: Documentation for %{name} Requires: %{name} = %{version}-%{release} BuildArch: noarch %description doc Documentation for %{name}. %prep %setup -q -n %{gem_name}-%{version} %build # Create the gem as gem install only works on a gem file gem build ../%{gem_name}-%{version}.gemspec # %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir # by default, so that we can move it into the buildroot in %%install %gem_install %install mkdir -p %{buildroot}%{gem_dir} cp -a .%{gem_dir}/* \ %{buildroot}%{gem_dir}/ %check pushd .%{gem_instdir} # rspec spec popd %files %dir %{gem_instdir} %exclude %{gem_instdir}/.gitignore %license %{gem_instdir}/LICENSE.txt %{gem_libdir} %exclude %{gem_cache} %{gem_spec} %files doc %doc %{gem_docdir} %exclude %{gem_instdir}/.rspec %{gem_instdir}/Gemfile %doc %{gem_instdir}/README.md %{gem_instdir}/Rakefile %{gem_instdir}/sms_validation.gemspec %{gem_instdir}/spec %changelog * Wed Sep 15 2021 mockbuilder - 0.0.2-1 - Initial package