langtastic 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +9 -0
- data/bin/langtastic +10 -0
- data/langtastic.gemspec +27 -0
- data/lib/langtastic.rb +40 -0
- data/lib/langtastic/version.rb +3 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 824898b9c3487e9a76beef6dad3f46b1af81d715
|
4
|
+
data.tar.gz: 781a10c7acb76c4092cf0df2ab60d4cddf4f6494
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a44f9c163bf49e84f7b95f455708b166ce907d755847708e06baa09e772d57216cc49e9b013b8a2792a760661088050acf3600d1c0c490e730d141590c01193
|
7
|
+
data.tar.gz: 3d308a89e2fabdbff69ee8772a2c4ec07ec79329bc18a42ebb6c997f3f9f5f7d584c6e3ec58459e80e3e116a621e1ebec29ad46dee707ce9163a7049310f865e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ed Robinson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Langtastic
|
2
|
+
|
3
|
+
Reads data language subtag data from the iana.org language subtag registry and
|
4
|
+
parses it into a somewhat usable form.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'langtastic'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install langtastic
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'langtastic'
|
26
|
+
Langtastic.subtags
|
27
|
+
=> [{"File-Date"=>"2015-05-12"},
|
28
|
+
{"Type"=>"language", "Subtag"=>"aa", "Description"=>"Afar", "Added"=>"2005-10-16"},
|
29
|
+
{"Type"=>"language", "Subtag"=>"ab", "Description"=>"Abkhazian", "Added"=>"2005-10-16", "Suppress-Script"=>"Cyrl"},
|
30
|
+
{"Type"=>"language", "Subtag"=>"ae", "Description"=>"Avestan", "Added"=>"2005-10-16"},
|
31
|
+
{"Type"=>"language", "Subtag"=>"af", "Description"=>"Afrikaans", "Added"=>"2005-10-16", "Suppress-Script"=>"Latn"},
|
32
|
+
{"Type"=>"language", "Subtag"=>"ak", "Description"=>"Akan", "Added"=>"2005-10-16", "Scope"=>"macrolanguage"},
|
33
|
+
{"Type"=>"language", "Subtag"=>"am", "Description"=>"Amharic", "Added"=>"2005-10-16", "Suppress-Script"=>"Ethi"},
|
34
|
+
{"Type"=>"language", "Subtag"=>"an", "Description"=>"Aragonese", "Added"=>"2005-10-16"},
|
35
|
+
...,
|
36
|
+
{"Type"=>"region", "Subtag"=>"AA", "Description"=>"Private use", "Added"=>"2005-10-16"},
|
37
|
+
{"Type"=>"region", "Subtag"=>"AC", "Description"=>"Ascension Island", "Added"=>"2009-07-29"},
|
38
|
+
{"Type"=>"region", "Subtag"=>"AD", "Description"=>"Andorra", "Added"=>"2005-10-16"},
|
39
|
+
{"Type"=>"region", "Subtag"=>"AE", "Description"=>"United Arab Emirates", "Added"=>"2005-10-16"},
|
40
|
+
{"Type"=>"region", "Subtag"=>"AF", "Description"=>"Afghanistan", "Added"=>"2005-10-16"},
|
41
|
+
{"Type"=>"region", "Subtag"=>"AG", "Description"=>"Antigua and Barbuda", "Added"=>"2005-10-16"},
|
42
|
+
{"Type"=>"region", "Subtag"=>"AI", "Description"=>"Anguilla", "Added"=>"2005-10-16"},
|
43
|
+
{"Type"=>"region", "Subtag"=>"AL", "Description"=>"Albania", "Added"=>"2005-10-16"},
|
44
|
+
{"Type"=>"region", "Subtag"=>"AM", "Description"=>"Armenia", "Added"=>"2005-10-16"},
|
45
|
+
...
|
46
|
+
]
|
47
|
+
```
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it ( https://github.com/[my-github-username]/langtastic/fork )
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/langtastic
ADDED
data/langtastic.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'langtastic/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'langtastic'
|
8
|
+
spec.version = Langtastic::VERSION
|
9
|
+
spec.authors = ['Ed Robinson']
|
10
|
+
spec.email = ['ed.robinson@reevoo.com']
|
11
|
+
|
12
|
+
spec.summary = 'Extracts language subtag data from the IANA registry '
|
13
|
+
spec.description = 'Extracts IANA language subtags'
|
14
|
+
spec.homepage = 'https://github.com/reevoo/langtastic'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
|
18
|
+
spec.bindir = 'bin'
|
19
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
25
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
26
|
+
spec.add_development_dependency 'reevoocop'
|
27
|
+
end
|
data/lib/langtastic.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'langtastic/version'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Langtastic
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def subtags
|
8
|
+
raw_subtags.map do |subtag|
|
9
|
+
@last_field = []
|
10
|
+
subtag.map do |field|
|
11
|
+
if field.split(': ').size > 1
|
12
|
+
@this_field = field.split(': ')
|
13
|
+
if duplicate_field?
|
14
|
+
@last_field[1] += ", #{@this_field[1]}"
|
15
|
+
nil
|
16
|
+
else
|
17
|
+
@last_field = @this_field
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@last_field[1] += field
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end.compact.to_h
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def duplicate_field?
|
30
|
+
@this_field[0] == @last_field[0]
|
31
|
+
end
|
32
|
+
|
33
|
+
def raw_subtags
|
34
|
+
data.split('%%').map(&:strip).map { |subtag| subtag.split("\n") }
|
35
|
+
end
|
36
|
+
|
37
|
+
def data
|
38
|
+
Net::HTTP.get('www.iana.org', '/assignments/language-subtag-registry/language-subtag-registry')
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: langtastic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ed Robinson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: codeclimate-test-reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: reevoocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Extracts IANA language subtags
|
84
|
+
email:
|
85
|
+
- ed.robinson@reevoo.com
|
86
|
+
executables:
|
87
|
+
- langtastic
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- CODE_OF_CONDUCT.md
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/langtastic
|
100
|
+
- langtastic.gemspec
|
101
|
+
- lib/langtastic.rb
|
102
|
+
- lib/langtastic/version.rb
|
103
|
+
homepage: https://github.com/reevoo/langtastic
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Extracts language subtag data from the IANA registry
|
127
|
+
test_files: []
|