generamba 0.7.7 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75fd8f09b867e3a63ea18b53a9d78d82eb1123f3
4
- data.tar.gz: 83c57bda10c9a4cf25c28ab9724c1b4a1e606826
3
+ metadata.gz: 8b7d38bed5812d081bc9af321e8f0b42b05315ad
4
+ data.tar.gz: 1bf9e9e8721031880b58a854028a8769e34ad31b
5
5
  SHA512:
6
- metadata.gz: 1aa8ae6ebdd3b662865a14926857eb6d925651ce4f4779346484a4476587d7a926895e8929a2063b120246fc3623004ba8644aee35a2739d0b9bd4a4eed3d65c
7
- data.tar.gz: 0cdb99df08c246ceda3c59abeafc48483d2bfe77a9f2a2f1bc2f95a10a68e310531b4e809dff643fe4d1c4be820e5f5e6decee4f020b8e9a0589e8e7ddf64714
6
+ metadata.gz: 5cff9119fe6f9329a0d9bbd008568396dac8c6b91c2e4004d0933684b47df98744ad9fbc5d798549a4a5fbef455363c5cd82cb347e517c4ca6e03e69d28ae2be
7
+ data.tar.gz: 669f7d7e3979766e6b68837ec2720390ec9722b4318c2b7d960df4be2402d8899daa8091f26b4b1018a201e8e1fdb147a202c712dfd10ff727a362cb3da0bf65
@@ -12,6 +12,7 @@ module Generamba
12
12
  TEMPLATE_FILE_NAME_KEY = 'name'
13
13
  TEMPLATE_FILE_PATH_KEY = 'path'
14
14
  TEMPLATE_FILE_FILENAME_KEY = 'file_name'
15
+ TEMPLATE_FILE_FILETYPE_KEY = 'file_type'
15
16
 
16
17
  TEMPLATE_DEPENDENCIES_KEY = 'dependencies'
17
18
  end
@@ -16,9 +16,10 @@ module Generamba
16
16
  # @param targets_name [String] Array of targets name
17
17
  # @param group_path [Pathname] The Xcode group path for current file
18
18
  # @param file_path [Pathname] The file path for current file
19
+ # @param file_type is either 'source' or 'resource' - it affects on where file will be added. Put nil for autodetect
19
20
  #
20
21
  # @return [void]
21
- def self.add_file_to_project_and_targets(project, targets_name, group_path, file_path)
22
+ def self.add_file_to_project_and_targets(project, targets_name, group_path, file_path, file_type = nil)
22
23
  module_group = self.retreive_group_or_create_if_needed(group_path, project, true)
23
24
  xcode_file = module_group.new_file(File.absolute_path(file_path))
24
25
 
@@ -26,12 +27,31 @@ module Generamba
26
27
  targets_name.each do |target|
27
28
  xcode_target = self.obtain_target(target, project)
28
29
 
29
- if self.is_compile_source?(file_name)
30
- xcode_target.add_file_references([xcode_file])
31
- elsif self.is_bundle_resource?(file_name)
32
- xcode_target.add_resources([xcode_file])
30
+ unless file_type
31
+ if self.is_compile_source?(file_name)
32
+ file_type = 'source'
33
+ elsif self.is_bundle_resource?(file_name)
34
+ file_type = 'resource'
35
+ end
33
36
  end
34
-
37
+
38
+ self.add_file_to_target(xcode_target, xcode_file, file_type)
39
+ end
40
+ end
41
+
42
+ # Adds xcode file to target based on it's type
43
+ # @param target [Xcodeproj::AbstractTarget] xcode target to use
44
+ # @param file [Xcodeproj::PBXFileReference] file reference to add
45
+ # @param type [String] is either 'source' or 'resource'
46
+ #
47
+ def self.add_file_to_target(target, file, type)
48
+ case type
49
+ when 'source'
50
+ target.add_file_references([file])
51
+ when 'resource'
52
+ target.add_resources([file])
53
+ else
54
+ puts "Can't add file with type #{type}. Only 'source' and 'resource' are acceptable"
35
55
  end
36
56
  end
37
57
 
@@ -80,9 +80,11 @@ module Generamba
80
80
  File.open(file_path, 'w+') do |f|
81
81
  f.write(file_content)
82
82
  end
83
+
84
+ file_type = file[TEMPLATE_FILE_FILETYPE_KEY]
83
85
 
84
86
  # Creating the file in the Xcode project
85
- XcodeprojHelper.add_file_to_project_and_targets(project, targets, group_path.join(file_group), file_path)
87
+ XcodeprojHelper.add_file_to_project_and_targets(project, targets, group_path.join(file_group), file_path, file_type)
86
88
  end
87
89
  end
88
90
  end
@@ -1,3 +1,3 @@
1
1
  module Generamba
2
- VERSION = '0.7.7'
2
+ VERSION = '0.7.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generamba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Tolstoy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-05-10 00:00:00.000000000 Z
13
+ date: 2016-05-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor