This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
forked from mamantoha/zci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0623c9f
Showing
26 changed files
with
917 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
*.gem | ||
*.rbc | ||
/.config | ||
/coverage/ | ||
/InstalledFiles | ||
/pkg/ | ||
/spec/reports/ | ||
/test/tmp/ | ||
/test/version_tmp/ | ||
/tmp/ | ||
/fci.yml | ||
|
||
## Specific to RubyMotion: | ||
.dat* | ||
.repl_history | ||
build/ | ||
|
||
## Documentation cache and generated files: | ||
/.yardoc/ | ||
/_yardoc/ | ||
/doc/ | ||
/rdoc/ | ||
|
||
## Environment normalisation: | ||
/.bundle/ | ||
/vendor/bundle | ||
/lib/bundler/man/ | ||
|
||
# for a library or gem, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# Gemfile.lock | ||
# .ruby-version | ||
# .ruby-gemset | ||
|
||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: | ||
.rvmrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
zendesk_api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ruby-2.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
||
# gem 'zendesk_help_center_api', path: '../zendesk_help_center_api_client_rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Anton Maminov | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# ZCI | ||
|
||
Zendesk and Crowdin integration Command Line Interface (CLI) | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
``` | ||
gem 'zci' | ||
``` | ||
|
||
And then execute: | ||
``` | ||
$ bundle | ||
``` | ||
|
||
Or install it manually as: | ||
|
||
``` | ||
$ gem install zci | ||
``` | ||
|
||
## Use | ||
|
||
The simplest way to get started is to create a scaffold project: | ||
|
||
``` | ||
> zci init todo | ||
``` | ||
|
||
A new ./todo directory is created containing the sample config `zci.yml`. View the basic output of the scaffold with: | ||
|
||
``` | ||
> cd todo | ||
> zci help | ||
``` | ||
|
||
Which will output: | ||
|
||
``` | ||
NAME | ||
zci - is a command line tool that allows you to manage and synchronize your Zendesk localization with Crowdin project | ||
SYNOPSIS | ||
zci [global options] command [command options] [arguments...] | ||
VERSION | ||
0.0.1 | ||
GLOBAL OPTIONS | ||
-c, --config=<s> - Project-specific configuration file (default: /home/user/todo/zci.yml) | ||
--version - Display the program version | ||
-v, --verbose - Be verbose | ||
--help - Show this message | ||
COMMANDS | ||
help - Shows a list of commands or help for one command | ||
init:project - Create a new ZCI-based project | ||
import:sources - Read categories/section/articles from Zendesk and upload resource files to Crowdin | ||
download:translations - Build and download last exported translation resources from Crowdin | ||
export:translations - Add or update localized resource files(sections and articles) in Zendesk | ||
``` | ||
|
||
## Configuration | ||
|
||
The scaffold project that was created in ./todo comes with a `zci.yml` shell. | ||
|
||
``` | ||
--- | ||
# Crowdin API credentials | ||
crowdin_project_id: '<%your-crowdin-project-id%>' | ||
crowdin_api_key: '<%your-crowdin-api-key%>' | ||
crowdin_base_url: 'https://api.crowdin.com' | ||
# Zendesk API credentials | ||
zendesk_base_url: 'https://<%subdomain%>.zendesk.com' | ||
zendesk_username: '<%your-zendesk-username%>' | ||
zendesk_password: '<%your-zendesk-password%>' | ||
# Zendesk catogories | ||
categories: | ||
- zendesk_category: '<%zendesk-category-id%>' | ||
translations: | ||
- | ||
crowdin_language_code: '<%crowdin-two-letters-code%>' | ||
zendesk_locale: '<%zendesk-locale%>' | ||
- | ||
crowdin_language_code: '<%crowdin-two-letters-code%>' | ||
zendesk_locale: '<%zendesk-locale%>' | ||
- zendesk_category: '<%zendesk-category-id%>' | ||
translations: | ||
- | ||
crowdin_language_code: '<%crowdin-two-letters-code%>' | ||
zendesk_locale: '<%zendesk-locale%>' | ||
- | ||
crowdin_language_code: '<%crowdin-two-letters-code%>' | ||
zendesk_locale: '<%zendesk-locale%>' | ||
``` | ||
|
||
## Supported Rubies | ||
|
||
Tested with the following Ruby versions: | ||
|
||
- MRI 2.2.0 | ||
- JRuby 9.0.0.0.pre2 | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request | ||
|
||
## License and Author | ||
|
||
Author: Anton Maminov ([email protected]) | ||
|
||
Copyright: 2015 [crowdin.com](http://crowdin.com/) | ||
|
||
This project is licensed under the MIT license, a copy of which can be found in the LICENSE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'rake/clean' | ||
require 'rubygems' | ||
require 'rubygems/package_task' | ||
require 'rdoc/task' | ||
require 'cucumber' | ||
require 'cucumber/rake/task' | ||
Rake::RDocTask.new do |rd| | ||
rd.main = "README.rdoc" | ||
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*") | ||
rd.title = 'Your application title' | ||
end | ||
|
||
spec = eval(File.read('fci.gemspec')) | ||
|
||
Gem::PackageTask.new(spec) do |pkg| | ||
end | ||
CUKE_RESULTS = 'results.html' | ||
CLEAN << CUKE_RESULTS | ||
desc 'Run features' | ||
Cucumber::Rake::Task.new(:features) do |t| | ||
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x" | ||
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS'] | ||
t.cucumber_opts = opts | ||
t.fork = false | ||
end | ||
|
||
desc 'Run features tagged as work-in-progress (@wip)' | ||
Cucumber::Rake::Task.new('features:wip') do |t| | ||
tag_opts = ' --tags ~@pending' | ||
tag_opts = ' --tags @wip' | ||
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}" | ||
t.fork = false | ||
end | ||
|
||
task :cucumber => :features | ||
task 'cucumber:wip' => 'features:wip' | ||
task :wip => 'features:wip' | ||
require 'rake/testtask' | ||
Rake::TestTask.new do |t| | ||
t.libs << "test" | ||
t.test_files = FileList['test/*_test.rb'] | ||
end | ||
|
||
task :default => [:test,:features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env ruby | ||
require 'gli' | ||
require 'zci' | ||
|
||
include GLI::App | ||
include ZCI | ||
|
||
program_desc 'is a command line tool that allows you to manage and synchronize your Zendesk localization with Crowdin project' | ||
|
||
sort_help :manually # help commands are ordered in the order declared | ||
|
||
version ZCI::VERSION | ||
|
||
subcommand_option_handling :normal | ||
arguments :strict | ||
|
||
desc 'Be verbose' | ||
switch [:v, :verbose], negatable: false | ||
|
||
desc 'Project-specific configuration file' | ||
default_value File.join(Dir.pwd, 'zci.yml') | ||
arg_name '<s>' | ||
flag [:c, :config] | ||
|
||
commands_from 'zci/commands' | ||
|
||
pre do |global, command, options, args| | ||
# Pre logic here | ||
# Return true to proceed; false to abort and not call the | ||
# chosen command | ||
# Use skips_pre before a command to skip this block | ||
# on that command only | ||
|
||
unless File.exists?(global[:config]) | ||
exit_now! <<-EOS.strip_heredoc | ||
Can't find configuration file (default `zci.yml'). | ||
Type `zci help` to know how to specify custom configuration file | ||
EOS | ||
end | ||
|
||
# load project-specific configuration | ||
begin | ||
@cli_config = YAML.load(File.read(global[:config])) || {} | ||
rescue Psych::SyntaxError => err | ||
exit_now! <<-EOS | ||
Could not parse YAML: #{err.message} | ||
EOS | ||
end | ||
|
||
@zendesk = ZendeskAPI::Client.new do |config| | ||
config.url = @cli_config['zendesk_base_url'] | ||
config.username = @cli_config['zendesk_username'] | ||
config.password = @cli_config['zendesk_password'] | ||
|
||
if global[:verbose] | ||
require 'logger' | ||
config.logger = Logger.new(STDOUT) | ||
end | ||
end | ||
|
||
if global[:verbose] | ||
Crowdin::API.log = Logger.new(STDOUT) if globals[:verbose] | ||
end | ||
|
||
@crowdin = Crowdin::API.new(api_key: @cli_config['crowdin_api_key'], project_id: @cli_config['crowdin_project_id'], base_url: @cli_config['crowdin_base_url']) | ||
|
||
true | ||
end | ||
|
||
post do |global, command, options, args| | ||
# Post logic here | ||
# Use skips_post before a command to skip this | ||
# block on that command only | ||
end | ||
|
||
on_error do |exception| | ||
# Error logic here | ||
# return false to skip default error handling | ||
true | ||
end | ||
|
||
exit run(ARGV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Feature: My bootstrapped app kinda works | ||
In order to get going on coding my awesome app | ||
I want to have aruba and cucumber setup | ||
So I don't have to do it myself | ||
|
||
Scenario: App just runs | ||
When I get help for "fci" | ||
Then the exit status should be 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
When /^I get help for "([^"]*)"$/ do |app_name| | ||
@app_name = app_name | ||
step %(I run `#{app_name} help`) | ||
end | ||
|
||
# Add more step definitions here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'aruba/cucumber' | ||
|
||
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}" | ||
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib') | ||
|
||
Before do | ||
# Using "announce" causes massive warnings on 1.9.2 | ||
@puts = true | ||
@original_rubylib = ENV['RUBYLIB'] | ||
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s | ||
end | ||
|
||
After do | ||
ENV['RUBYLIB'] = @original_rubylib | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'zci/version.rb' | ||
|
||
require 'zendesk_api' | ||
require 'zendesk_api/help_center' | ||
|
||
require 'crowdin-api' | ||
require 'nokogiri' | ||
require 'zip' | ||
|
||
# require 'byebug' | ||
|
||
# Add requires for other files you add to your project here, so | ||
# you just need to require this one file in your bin file | ||
require 'zci/helpers.rb' | ||
require 'zci/init.rb' | ||
require 'zci/import.rb' | ||
require 'zci/download.rb' | ||
require 'zci/export.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
desc 'Create a new ZCI-based project' | ||
arg 'project_name' | ||
arg_name 'project_name' | ||
skips_pre | ||
command :'init:project' do |c| | ||
c.desc 'Root dir of project' | ||
c.long_desc <<-EOS.strip_heredoc | ||
This is the directory where the project's directory will be made, so if you | ||
specify a project name `foo` and the root dir of `.`, the directory | ||
`./foo` will be created | ||
EOS | ||
c.flag :r, :root, :default_value => '.' | ||
|
||
c.switch :force, :desc => 'Overwrite/ignore existing files and directories' | ||
|
||
c.action do |global_options, options, args| | ||
if args.length < 1 | ||
raise 'You must specify the name of your project' | ||
end | ||
|
||
root_dir = options[:root] | ||
force = options[:force] | ||
project_name = args.first | ||
|
||
create_scaffold(root_dir, project_name, force) | ||
end | ||
end | ||
|
Oops, something went wrong.