foobar_templates 2.0.1.rc2 → 2.0.1.rc3

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
  SHA256:
3
- metadata.gz: ef1e2cd0e959fef6c0ac4f5e4475675f8ea8c9b4c60d818ff3606ca94d2638a7
4
- data.tar.gz: e5d6e2ef6a066ad687a0509eb80d199f7d381307bf4ea2470f8f45f9c6eca274
3
+ metadata.gz: f6f830e123079c5b60a6cd7f799df40f0615b6326565814e837029ea6a8d69e9
4
+ data.tar.gz: 8d19d2bad9ee276d489657f9de11ef0ac8e9929a92d7fa08d95b2f9e609bc9d4
5
5
  SHA512:
6
- metadata.gz: 59087e7c7d265a35bc574ef126d11ff253b3c4970ce156e1d3edc0bbfb67d73f39f0894498f6594f9eb2e63e1fc7307803fe9e243bfe000fae7bc985d14b3484
7
- data.tar.gz: cd0ee89ddd0b52b6ab18c222deb7af07a933cc253428861ffd6e276943b9f70225e95ca8a95e4a502a89989358596d372020d75628fe532bfab9c048fe70f336
6
+ metadata.gz: 2e2abe9daa3749abab39f10fbb110b8262541fd2ebba6f74d4c6d0bf85fe97d3e05a6745f05cb05fbb27db532c2c2d99945afe028e90dba066335648669ad998
7
+ data.tar.gz: df73ec40e11c12ac8316ab4c6105ac0d9ea895f2ca049b6b676b44660d7656df8041411ef38775d30e98f1d5a6909c2e4cb70e0210769b94d69eebfa6ffa7025
data/bin/foobar_templates CHANGED
@@ -29,6 +29,10 @@ parser = OptionParser.new do |opts|
29
29
  exit
30
30
  end
31
31
 
32
+ opts.on("-p", "--performance", "Show performance metrics for template generation") do
33
+ options[:performance] = true
34
+ end
35
+
32
36
  opts.on("--install-public-templates", "Install public templates") do
33
37
  FoobarTemplates.install_public_templates
34
38
  exit
@@ -23,53 +23,67 @@ module FoobarTemplates::CLI
23
23
  end
24
24
 
25
25
  def config
26
- @config ||= build_interpolation_config
26
+ @config ||= time_it("build_interpolation_config") { build_interpolation_config }
27
27
  end
28
28
 
29
29
  def run
30
- puts "Beginning run" if $TRACE
31
- raise_project_with_that_name_already_exists! if File.exist?(target)
30
+ time_it("TOTAL run") do
31
+ puts "Beginning run" if $TRACE
32
+ raise_project_with_that_name_already_exists! if File.exist?(target)
32
33
 
33
- puts "ensure_safe_project_name" if $TRACE
34
- ensure_safe_project_name(name, config[:constant_array])
34
+ puts "ensure_safe_project_name" if $TRACE
35
+ time_it("ensure_safe_project_name") do
36
+ ensure_safe_project_name(name, config[:constant_array])
37
+ end
35
38
 
36
- puts "run_name_validation" if $TRACE
37
- run_name_validation
39
+ puts "run_name_validation" if $TRACE
40
+ time_it("run_name_validation") { run_name_validation }
38
41
 
39
- template_src = match_template_src
42
+ template_src = time_it("match_template_src") { match_template_src }
40
43
 
41
- puts "dynamically_generate_template_directories" if $TRACE
42
- time_it("dynamically_generate_template_directories") do
43
- @template_directories = dynamically_generate_template_directories
44
- end
44
+ puts "dynamically_generate_template_directories" if $TRACE
45
+ @template_directories = time_it("dynamically_generate_template_directories") do
46
+ dynamically_generate_template_directories
47
+ end
45
48
 
46
- puts "dynamically_generate_templates_files" if $TRACE
47
- templates = dynamically_generate_templates_files
49
+ puts "dynamically_generate_templates_files" if $TRACE
50
+ templates = time_it("dynamically_generate_templates_files") do
51
+ dynamically_generate_templates_files
52
+ end
48
53
 
49
- puts "Creating new project folder '#{name}'\n\n"
50
- create_template_directories(@template_directories, target)
54
+ puts "Creating new project folder '#{name}'\n\n"
55
+ time_it("create_template_directories") do
56
+ create_template_directories(@template_directories, target)
57
+ end
51
58
 
52
- templates.each do |src, dst|
53
- template("#{template_src}/#{src}", target.join(dst), config)
54
- end
59
+ time_it("write_template_files") do
60
+ templates.each do |src, dst|
61
+ template("#{template_src}/#{src}", target.join(dst), config)
62
+ end
63
+ end
55
64
 
56
- Dir.chdir(target) do
57
- if @configurator.always_perform_git_init || !inside_git_work_tree?
58
- `git init`
65
+ time_it("git_init_and_add") do
66
+ Dir.chdir(target) do
67
+ if @configurator.always_perform_git_init || !inside_git_work_tree?
68
+ `git init`
69
+ end
70
+ `git add .`
71
+ end
59
72
  end
60
- `git add .`
61
- end
62
73
 
63
- if @tconf[:bootstrap_command]
64
- puts "Executing bootstrap_command"
65
- cmd = safe_gsub_template_variables(@tconf[:bootstrap_command])
66
- puts cmd
67
- Dir.chdir(target) do
68
- `#{cmd}`
74
+ if @tconf[:bootstrap_command]
75
+ puts "Executing bootstrap_command"
76
+ cmd = safe_gsub_template_variables(@tconf[:bootstrap_command])
77
+ puts cmd
78
+ time_it("bootstrap_command") do
79
+ Dir.chdir(target) do
80
+ `#{cmd}`
81
+ end
82
+ end
69
83
  end
70
- end
71
84
 
72
- puts "\nComplete."
85
+ puts "\nComplete."
86
+ end
73
87
  end
74
88
 
75
89
  def build_interpolation_config
@@ -84,7 +98,9 @@ module FoobarTemplates::CLI
84
98
  git_user_email = `git config user.email`.chomp
85
99
 
86
100
  # Resolve domain values from ~/.foobar/config, prompting if needed
87
- required_domains = scan_template_for_required_domains
101
+ required_domains = time_it("scan_template_for_required_domains") do
102
+ scan_template_for_required_domains
103
+ end
88
104
  prompt_for_missing_domains(required_domains)
89
105
 
90
106
  registry_domain = @configurator.domain('registry_domain')
@@ -296,7 +312,9 @@ module FoobarTemplates::CLI
296
312
  # .git directory and any gitignored paths. Ignored directories are pruned
297
313
  # during traversal so their (potentially huge) contents are never walked.
298
314
  def template_relative_paths
299
- @template_relative_paths ||= collect_non_ignored_paths(@template_src)
315
+ @template_relative_paths ||= time_it("collect_non_ignored_paths") do
316
+ collect_non_ignored_paths(@template_src)
317
+ end
300
318
  end
301
319
 
302
320
  # Breadth-first walk that prunes ignored directories. One batched
@@ -476,11 +494,18 @@ Exiting...
476
494
  end
477
495
 
478
496
  def time_it(label = nil)
497
+ return yield unless performance?
498
+
479
499
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
480
- yield
500
+ result = yield
481
501
  end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
482
502
  elapsed_ms = ((end_time - start_time) * 1000).round(2)
483
503
  puts "#{label || 'Elapsed'}: #{elapsed_ms} ms"
504
+ result
505
+ end
506
+
507
+ def performance?
508
+ @options[:performance]
484
509
  end
485
510
 
486
511
  # This checks to see that the gem_name is a valid ruby gem name and will 'work'
@@ -1,3 +1,3 @@
1
1
  module FoobarTemplates
2
- VERSION = "2.0.1.rc2"
2
+ VERSION = "2.0.1.rc3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobar_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1.rc2
4
+ version: 2.0.1.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TheNotary
@@ -130,9 +130,9 @@ licenses:
130
130
  - MIT
131
131
  metadata:
132
132
  bug_tracker_uri: https://github.com/TheNotary/foobar_templates/issues
133
- changelog_uri: https://github.com/TheNotary/foobar_templates/releases/tag/v2.0.1.rc2
133
+ changelog_uri: https://github.com/TheNotary/foobar_templates/releases/tag/v2.0.1.rc3
134
134
  documentation_uri: https://github.com/TheNotary/foobar_templates
135
- source_code_uri: https://github.com/TheNotary/foobar_templates/tree/v2.0.1.rc2
135
+ source_code_uri: https://github.com/TheNotary/foobar_templates/tree/v2.0.1.rc3
136
136
  rdoc_options: []
137
137
  require_paths:
138
138
  - lib