unigunkan 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,24 +1,26 @@
1
1
  # Unigunkan
2
2
 
3
- TODO: Write a gem description
3
+ Unigunkan is a command line xcode project file modifier tool. Designed for Unity based projects.
4
4
 
5
- ## Installation
5
+ It helps you automate building process of Unity project.
6
6
 
7
- Add this line to your application's Gemfile:
7
+ ## Installation
8
8
 
9
- gem 'unigunkan'
9
+ $ gem install unigunkan
10
10
 
11
- And then execute:
11
+ ## Usage
12
12
 
13
- $ bundle
13
+ ### Basic
14
14
 
15
- Or install it yourself as:
15
+ $ unigunkan /path/to/your/xcode/project/Unity-iPhone.xcodeproj
16
+
17
+ Please read the messages shown by this command.
16
18
 
17
- $ gem install unigunkan
19
+ ### Options
18
20
 
19
- ## Usage
21
+ To disable Retina 4 inch devices support,
20
22
 
21
- TODO: Write usage instructions here
23
+ $ unigunkan /path/to/project/Unity-iPhone.xcodeproj --disable-retina-4inch-support
22
24
 
23
25
  ## Contributing
24
26
 
data/bin/unigunkan CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- require 'fileutils'
5
- require 'pathname'
6
4
  require 'optparse'
5
+ require 'unigunkan'
7
6
  opt = OptionParser.new
8
7
 
9
8
  OPTS = {}
@@ -15,6 +14,11 @@ input = ARGV[0]
15
14
  backup_confirmed = OPTS[:y]
16
15
  disable_retina_4inch_support = OPTS[:disable_retina_4inch_support]
17
16
 
17
+ if input.nil?
18
+ STDERR.puts "No input file."
19
+ exit false
20
+ end
21
+
18
22
  puts "Hello Uni. #{ARGV[0]}"
19
23
 
20
24
  input = "#{input}/project.pbxproj" if !File.exists?(input) || File::ftype(input) == "directory"
@@ -33,47 +37,8 @@ if backup_confirmed != true
33
37
  exit false
34
38
  end
35
39
 
36
- # create a backup
37
- STDOUT.puts "Creating a backup of project.pbxproj..."
38
- backup_filepath = input + ".backup" + Time.now.strftime("%Y%m%d%H%M%S")
39
- FileUtils.cp(input, backup_filepath)
40
- STDOUT.puts "A backup created -> #{backup_filepath}"
41
-
42
- # read the original
43
- src = ""
44
- f = open(input)
45
- src = f.read
46
- f.close
47
-
48
- # Disable iphone5 support
49
- # (Remove lines which include 'Default-568h@2x.png'.)
50
- if disable_retina_4inch_support
51
- STDOUT.puts "Disabling Retina 4inch support..."
52
- dst = src.split("\n")
53
- src = ""
54
- lines_removed = 0
55
- for line in dst
56
- if line.index("Default-568h@2x.png") == nil
57
- src += "#{line}\n"
58
- else
59
- lines_removed += 1
60
- end
61
- end
62
- if lines_removed > 0
63
- STDOUT.puts "#{lines_removed} lines removed."
64
- else
65
- STDOUT.puts "Default-568h@2x.png not found in this project. No lines removed."
66
- end
67
-
68
- default_png_path = Pathname.new(input + "/../../Default-568h@2x.png").realpath
69
-
70
- FileUtils.mv default_png_path, default_png_path.to_s + ".backup" + Time.now.strftime("%Y%m%d%H%M%S")
71
- end
72
-
73
- # delete the original
74
- FileUtils.rm input
75
-
76
- # write to project.pbxproj
77
- open(input, "w") {|f|
78
- f.puts src
79
- }
40
+ processor = Unigunkan::Processor.new(input, OPTS)
41
+ processor.create_backup
42
+ processor.disable_retina_4inch_support if disable_retina_4inch_support
43
+ processor.delete_original_project_file
44
+ processor.write
@@ -0,0 +1,61 @@
1
+ require 'fileutils'
2
+ require 'pathname'
3
+
4
+ class Unigunkan::Processor
5
+ def initialize(proj_file, opts)
6
+ @proj_file = proj_file
7
+ @opts = opts
8
+
9
+ f = open(@proj_file)
10
+ @src = f.read
11
+ f.close
12
+ end
13
+
14
+ def create_backup
15
+ STDOUT.puts "Creating a backup of project.pbxproj..."
16
+ backup_filepath = @proj_file + ".backup" + Time.now.strftime("%Y%m%d%H%M%S")
17
+ FileUtils.cp(@proj_file, backup_filepath)
18
+ STDOUT.puts "A backup created -> #{backup_filepath}"
19
+ end
20
+
21
+ # Disable iphone5 support
22
+ # (Remove lines which include 'Default-568h@2x.png'.)
23
+ def disable_retina_4inch_support
24
+ src = @src
25
+ STDOUT.puts "Disabling Retina 4inch support..."
26
+ dst = src.split("\n")
27
+ src = ""
28
+ lines_removed = 0
29
+ for line in dst
30
+ if line.index("Default-568h@2x.png") == nil
31
+ src += "#{line}\n"
32
+ else
33
+ lines_removed += 1
34
+ end
35
+ end
36
+ if lines_removed > 0
37
+ STDOUT.puts "#{lines_removed} lines removed."
38
+ else
39
+ STDOUT.puts "Default-568h@2x.png not found in this project. No lines removed."
40
+ end
41
+
42
+ begin
43
+ default_png_path = Pathname.new(@proj_file + "/../../Default-568h@2x.png").realpath
44
+ FileUtils.mv default_png_path, default_png_path.to_s + ".backup" + Time.now.strftime("%Y%m%d%H%M%S")
45
+ rescue
46
+ STDOUT.puts "Warning: No Default-568h@2x.png found."
47
+ end
48
+
49
+ @src = src
50
+ end
51
+
52
+ def delete_original_project_file
53
+ FileUtils.rm @proj_file
54
+ end
55
+
56
+ def write
57
+ open(@proj_file, "w") {|f|
58
+ f.puts @src
59
+ }
60
+ end
61
+ end
@@ -1,3 +1,3 @@
1
1
  module Unigunkan
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/unigunkan.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "unigunkan/version"
2
+ require "unigunkan/processor"
2
3
 
3
4
  module Unigunkan
4
5
  # Your code goes here...
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unigunkan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-05 00:00:00.000000000 Z
12
+ date: 2012-10-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Designed for Unity based projects.
15
15
  email:
@@ -26,6 +26,7 @@ files:
26
26
  - Rakefile
27
27
  - bin/unigunkan
28
28
  - lib/unigunkan.rb
29
+ - lib/unigunkan/processor.rb
29
30
  - lib/unigunkan/version.rb
30
31
  - unigunkan.gemspec
31
32
  homepage: http://github.com/yokoe/unigunkan
@@ -48,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
49
  version: '0'
49
50
  requirements: []
50
51
  rubyforge_project:
51
- rubygems_version: 1.8.24
52
+ rubygems_version: 1.8.23
52
53
  signing_key:
53
54
  specification_version: 3
54
55
  summary: A command line xcode project file modifier.