yatapp 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3f08f10eae6d36ad30b9441a8c40ab2cc1429855
4
+ data.tar.gz: 9ee4b7d69c902e5e58b9343fe9677f810f5acbec
5
+ SHA512:
6
+ metadata.gz: 3c879e909e4906b528292024b534f8e88a6b1f50cb43572cdea88cf7bb8692aca25c23dc676b2ee027de121fa904faf3d22a5fcccf9bb82142dc751c383f35f9
7
+ data.tar.gz: 5cc4195238d96cf7a3df2103c3f66cef0530fca18029fe7ecf2da34bfdcbb8d9e4b161db9f94b9249cfb81f8c233261c1cd2d372b3a2bcace0015da0e22c9e03
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.yata.yaml
11
+ *.yata.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yatapp.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 luki3k5
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,50 @@
1
+ # Yatapp
2
+
3
+ Welcome to Yata integration gem, this gem will allow you to easy get your translations from http://yatapp.net service.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yatapp'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install yatapp
20
+
21
+ ## Usage in Rails
22
+ Before using Yata integration gem you need to configure it.
23
+ We recommend adding the following lines to freshly created initialiser
24
+ in your rails project:
25
+
26
+
27
+ ```ruby
28
+ include Yatapp
29
+
30
+ Yatapp.configure do |c|
31
+ c.languages = ['en', 'de'] # add any languages you wish by language code
32
+ c.api_access_token = ENV['YATA_API_KEY'] # access key to Yata
33
+ c.project = 'hash-of-your-project' # project you wish to fetch from
34
+ end
35
+
36
+ ```
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/yatapp/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yatapp"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ namespace :yata do
2
+ desc "gets all the languages translations"
3
+ task :fetch_translations do
4
+ get_translations
5
+ end
6
+ end
data/lib/yatapp.rb ADDED
@@ -0,0 +1,26 @@
1
+ require "yatapp/version"
2
+ require "yatapp/configuration"
3
+ require "yatapp/yata_api_caller"
4
+ require 'yatapp/railtie' if defined?(Rails)
5
+
6
+ module Yatapp
7
+ extend Configuration
8
+
9
+ class << self
10
+ def included(includer)
11
+ includer.send(:include, Methods)
12
+ includer.extend(Methods)
13
+ end
14
+
15
+ def api_caller
16
+ @api_caller ||= YataApiCaller.new
17
+ end
18
+
19
+ end
20
+
21
+ module Methods
22
+ def get_translations
23
+ Yatapp.api_caller.get_translations
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module Yatapp
2
+ module Configuration
3
+ CONFIGURATION_OPTIONS = [
4
+ :languages,
5
+ :api_access_token,
6
+ :project
7
+ ].freeze
8
+
9
+ attr_accessor *CONFIGURATION_OPTIONS
10
+
11
+ def configure
12
+ yield self
13
+ end
14
+
15
+ def options
16
+ CONFIGURATION_OPTIONS.inject({}) do |opt, key|
17
+ opt.merge!(key => send(key))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require 'yatapp'
2
+ require 'rails'
3
+
4
+ module GoogleSpreadsheet2yml
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :yatapp
7
+
8
+ rake_tasks do
9
+ load "tasks/yata.rake"
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,3 @@
1
+ module Yatapp
2
+ VERSION = "0.2.3"
3
+ end
@@ -0,0 +1,57 @@
1
+ require 'faraday'
2
+ require 'typhoeus'
3
+ require 'typhoeus/adapters/faraday'
4
+ require 'pry'
5
+
6
+ module Yatapp
7
+ class YataApiCaller
8
+ API_CALLER_ATTRIBUTES = [:connection].freeze
9
+ API_END_POINT_URL = "/api/project/:project_id/download/:lang"
10
+ API_BASE_URL = "http://api.yatapp.net"
11
+
12
+ attr_accessor *Yatapp::Configuration::CONFIGURATION_OPTIONS
13
+ attr_reader *API_CALLER_ATTRIBUTES
14
+
15
+ def initialize
16
+ initialize_configuration
17
+ @connection = make_connection
18
+ end
19
+
20
+ def make_connection
21
+ Faraday.new(url: API_BASE_URL) do |faraday|
22
+ faraday.adapter :typhoeus
23
+ end
24
+ end
25
+
26
+ def get_translations
27
+ languages.each do |lang|
28
+ api_url = download_url(lang)
29
+ api_response = connection.get(api_url)
30
+ save_translation(lang, api_response)
31
+ end
32
+ end
33
+
34
+ private
35
+ def initialize_configuration
36
+ options = Yatapp.options
37
+ Configuration::CONFIGURATION_OPTIONS.each do |key|
38
+ send("#{key}=", options[key])
39
+ end
40
+ end
41
+
42
+ def save_translation(lang, response)
43
+ bfp = base_file_path
44
+ File.open("#{bfp}#{lang}.yata.yml", 'wb') { |f| f.write(response.body) }
45
+ end
46
+
47
+ def base_file_path
48
+ "#{Rails.root}/config/locales/" if defined?(Rails)
49
+ end
50
+
51
+ def download_url(lang)
52
+ url = API_END_POINT_URL.sub(':project_id', project)
53
+ url = url.sub(':lang', lang)
54
+ end
55
+
56
+ end
57
+ end
data/yatapp.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yatapp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yatapp"
8
+ spec.version = Yatapp::VERSION
9
+ spec.authors = ["luki3k5"]
10
+ spec.email = ["luki3k5@gmail.com"]
11
+
12
+ spec.summary = %q{This gem allows for easy integration with Yata to fetch translation files from the service}
13
+ spec.description = %q{This gem allows for easy integration with Yata to fetch translation files from the service}
14
+ spec.homepage = "http://github.com/luki3k5/yatapp"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ #spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency 'faraday'
31
+ spec.add_dependency 'typhoeus'
32
+ spec.add_development_dependency "bundler", "~> 1.9"
33
+ spec.add_development_dependency "pry"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yatapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.3
5
+ platform: ruby
6
+ authors:
7
+ - luki3k5
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: typhoeus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: This gem allows for easy integration with Yata to fetch translation files
84
+ from the service
85
+ email:
86
+ - luki3k5@gmail.com
87
+ executables: []
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/console
100
+ - bin/setup
101
+ - lib/tasks/yata.rake
102
+ - lib/yatapp.rb
103
+ - lib/yatapp/configuration.rb
104
+ - lib/yatapp/railtie.rb
105
+ - lib/yatapp/version.rb
106
+ - lib/yatapp/yata_api_caller.rb
107
+ - yatapp.gemspec
108
+ homepage: http://github.com/luki3k5/yatapp
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: This gem allows for easy integration with Yata to fetch translation files
132
+ from the service
133
+ test_files: []