Skip to content

Commit

Permalink
Update license, add new Task attribute, fix linter issues (#11)
Browse files Browse the repository at this point in the history
* SRUBY-4 Update license, add new Task attribute, fix linter issues

* SRUBY-4 update jekyll [skip ci]
  • Loading branch information
bodrovis authored Feb 2, 2021
1 parent 5a6599d commit faa9abb
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 107 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require:
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.6
TargetRubyVersion: 2.5
NewCops: enable

Layout/SpaceInsideHashLiteralBraces:
Expand Down Expand Up @@ -83,3 +83,6 @@ RSpec/FilePath:

RSpec/MessageSpies:
EnforcedStyle: receive

RSpec/MultipleMemoizedHelpers:
Max: 10
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ language: ruby
rvm:
- 2.5.8
- 2.6.6
- 2.7.1
- 2.7.2
- 3.0.0

install: bundle install --retry=3

Expand Down
27 changes: 9 additions & 18 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
MIT License
BSD 3 Clause

Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov
Copyright 2021 Lokalise Group, Ilya Bodrov

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ Detailed documentation can be found at [lokalise.github.io/ruby-lokalise-api](ht

## License

This gem is licensed under the [MIT License](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE).
This gem is licensed under the [BSD 3 Clause license](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). Prior to version 4 the license type was MIT.

Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech)
22 changes: 12 additions & 10 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
Expand All @@ -8,30 +10,30 @@ source "https://rubygems.org"
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
#gem "jekyll", "~> 3.9.0"
gem "jekyll", "~> 3.9.0"

# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
gem 'minima', '~> 2.0'

# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", "~> 207", group: :jekyll_plugins
gem 'github-pages', '~> 211', group: :jekyll_plugins

# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
gem 'jekyll-feed', '~> 0.15'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
gem "tzinfo", "~> 1.2"
gem "tzinfo-data"
install_if -> { RUBY_PLATFORM =~ /mingw|mswin|java/ } do
gem 'tzinfo', '~> 1.2'
gem 'tzinfo-data'
end

# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0", :install_if => Gem.win_platform?
gem 'wdm', '~> 0.1.0', install_if: Gem.win_platform?

# kramdown v2 ships without the gfm parser by default. If you're using
# kramdown v1, comment out this line.
gem "kramdown-parser-gfm"
gem 'kramdown-parser-gfm'
7 changes: 7 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 4.0.0 (02-Feb-20)

* **License type is now BSD 3 Clause**
* Added `auto_close_items` attribute for the `Task` endpoint
* Dependency updates
* Test against Ruby 3

## 3.1.0 (08-Jul-20)

* Added all recently introduced attributes for the following endpoints: `Contributor` and `Key`
Expand Down
27 changes: 9 additions & 18 deletions docs/additional_info/license_type.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
MIT License
BSD 3 Clause

Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov
Copyright 2021 Lokalise Group, Ilya Bodrov

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/collections/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def fetch_page(page_num)
# Collection example: `{ "content": {"comments": [ ... ]} }`
def produce_collection_for(response)
model_class = self.class.name.base_class_name
data_key_plural = data_key_for model_class, true, true
data_key_plural = data_key_for model_class: model_class, plural: true, collection: true

# Fetch collection data and instantiate an individual resource for each object
# We also preserve the `client` to be able to chain API methods later
Expand Down
1 change: 1 addition & 0 deletions lib/ruby-lokalise-api/data/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"languages",
"auto_close_languages",
"auto_close_task",
"auto_close_items",
"completed_at",
"completed_at_timestamp",
"completed_by",
Expand Down
8 changes: 4 additions & 4 deletions lib/ruby-lokalise-api/resources/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def prepare_params(params)
# Instantiates a new resource or collection based on the given response
def object_from(response, params)
model_class = name.base_class_name
data_key_plural = data_key_for model_class, true
data_key_plural = data_key_for model_class: model_class, plural: true
# Preserve the initial path to allow chaining
response['path'] = params.delete(:_initial_path) if params.key?(:_initial_path)

Expand All @@ -107,7 +107,7 @@ def object_from(response, params)
end

def produce_resource(model_class, response)
data_key_singular = data_key_for model_class
data_key_singular = data_key_for model_class: model_class
if response['content'].key? data_key_singular
data = response['content'].delete data_key_singular
response['content'].merge! data
Expand All @@ -124,7 +124,7 @@ def produce_collection(model_class, response, params)
# Generates path for the individual resource based on the path for the collection
def infer_path_from(response, endpoint_generator = nil)
id_key = id_key_for self.class.name.base_class_name
data_key = data_key_for self.class.name.base_class_name
data_key = data_key_for model_class: self.class.name.base_class_name

path_with_id response, id_key, data_key, endpoint_generator
end
Expand Down Expand Up @@ -164,7 +164,7 @@ def id_from(response, id_key, data_key)
# Store all resources attributes under the corresponding instance variables.
# `ATTRIBUTES` is defined inside resource-specific classes
def populate_attributes_for(content)
data_key = data_key_for self.class.name.base_class_name
data_key = data_key_for model_class: self.class.name.base_class_name

self.class.const_get(:ATTRIBUTES).each do |attr|
value = if content.key?(data_key) && content[data_key].is_a?(Hash)
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/resources/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Project < Base
supports :update, :destroy, [:reload_data, '', :find]

def empty
self.class.empty @client, @path + '/empty'
self.class.empty @client, "#{@path}/empty"
end

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/resources/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Webhook < Base
supports :update, :destroy, [:reload_data, '', :find]

def regenerate_secret
self.class.regenerate_secret @client, @path + '/secret/regenerate'
self.class.regenerate_secret @client, "#{@path}/secret/regenerate"
end

class << self
Expand Down
17 changes: 11 additions & 6 deletions lib/ruby-lokalise-api/utils/attribute_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@ module AttributeHelpers
# @return [String]
# @param model_class [String]
# @param plural [Boolean] Should the returned value be pluralized?
def data_key_for(model_class, plural = false, collection = false)
data_key_plural = get_key('DATA_KEY_PLURAL', model_class, true, true)
def data_key_for(model_class:, plural: false, collection: false)
data_key_plural = get_key(
name: 'DATA_KEY_PLURAL',
model_class: model_class,
collection: true,
strict: true
)

return data_key_plural if collection && data_key_plural

data_key = get_key 'DATA_KEY', model_class, collection
data_key = get_key name: 'DATA_KEY', model_class: model_class, collection: collection

return data_key unless plural

data_key + 's'
"#{data_key}s"
end

# Returns key used to determine resource id (for example `user_id` or `project_id`).
Expand All @@ -35,7 +40,7 @@ def data_key_for(model_class, plural = false, collection = false)
# @return [String]
# @param model_class [String]
def id_key_for(model_class)
get_key('ID_KEY', model_class) + '_id'
"#{get_key(name: 'ID_KEY', model_class: model_class)}_id"
end

# Loads attributes for the given resource based on its name
Expand All @@ -52,7 +57,7 @@ def attributes_for(klass)

private

def get_key(name, model_class, collection = false, strict = false)
def get_key(name:, model_class:, collection: false, strict: false)
key = if collection && Module.const_defined?("Lokalise::Collections::#{model_class}::#{name}")
Module.const_get "Lokalise::Collections::#{model_class}::#{name}"
elsif Module.const_defined? "Lokalise::Resources::#{model_class}::#{name}"
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-lokalise-api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Lokalise
VERSION = '3.1.0'
VERSION = '4.0.0'
end
3 changes: 2 additions & 1 deletion ruby-lokalise-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Gem::Specification.new do |spec|
spec.summary = 'Ruby interface to the Lokalise API'
spec.description = 'Opinionated Ruby client for the Lokalise platform API allowing to work with translations, projects, users and other resources as with Ruby objects.'
spec.homepage = 'https://github.com/lokalise/ruby-lokalise-api'
spec.license = 'MIT'
spec.license = 'BSD-3-Clause'
spec.platform = Gem::Platform::RUBY
spec.required_ruby_version = '>= 2.5.0'

spec.files = Dir['README.md', 'LICENSE',
'CHANGELOG.md', 'lib/**/*.rb', 'lib/ruby-lokalise-api/data/attributes.json',
Expand Down
Loading

0 comments on commit faa9abb

Please sign in to comment.