franc 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.
- checksums.yaml +7 -0
- data/LICENSE +19 -0
- data/README.md +49 -0
- data/Rakefile +7 -0
- data/lib/franc/version.rb +3 -0
- data/lib/franc.rb +36 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 380a458fdd11b1aa8514848152de0fe981170ac7
|
4
|
+
data.tar.gz: cdcb9b654bf1e77486ad24081f81ec926260d882
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d9cf459dfa3a1ea2db4c87abcddaa142463a939dd421621eca77c96cea4ed3b66f636b971937be0d879cfccbf543506e419bcaab58c80456574a941f0ca4b1d
|
7
|
+
data.tar.gz: d1832cd6034bc6f8e930f5742de4fc41cea2c738a84d285119a8118b93901f35512094b44e343b703c5e5d7370be95e4053965b34a5ab72d0a51c4f37c85f909
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2015 John Mason
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Franc
|
2
|
+
|
3
|
+
A simple ruby wrapper to Titus Wormer's awesome javascript language detection called [Franc](https://github.com/wooorm/franc).
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
At this time, this gem depends on a system wide npm installation of franc and runs a bash command within ruby to invoke the franc javascript.
|
8
|
+
|
9
|
+
If you do not have franc installed, this gem will install it for you on the first run.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install franc
|
15
|
+
|
16
|
+
```
|
17
|
+
|
18
|
+
## Set Up
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'franc'
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
## How it works
|
26
|
+
|
27
|
+
Franc is included in the String class and can be called on any string using the `language` method:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
|
31
|
+
'Alle menslike wesens word vry'.language
|
32
|
+
# => "afr"
|
33
|
+
|
34
|
+
'এটি একটি ভাষা একক IBM স্ক্রিপ্ট'.language
|
35
|
+
# => "ben"
|
36
|
+
|
37
|
+
'Alle mennesker er født frie og'.language
|
38
|
+
# => "nno"
|
39
|
+
|
40
|
+
'asdfasdf'.language
|
41
|
+
# => "und"
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
## License
|
46
|
+
[The MIT License (MIT)](https://github.com/m8ss/franc/blob/master/LICENSE)
|
47
|
+
|
48
|
+
Copyright (c) 2015 John Mason
|
49
|
+
|
data/Rakefile
ADDED
data/lib/franc.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# This runs a bash command for Titus Wormer's franc.
|
2
|
+
# More info on franc can be found here: https://github.com/wooorm/franc
|
3
|
+
#
|
4
|
+
# If franc is not installed globally on computer system, this will not work.
|
5
|
+
module Franc
|
6
|
+
def language(str = self)
|
7
|
+
`franc #{str}`.strip!
|
8
|
+
rescue Errno::ENOENT
|
9
|
+
ask_install
|
10
|
+
end
|
11
|
+
|
12
|
+
# Asks if user would like to install franc.
|
13
|
+
def ask_install
|
14
|
+
puts 'Looks like franc has not been installed yet.'
|
15
|
+
puts 'Would you like to install it now? (y/n)'
|
16
|
+
answer = gets.chomp!
|
17
|
+
install(answer)
|
18
|
+
end
|
19
|
+
|
20
|
+
# If user presses RETURN or gives anything besides no, franc is installed.
|
21
|
+
def install(str)
|
22
|
+
return if ['no', 'n'].include?(str)
|
23
|
+
puts 'installing...'
|
24
|
+
`npm install -g franc`
|
25
|
+
puts "\nnpm successfully installed."
|
26
|
+
true # Just for looks, better than returning nil.
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Add to String class. Now usage can be:
|
31
|
+
# "example string".language
|
32
|
+
# =>"und"
|
33
|
+
class String
|
34
|
+
include Franc
|
35
|
+
end
|
36
|
+
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: franc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Mason
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.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.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
description: This is a simple ruby wrapper for Titus Wormer's awesome javascript language
|
42
|
+
detection called Franc (https://github.com/wooorm/franc). At this time, this gem
|
43
|
+
depends on a global npm installation of franc and runs a bash command within ruby
|
44
|
+
to invoke the franc javascript. If you do not have franc installed, this gem will
|
45
|
+
install it for you on the first run.
|
46
|
+
email: mace2345@gmail.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/franc.rb
|
55
|
+
- lib/franc/version.rb
|
56
|
+
homepage: http://github.com/m8ss/franc
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message: Run `npm install -g franc` to finish installation.
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.3
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Detect the language of text.
|
80
|
+
test_files: []
|