strings_updater 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/StringsUpdater.rb +76 -0
  2. metadata +77 -0
@@ -0,0 +1,76 @@
1
+
2
+ #THIS IS TRIVIAL CODE WITHOUT LICENCE
3
+ # depends: google_drive, inifile
4
+ #!/usr/bin/env ruby
5
+
6
+ require "inifile"
7
+ require 'google_drive'
8
+
9
+ class StringsUpdater
10
+ def working_dictionary
11
+ "./"
12
+ end
13
+
14
+ def temp_catalog_name
15
+ "temp_proj"
16
+ end
17
+
18
+ def read_settings
19
+ config = IniFile.load "#{Dir.home}/.aplist/cred.cfg", :parameter => ":", :comment => ';'
20
+
21
+ @user_name = config["user"]["login"]
22
+ @user_password = config["user"]["password"]
23
+ end
24
+
25
+ def get_plist_with_document_id(document_id)
26
+
27
+ read_settings
28
+
29
+ session = GoogleDrive.login(@user_name, @user_password)
30
+ @ws = session.spreadsheet_by_key(document_id).worksheets[0]
31
+
32
+ plist = "\nFile generated Strings Updater v0.1\nMore info: https://github.com/artur-gurgul/strings_updater\n\n\n"
33
+ i = 2
34
+ while true
35
+
36
+
37
+ break if @ws[i, 1] == "."
38
+
39
+ plist += "\n//#{@ws[i, 1]}\n\n" if @ws[i, 1] != ""
40
+
41
+ plist += "\"#{@ws[i, 2]}\" = \"#{@ws[i, 3]};\n" if @ws[i, 2] != ""
42
+ i += 1
43
+ end
44
+ plist
45
+ end
46
+
47
+ def push_project(project_url,output_path,spread_id, branch_name)
48
+ Dir.chdir working_dictionary
49
+
50
+ puts "cloning..."
51
+ `git clone #{project_url} #{temp_catalog_name}`
52
+ exit(-1) if $?.exitstatus != 0
53
+
54
+ proj_path = working_dictionary + temp_catalog_name
55
+ Dir.chdir proj_path
56
+
57
+ puts "downloading google document..."
58
+ plist = get_plist_with_document_id(spread_id)
59
+
60
+ f = File.new(output_path, "w")
61
+ f.write(plist)
62
+ f.close
63
+
64
+ puts "commitintg changes ...."
65
+ `git commit -a -m "update translations"`
66
+ `git push origin #{branch_name}`
67
+ exit(-1) if $?.exitstatus != 0
68
+
69
+ puts "cleaning ..."
70
+ Dir.chdir working_dictionary
71
+ `rm -rf #{proj_path}`
72
+ puts "DONE"
73
+ end
74
+ end
75
+
76
+
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strings_updater
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Artur Gurgul
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: google_drive
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
+ - !ruby/object:Gem::Dependency
31
+ name: inifile
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A simple hello world gem
47
+ email: artur.gurgul@gmail.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - lib/StringsUpdater.rb
53
+ homepage: https://github.com/artur-gurgul/plist_updater
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.25
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Package to autocommit plist file from google drive
77
+ test_files: []