google_spreadsheet2yml 0.1.3

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in google_spreadsheet2yml.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 luki3k5
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # GoogleSpreadsheet2yml
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'google-spreadsheet2yml'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install google-spreadsheet2yml
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/google_spreadsheet2yml/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["luki3k5"]
6
+ gem.email = ["luki3k5@gmail.com"]
7
+ gem.description = %q{This gems allows simple management of translations from google spreadsheets - it converts google document into yml files}
8
+ gem.summary = %q{easy management of i18n-yml through google spreadsheets}
9
+ gem.homepage = ""
10
+ gem.add_dependency "google-spreadsheet-ruby"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "google_spreadsheet2yml"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = GoogleSpreadsheet2yml::VERSION
18
+ end
@@ -0,0 +1,12 @@
1
+ require 'google_spreadsheet2yml'
2
+ require 'rails'
3
+
4
+ module GoogleSpreadsheet2yml
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :google_spreadsheet2yml
7
+
8
+ rake_tasks do
9
+ load "tasks/google_spreadsheet2yml.rake"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module GoogleSpreadsheet2yml
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,21 @@
1
+ require "google_spreadsheet2yml/version"
2
+
3
+ module GoogleSpreadsheet2yml
4
+ require 'google_spreadsheet2yml/railtie' if defined?(Rails)
5
+
6
+ def self.hash_from_array(key, arr, main_hash)
7
+ current_first = arr.delete_at(0)
8
+ return { current_first => hash_from_array(key, arr, main_hash) } if arr.size > 0
9
+ return { current_first => main_hash[key] } if arr.size == 0
10
+ end
11
+
12
+ def self.create_yaml(hash)
13
+ @result = Hash.new
14
+ merger = proc { |key,v1,v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
15
+ hash.keys.each do |key|
16
+ @result = @result.merge(hash_from_array(key, key.split('.'), hash), &merger)
17
+ end
18
+ @result.to_yaml
19
+ end
20
+
21
+ end
@@ -0,0 +1,56 @@
1
+ desc 'my plugins rake task'
2
+ task :do_something do
3
+ puts "the rake task did something"
4
+ end
5
+
6
+ namespace :gs2yml do
7
+
8
+ desc "gets translations from google doc and creates YML files"
9
+ task :translate do
10
+ puts "Starting Translation"
11
+
12
+ # require "rubygems"
13
+ require "google_spreadsheet"
14
+ require 'yaml'
15
+ require 'google_spreadsheet2yml'
16
+ config = ""
17
+
18
+ begin
19
+ puts "Loading configuration..."
20
+ config = YAML.load_file("./config/google_doc_translations_config.yml")
21
+ rescue Exception => ex
22
+ puts("config file missing!")
23
+ exit
24
+ end
25
+
26
+ login = config['google_user_id'] # Getting the login information
27
+ password = config['google_password'] # getting password information
28
+ spreedsheet_key = config['google_spreedsheet_to_process'] # getting spreedsheet id
29
+
30
+ session = GoogleSpreadsheet.login(login, password)
31
+ puts "connected..."
32
+ spreadsheet = session.spreadsheet_by_key(spreedsheet_key)
33
+ puts "got spreadsheet..."
34
+ ws = spreadsheet.worksheets[0] # getting the first worksheet
35
+ puts "got worksheet..."
36
+ languages = {}
37
+
38
+ puts "Parsing Google Docs"
39
+
40
+ (3..ws.num_cols).each do |c|
41
+ languages["#{ws[1,c]}"] = c
42
+ end
43
+
44
+ puts "Connecting to Google Docs"
45
+
46
+ # Create flat HASH from Spreedsheet that will be processed
47
+ languages.keys.each do |lang|
48
+ hash = Hash.new
49
+ (2..ws.num_rows).each do |row|
50
+ hash.store([lang, ws[row, 1].strip.rstrip].join('.'), ws[row, languages[lang]].strip.rstrip)
51
+ end
52
+
53
+ File.open("./config/locales/#{lang}.gdocs.yml", 'w') {|f| f.write(GoogleSpreadsheet2yml.create_yaml(hash)) }
54
+ end
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google_spreadsheet2yml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - luki3k5
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: google-spreadsheet-ruby
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: This gems allows simple management of translations from google spreadsheets
31
+ - it converts google document into yml files
32
+ email:
33
+ - luki3k5@gmail.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - google_spreadsheet2yml.gemspec
44
+ - lib/google_spreadsheet2yml.rb
45
+ - lib/google_spreadsheet2yml/railtie.rb
46
+ - lib/google_spreadsheet2yml/version.rb
47
+ - lib/tasks/google_spreadsheet2yml.rake
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.21
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: easy management of i18n-yml through google spreadsheets
72
+ test_files: []