Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit f303aa7

Browse files
committed
Initial commit to deepl-rb for version 0.0.0.
0 parents  commit f303aa7

29 files changed

+1163
-0
lines changed

.circleci/config.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: 2
2+
jobs:
3+
build:
4+
working_directory: ~/deepl-rb
5+
docker:
6+
- image: circleci/ruby:2.4-node
7+
steps:
8+
- checkout
9+
10+
# Restore bundle cache
11+
- type: cache-restore
12+
name: Restore bundle cache
13+
key: deepl-rb-bundle-{{ checksum "Gemfile.lock" }}
14+
15+
- run:
16+
name: Bundle Install
17+
command: bundle install --path vendor/bundle
18+
19+
# Store bundle cache
20+
- type: cache-save
21+
name: Store bundle cache
22+
key: deepl-rb-bundle-{{ checksum "Gemfile.lock" }}
23+
paths:
24+
- vendor/bundle
25+
26+
# Run rspec
27+
- type: shell
28+
command: |
29+
bundle exec rspec $(circleci tests glob "spec/**/*_spec.rb" |
30+
circleci tests split --split-by=timings)
31+
32+
# Run rubocop
33+
- type: shell
34+
command: |
35+
bundle exec rubocop
36+
37+
# Save test results for timing analysis
38+
- store_test_results:
39+
path: test_results

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# yard generated
2+
doc
3+
.yardoc
4+
5+
# juwelier generated
6+
pkg

.rubocop.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Custom rubocop configuration
2+
3+
AllCops:
4+
DisplayCopNames: true
5+
6+
Metrics/BlockLength:
7+
Exclude:
8+
- "**/*_spec.rb"
9+
10+
Metrics/LineLength:
11+
Max: 120
12+
13+
Style/Documentation:
14+
Enabled: false
15+
16+
Style/ModuleFunction:
17+
EnforcedStyle: extend_self

Gemfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
source 'https://rubygems.org'
2+
3+
group :development do
4+
# Gem management
5+
gem 'juwelier'
6+
end
7+
8+
group :test do
9+
# Test
10+
gem 'rspec'
11+
gem 'rubocop'
12+
gem 'simplecov'
13+
gem 'vcr'
14+
gem 'webmock'
15+
end

Gemfile.lock

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
addressable (2.5.2)
5+
public_suffix (>= 2.0.2, < 4.0)
6+
ast (2.3.0)
7+
builder (3.2.3)
8+
crack (0.4.3)
9+
safe_yaml (~> 1.0.0)
10+
descendants_tracker (0.0.4)
11+
thread_safe (~> 0.3, >= 0.3.1)
12+
diff-lcs (1.3)
13+
docile (1.1.5)
14+
faraday (0.12.2)
15+
multipart-post (>= 1.2, < 3)
16+
git (1.3.0)
17+
github_api (0.18.2)
18+
addressable (~> 2.4)
19+
descendants_tracker (~> 0.0.4)
20+
faraday (~> 0.8)
21+
hashie (~> 3.5, >= 3.5.2)
22+
oauth2 (~> 1.0)
23+
hashdiff (0.3.7)
24+
hashie (3.5.6)
25+
highline (1.7.10)
26+
json (2.1.0)
27+
juwelier (2.4.7)
28+
builder
29+
bundler
30+
git
31+
github_api
32+
highline
33+
kamelcase (~> 0)
34+
nokogiri
35+
psych
36+
rake
37+
rdoc
38+
semver2
39+
jwt (1.5.6)
40+
kamelcase (0.0.1)
41+
semver2 (~> 3)
42+
mini_portile2 (2.3.0)
43+
multi_json (1.12.2)
44+
multi_xml (0.6.0)
45+
multipart-post (2.0.0)
46+
nokogiri (1.8.1)
47+
mini_portile2 (~> 2.3.0)
48+
oauth2 (1.4.0)
49+
faraday (>= 0.8, < 0.13)
50+
jwt (~> 1.0)
51+
multi_json (~> 1.3)
52+
multi_xml (~> 0.5)
53+
rack (>= 1.2, < 3)
54+
parallel (1.12.0)
55+
parser (2.4.0.2)
56+
ast (~> 2.3)
57+
powerpack (0.1.1)
58+
psych (2.2.2)
59+
public_suffix (3.0.1)
60+
rack (2.0.3)
61+
rainbow (2.2.2)
62+
rake
63+
rake (12.3.0)
64+
rdoc (5.0.0)
65+
rspec (3.7.0)
66+
rspec-core (~> 3.7.0)
67+
rspec-expectations (~> 3.7.0)
68+
rspec-mocks (~> 3.7.0)
69+
rspec-core (3.7.0)
70+
rspec-support (~> 3.7.0)
71+
rspec-expectations (3.7.0)
72+
diff-lcs (>= 1.2.0, < 2.0)
73+
rspec-support (~> 3.7.0)
74+
rspec-mocks (3.7.0)
75+
diff-lcs (>= 1.2.0, < 2.0)
76+
rspec-support (~> 3.7.0)
77+
rspec-support (3.7.0)
78+
rubocop (0.51.0)
79+
parallel (~> 1.10)
80+
parser (>= 2.3.3.1, < 3.0)
81+
powerpack (~> 0.1)
82+
rainbow (>= 2.2.2, < 3.0)
83+
ruby-progressbar (~> 1.7)
84+
unicode-display_width (~> 1.0, >= 1.0.1)
85+
ruby-progressbar (1.9.0)
86+
safe_yaml (1.0.4)
87+
semver2 (3.4.2)
88+
simplecov (0.15.1)
89+
docile (~> 1.1.0)
90+
json (>= 1.8, < 3)
91+
simplecov-html (~> 0.10.0)
92+
simplecov-html (0.10.2)
93+
thread_safe (0.3.6)
94+
unicode-display_width (1.3.0)
95+
vcr (4.0.0)
96+
webmock (3.1.1)
97+
addressable (>= 2.3.6)
98+
crack (>= 0.3.2)
99+
hashdiff
100+
101+
PLATFORMS
102+
ruby
103+
104+
DEPENDENCIES
105+
juwelier
106+
rspec
107+
rubocop
108+
simplecov
109+
vcr
110+
webmock
111+
112+
BUNDLED WITH
113+
1.15.4

LICENSE.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The MIT License (MIT)
2+
=====================
3+
4+
Copyright © `2018` `Daniel Herzog`
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the “Software”), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

README.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
[![Gem Version](https://badge.fury.io/rb/deepl-rb.svg)](https://badge.fury.io/rb/deepl-rb) [![Dependency Status](https://gemnasium.com/badges/github.com/wikiti/deepl-rb.svg)](https://gemnasium.com/github.com/wikiti/deepl-rb) [![CircleCI](https://circleci.com/gh/wikiti/deepl-rb.svg?style=shield)](https://circleci.com/gh/wikiti/deepl-rb)
2+
3+
# DeepL for ruby
4+
5+
A simple ruby wrapper for the [DeepL translation API (v1)](https://www.deepl.com/docs/api-reference.html).
6+
7+
## Installation
8+
9+
Install this gem with
10+
11+
```sh
12+
gem install deepl-rb
13+
```
14+
15+
Or add it to your Gemfile:
16+
17+
```rb
18+
gem 'deepl-rb'
19+
```
20+
21+
## Usage
22+
23+
Setup an environment variable named `DEEPL_AUTH_KEY` with your authentication key:
24+
25+
```sh
26+
export DEEPL_AUTH_KEY="your-api-token"
27+
```
28+
29+
Alternatively, you can configure the API client within a ruby block:
30+
31+
```rb
32+
DeepL.configure do |config|
33+
config.auth_key = 'your-api-token'
34+
end
35+
```
36+
37+
You can also configure the api host:
38+
39+
```rb
40+
DeepL.configure do |config|
41+
config.auth_key = 'your-api-token'
42+
config.host = 'https://test-api.deepl.com' # Default value is 'https://api.deepl.com'
43+
end
44+
```
45+
46+
### Translate
47+
48+
To translate a simple text, use the `translate` method:
49+
50+
```rb
51+
item = DeepL.translate 'This is my text', 'EN', 'ES'
52+
53+
puts item.class
54+
# => DeepL::Resources::Text
55+
puts item.text
56+
# => 'Este es mi texto'
57+
```
58+
59+
You can also auto-detect source language by skipping it with `nil`:
60+
61+
```rb
62+
item = DeepL.translate 'This is my text', nil, 'ES'
63+
64+
puts item.detected_source_language
65+
# => 'EN'
66+
```
67+
68+
You can also translate a list of texts by passing an array as an argument:
69+
70+
```rb
71+
texts = ['Sample text', 'Another text']
72+
items = DeepL.translate texts, 'EN', 'ES'
73+
74+
puts items.class
75+
# => Array
76+
puts items.first.class
77+
# => DeepL::Resources::Text
78+
```
79+
80+
## Development
81+
82+
Clone the repository, and install its dependencies:
83+
84+
```sh
85+
git clone https://github.com/wikiti/deepl-rb
86+
cd deepl-rb
87+
bundle install
88+
```
89+
90+
To run tests (rspec and rubocop), use
91+
92+
```
93+
bundle exec rake test
94+
```
95+
96+
## Contributors
97+
98+
This project has been developed by:
99+
100+
| Avatar | Name | Nickname | Email |
101+
| ------ | ---- | -------- | ----- |
102+
| ![](http://www.gravatar.com/avatar/2ae6d81e0605177ba9e17b19f54e6b6c.jpg?s=64) | Daniel Herzog | Wikiti | [[email protected]](mailto:[email protected])

Rakefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require 'rubygems'
2+
require 'bundler'
3+
4+
begin
5+
Bundler.setup(:default, :development)
6+
rescue Bundler::BundlerError => e
7+
warn e.message
8+
warn 'Run `bundle install` to install missing gems'
9+
exit e.status_code
10+
end
11+
12+
require 'rake'
13+
require 'juwelier'
14+
15+
Juwelier::Tasks.new do |gem|
16+
gem.name = 'deepl-rb'
17+
gem.homepage = 'http://github.com/wikiti/deepl-rb'
18+
gem.license = 'MIT'
19+
gem.summary = 'A simple ruby wrapper for the DeepL API'
20+
gem.description =
21+
'A simple ruby wrapper for the DeepL translation API (v1). ' \
22+
'For more information, check this: https://www.deepl.com/docs/api-reference.html'
23+
24+
gem.email = '[email protected]'
25+
gem.authors = ['Daniel Herzog']
26+
end
27+
28+
Juwelier::RubygemsDotOrgTasks.new
29+
30+
# Tests
31+
require 'rspec/core/rake_task'
32+
require 'rubocop/rake_task'
33+
34+
RuboCop::RakeTask.new
35+
RSpec::Core::RakeTask.new(:spec)
36+
37+
desc 'Run all tests.'
38+
task :test do
39+
Rake::Task['spec'].invoke
40+
Rake::Task['rubocop'].invoke
41+
end
42+
43+
task default: :test

VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.0

0 commit comments

Comments
 (0)