xfabricator 1.0.1 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba35ba380ab4c6735093f867d3ce107212f18b76
4
- data.tar.gz: e14183712633b0fb740e164b4c5acebc8ea25f99
3
+ metadata.gz: 93149bb48e6ba66cee41a8cb892062e7280ed962
4
+ data.tar.gz: 20772395ef2ab5791cdaa9b129354d8e204c44a0
5
5
  SHA512:
6
- metadata.gz: 4b8c31ec9f20f75d26f38831ade4abe407f651ca3de109e4e8f7c874bbcba0de1e131e2bb0d0c8c62aefa637079f92c433f201bd80854e09130b70610ba2ad91
7
- data.tar.gz: fa90829afa3126069b0872ee913e5211291b291b33f78789aaee44c16b3f85451f786c81f2633787442c423d09d463988edf3622ba6350471cc0d362455019ee
6
+ metadata.gz: 87e8764a79ed760041dc3c608e75dcc14f502b066013d4d112cb894425990b2ef7f2266bda7427cd7c3a46aedc5efc4ffd5d388f373f495e7fc7ff031f5cd51e
7
+ data.tar.gz: b04118bab2064cb01bcb467ced6f7061b1a1f2cd460b0db393edc72b22da6da2dbcab9eea84cace7db6ad24d720247ca497a37ebe22c0ad7f25058b8f1d97863
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Is a command line tool that generates files from mustache templates and add them directly to an xcode project.
4
4
 
5
- * Generated files can be added to specific targets, groups
6
- * Generated files can be added to groups automatically based on the path
5
+ * Generated files can be added to specific targets & groups
6
+ * Generated files can be added to groups automatically based on the present working directory or specified path
7
7
 
8
8
  ## Installation
9
9
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'inquirer'
5
+ require 'active_support/core_ext/hash'
5
6
  require 'xfabricator/fabricator'
6
7
  require 'xfabricator/fabrication_config'
7
8
  require 'xfabricator/template_definition'
@@ -26,7 +27,7 @@ class XFabricate
26
27
  @config = FabricationConfig.load_config xfabricate_file
27
28
  end
28
29
 
29
- def fabricate(template_name, target_name, output_path, group_name)
30
+ def fabricate(template_name, target_name, output_path, group_name, initial_variables = {})
30
31
  unless template_name
31
32
  raise ArgumentError, 'name of template to fabricate not specified'
32
33
  end
@@ -41,11 +42,16 @@ class XFabricate
41
42
  template = TemplateDefinition.load_definition Pathname.new(template_file)
42
43
 
43
44
  prompts = template.variable_prompts
44
- variables = @config.variables ? @config.variables : {}
45
+ variables = initial_variables.with_indifferent_access
46
+ variables = variables.merge( @config.variables ) if @config.variables
47
+
48
+ puts "existing variables #{variables}"
45
49
 
46
50
  prompts.each do |variable, prompt|
51
+ unless variables[variable]
47
52
  value = Ask.input prompt
48
53
  variables[variable] = value
54
+ end
49
55
  end
50
56
 
51
57
  fabricator.fabricate template, variables, target_name unless group_name
@@ -80,6 +86,8 @@ end
80
86
  options = {}
81
87
  options[:path] = Pathname.pwd
82
88
 
89
+ variables = {}
90
+
83
91
  OptionParser.new do |opts|
84
92
  opts.banner = "Usage: xfabricate [options]"
85
93
 
@@ -99,9 +107,14 @@ OptionParser.new do |opts|
99
107
  options[:path] = Pathname.new(path).expand_path
100
108
  end
101
109
 
110
+ opts.on("-k key_value", "--var=key_value", "specify variables seperated key and value by a colon '-k variable:value'") do |variable|
111
+ key_value = variable.split(':', 2)
112
+ variables[key_value[0]] = key_value[1]
113
+ end
114
+
102
115
  end.parse!
103
116
 
104
117
  raise OptionParser::MissingArgument if options[:template].nil?
105
118
 
106
119
  xfabricate = Xfabricator::XFabricate.new Xfabricator::XFabricate.locate_file(".xfabricate")
107
- xfabricate.fabricate options[:template], options[:target], options[:path], options[:group]
120
+ xfabricate.fabricate options[:template], options[:target], options[:path], options[:group], variables
@@ -1,3 +1,3 @@
1
1
  module Xfabricator
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -26,5 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "xcodeproj", "~> 1.4"
27
27
  spec.add_development_dependency "mustache", "~> 1.0"
28
28
  spec.add_development_dependency "inquirer", "~> 0"
29
+ spec.add_development_dependency "active_support", "~> 3.2"
29
30
 
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xfabricator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Cross
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: active_support
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
83
97
  description: Generate file templates and add them to XCode project...
84
98
  email:
85
99
  executables: