ascii 1.0.0 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de00874c10e2bac1a66459de4642f2cfd6db4771
4
- data.tar.gz: 45fe9d761524d391f55cf4c136673e321283c0d3
3
+ metadata.gz: 2aea619f9906a262e98683d34465cf75ece8b157
4
+ data.tar.gz: 69005d73fba88557d4a779370a3cd2f02f48bcc5
5
5
  SHA512:
6
- metadata.gz: b0676d7fc88c5cd68730e243331a295ed1844dd83b8a3e6ab4fc18866a70f5fb8d0722e71fd7af4d2b5e76f5600ca3fbda30bc36a627903abc0cee40732c6c04
7
- data.tar.gz: bb03f51c1e2eddc217a3f9d9d47350ad20f65ddc7d9418a9012e2fc338e8662931cfc4b0cb672b2c6c4298ace0ca15b8626e9d15a884a56e1aea4697da1145e1
6
+ metadata.gz: 86eaab94b5547624220da024e477820d1e4dee093fc5e32d3c9fc48bc02b8585f45a58a9f6b199845a96a3169ddaf39c8ad53e5934fc3f4c875fe5f3a7c73e73
7
+ data.tar.gz: dc8a3e2e76eac549bfdf11424ef3389b26de3bd972e3f0511ffe5e35a20964c69ab6eb5c8ed1ed466394931049872748b408408cb29b40cac15333ff27af3f9b
data/README.md CHANGED
@@ -1,10 +1,7 @@
1
1
  # Ascii
2
- [![Gem Version](https://img.shields.io/gem/v/ascii.svg)][gem]
3
- [![Build Status](https://img.shields.io/travis/rwz/ascii.svg)][travis]
4
- [![Code Climate](https://img.shields.io/codeclimate/github/rwz/ascii.svg)][codeclimate]
5
- [gem]: https://rubygems.org/gems/ascii
6
- [travis]: http://travis-ci.org/rwz/ascii
7
- [codeclimate]: https://codeclimate.com/github/rwz/ascii
2
+ [![Gem Version](https://img.shields.io/gem/v/ascii.svg)](https://rubygems.org/gems/ascii)
3
+ [![Build Status](https://img.shields.io/travis/rwz/ascii.svg)](http://travis-ci.org/rwz/ascii)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/rwz/ascii.svg)](https://codeclimate.com/github/rwz/ascii)
8
5
 
9
6
  This library provides method to transliterate Unicode characters to an ASCII
10
7
  approximation.
@@ -1,9 +1,16 @@
1
1
  require "ascii/unidecoder"
2
2
  require "ascii/version"
3
3
 
4
+ # The main module of the gem, exposes only <tt>process</tt> method.
5
+ # Can be mixed into other classes.
4
6
  module Ascii
5
7
  extend self
6
8
 
9
+ # Generates the approximate ASCII repsentation of the given
10
+ # string
11
+ #
12
+ # @param str [String] The string you want to approximate
13
+ # @return [String] The ASCII approximation of the input string
7
14
  def process(str)
8
15
  Unidecoder.new(str).to_ascii
9
16
  end
@@ -1,24 +1,30 @@
1
1
  require "yaml"
2
2
 
3
3
  module Ascii
4
+
5
+ # The class responsible for translating a Unicode char to its ASCII
6
+ # representation
4
7
  class Codepoint
8
+ # @return [Integer] the code of the unicode character
5
9
  attr_reader :code
6
10
 
7
- GROUPS = Hash.new do |hash, group_name|
8
- filename = File.expand_path("../../../data/#{group_name}.yml", __FILE__)
9
- hash[name] = YAML.load_file(filename)
10
- end
11
-
11
+ # @param char [String] the unicode char
12
12
  def initialize(char)
13
13
  @code = char.unpack("U").first
14
14
  end
15
15
 
16
+ # @return [String] an ASCII representation of input
16
17
  def decode
17
18
  group.at(group_index)
18
19
  end
19
20
 
20
21
  private
21
22
 
23
+ GROUPS = Hash.new do |hash, group_name|
24
+ filename = File.expand_path("../../../data/#{group_name}.yml", __FILE__)
25
+ hash[name] = YAML.load_file(filename)
26
+ end
27
+
22
28
  def group
23
29
  GROUPS[group_name]
24
30
  end
@@ -1,13 +1,20 @@
1
1
  require "ascii/codepoint"
2
2
 
3
3
  module Ascii
4
+
5
+ # The class resposible for generating ASCII representation of the
6
+ # given string
4
7
  class Unidecoder
5
8
  attr_reader :input
6
9
 
10
+ # @param input [String] string to process
7
11
  def initialize(input)
8
12
  @input = input.to_s
9
13
  end
10
14
 
15
+ # Processes input string and returns ASCII
16
+ #
17
+ # @return [String] An ASCII approximation of input string
11
18
  def to_ascii
12
19
  input.gsub(/[^\x00-\x7f]/u, &method(:decode)).strip
13
20
  end
@@ -1,3 +1,3 @@
1
1
  module Ascii
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ascii
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-14 00:00:00.000000000 Z
11
+ date: 2014-03-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This library provides methods to transliterate Unicode characters to
14
14
  an ASCII approximation
@@ -238,3 +238,4 @@ summary: Create an ASCII representation of localized string
238
238
  test_files:
239
239
  - spec/ascii_spec.rb
240
240
  - spec/spec_helper.rb
241
+ has_rdoc: