charyf 0.2.7 → 0.2.8

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: f336e5499d3b8ba1c98487ff346af2546a372e0e
4
- data.tar.gz: 45664cb770c6af8da8c91ee9f82637680041da9a
3
+ metadata.gz: 8cfa0cfb7f56db44ae90413b60cc7a4e52efbcb9
4
+ data.tar.gz: 66ab9d05c60b4b7fec8f7f0fd35fbf1f6ac6154e
5
5
  SHA512:
6
- metadata.gz: e86ec3feae3fe2ec2c2b349346b7f0abcadbf7e88f67e6211e85a29c379a6edb467ab07822a7361876463c09addc4584a50d08188f182e212af653fd38543aef
7
- data.tar.gz: d7432ab641ff21c4a490004ee7e6a26869b3aa25bedc0631b0a462ae78c292b982c1f3495c4aee46466bd6e72cd5795311c70a188cc5a0d660edb9f5cbbd2707
6
+ metadata.gz: 7678c7af6c8606b78880d4bbc44407eb2a16264ceb083b3f3da58be733862b73a6246b6a9a34e581874c675c4617a8513eb89b3a9fede55fe21fc78ea749b0a9
7
+ data.tar.gz: 124617de56346b73fa8b3285e707fd12cc9dedc858052ee5bd73ebf7fdc9d9a7563567d48066b73b3a6d109a06b68f750e4aba507831a2cbc4fc13fec6ae834b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- charyf (0.2.7)
4
+ charyf (0.2.8)
5
5
  charyf_sig (~> 1.1.2)
6
6
  colorize (~> 0.8)
7
7
  i18n (~> 0.9)
@@ -14,7 +14,8 @@ module Charyf
14
14
 
15
15
  require_relative 'generators/app/app_generator'
16
16
  require_relative 'generators/skill/skill_generator'
17
- require_relative 'generators/intents/intents_generator'
17
+ require_relative 'generators/skill/hooks_generator'
18
+ require_relative 'generators/installers/installers_generator'
18
19
 
19
20
  run_generators_blocks(app)
20
21
  self
@@ -2,11 +2,21 @@ module Charyf
2
2
  module Configuration
3
3
 
4
4
  class Generators #:nodoc:
5
- attr_accessor :options
6
- attr_reader :hidden_namespaces
5
+ attr_reader :hidden_namespaces, :installers, :skill_hooks
6
+
7
+ def options
8
+ dup = @options.dup
9
+ dup[:charyf] ||= {}
10
+ dup[:installers] = @installers
11
+ dup[:skill_hooks] = @skill_hooks
12
+
13
+ dup
14
+ end
7
15
 
8
16
  def initialize
9
17
  @hidden_namespaces = []
18
+ @installers = []
19
+ @skill_hooks = []
10
20
  @options = Hash.new { |h, k| h[k] = {} }
11
21
  end
12
22
 
@@ -9,14 +9,15 @@ module Charyf
9
9
  module Generators
10
10
  include Charyf::Command::Behavior
11
11
 
12
- REMOVED_GENERATORS = %w(app cli_app intents)
12
+ REMOVED_GENERATORS = %w(app cli_app skill_hooks installers)
13
13
 
14
14
 
15
15
  DEFAULT_ALIASES = {}
16
16
 
17
17
  DEFAULT_OPTIONS = {
18
18
  charyf: {
19
- intents: true
19
+ # Skill hooks: true => allows automatic call for all hooks when generating new skill
20
+ skill_hooks: true
20
21
  }
21
22
  }
22
23
 
@@ -95,6 +96,8 @@ module Charyf
95
96
  namespaces = public_namespaces
96
97
  namespaces.sort!
97
98
 
99
+ hidden_namespaces.each { |n| namespaces.delete(n.to_s) }
100
+
98
101
  groups = Hash.new { |h, k| h[k] = [] }
99
102
  namespaces.each do |namespace|
100
103
  base = namespace.split(":").first
@@ -105,8 +108,6 @@ module Charyf
105
108
  charyf.map! { |n| n.sub(/^charyf:/, "") }
106
109
  REMOVED_GENERATORS.map { |name| charyf.delete(name) }
107
110
 
108
- hidden_namespaces.each { |n| groups.delete(n.to_s) }
109
-
110
111
  [[ "charyf", charyf ]] + groups.sort.to_a
111
112
  end
112
113
 
@@ -180,6 +180,8 @@ module Charyf
180
180
 
181
181
  public_task :run_bundle
182
182
 
183
+ public_task :run_installers
184
+
183
185
  def run_after_bundle_callbacks
184
186
  @after_bundle_callbacks.each(&:call)
185
187
  end
@@ -255,6 +255,22 @@ module Charyf
255
255
  end
256
256
  end
257
257
 
258
+ def charyf_command(command)
259
+ say_status :run, "charyf #{command}"
260
+
261
+ _charyf_command = Gem.bin_path("charyf", "charyf")
262
+
263
+ require "bundler"
264
+ Bundler.with_clean_env do
265
+ full_command = %Q["#{Gem.ruby}" "#{_charyf_command}" #{command}]
266
+ if options[:quiet]
267
+ system(full_command, out: File::NULL)
268
+ else
269
+ system(full_command)
270
+ end
271
+ end
272
+ end
273
+
258
274
  def bundle_install?
259
275
  !(options[:skip_gemfile] || options[:skip_bundle] || options[:pretend])
260
276
  end
@@ -263,6 +279,10 @@ module Charyf
263
279
  bundle_command("install") if bundle_install?
264
280
  end
265
281
 
282
+ def run_installers
283
+ charyf_command("generate installers") if bundle_install?
284
+ end
285
+
266
286
  def empty_directory_with_keep_file(destination, config = {})
267
287
  empty_directory(destination, config)
268
288
  keep_file(destination)
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../app_base'
4
+ require_relative '../named_base'
5
+
6
+ require_relative '../../generators'
7
+
8
+ require_relative '../../../support'
9
+
10
+ module Charyf
11
+ module Generators
12
+ class InstallersGenerator < Base # :nodoc:
13
+
14
+ def info_msg
15
+ say_status behavior, "Running all hooked installers", :green
16
+ puts ''
17
+ end
18
+
19
+ def try
20
+ hooked_generators.each do |generator_name|
21
+ names = generator_name.to_s.split(":")
22
+ klass = Charyf::Generators.find_by_namespace(names.pop, names.any? && names.join(":"))
23
+
24
+ if klass
25
+ say_status behavior, generator_name, :green
26
+
27
+ invoke generator_name, [], options.merge(autorun: true), behavior: behavior
28
+ else
29
+ say_status behavior, "#{generator_name} generator not found", :red
30
+ end
31
+
32
+ puts ''
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def hooked_generators
39
+ (Charyf::Generators.options[:installers] || []).compact.map(&:downcase)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../app_base'
4
+ require_relative '../named_base'
5
+
6
+ require_relative '../../generators'
7
+
8
+ require_relative '../../../support'
9
+
10
+ module Charyf
11
+ module Generators
12
+ class SkillHooksGenerator < NamedBase # :nodoc:
13
+
14
+ def try
15
+ hooked_generators.each do |generator_name|
16
+ names = generator_name.to_s.split(":")
17
+ klass = Charyf::Generators.find_by_namespace(names.pop, names.any? && names.join(":"))
18
+
19
+ if klass
20
+ say_status behavior, generator_name, :green
21
+
22
+ invoke generator_name, [name], options, behavior: behavior
23
+ else
24
+ say_status behavior, "#{generator_name} generator not found", :red
25
+ end
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def hooked_generators
32
+ (Charyf::Generators.options[:skill_hooks] || []).compact.map(&:downcase)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -40,7 +40,7 @@ module Charyf
40
40
  empty_directory File.join('app/skills', skill_content_path, 'initializers')
41
41
  end
42
42
 
43
- hook_for :intents
43
+ hook_for :skill_hooks
44
44
 
45
45
  end
46
46
  end
@@ -11,7 +11,7 @@ module Charyf
11
11
  module VERSION
12
12
  MAJOR = 0
13
13
  MINOR = 2
14
- TINY = 7
14
+ TINY = 8
15
15
  PRE = nil
16
16
 
17
17
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charyf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Ludvigh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-15 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: charyf_sig
@@ -231,8 +231,9 @@ files:
231
231
  - lib/charyf/utils/generators/app/templates/gitignore
232
232
  - lib/charyf/utils/generators/app_base.rb
233
233
  - lib/charyf/utils/generators/defaults.rb
234
- - lib/charyf/utils/generators/intents/intents_generator.rb
234
+ - lib/charyf/utils/generators/installers/installers_generator.rb
235
235
  - lib/charyf/utils/generators/named_base.rb
236
+ - lib/charyf/utils/generators/skill/hooks_generator.rb
236
237
  - lib/charyf/utils/generators/skill/skill_generator.rb
237
238
  - lib/charyf/utils/generators/skill/templates/controllers/skill_controller.rb.tt
238
239
  - lib/charyf/utils/generators/skill/templates/module.rb.tt
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../app_base'
4
- require_relative '../named_base'
5
-
6
- require_relative '../../generators'
7
-
8
- require_relative '../../../support'
9
-
10
- module Charyf
11
- module Generators
12
- class IntentsGenerator < NamedBase # :nodoc:
13
-
14
- def try
15
- intent_generators.each do |generator_name|
16
- names = generator_name(generator_name).to_s.split(":")
17
- klass = Charyf::Generators.find_by_namespace(names.pop, names.any? && names.join(":"))
18
-
19
- if klass
20
- say_status behavior, generator_name(generator_name), :green
21
-
22
- invoke generator_name(generator_name), [name], options, behavior: behavior
23
- else
24
- say_status behavior, "#{generator_name(generator_name)} generator not found", :red
25
- end
26
- end
27
- end
28
-
29
- private
30
-
31
- def intent_generators
32
- (Charyf::Generators.options[:intents] || {}).keys.map(&:downcase)
33
- end
34
-
35
- def generator_name(intent_processor_name)
36
- "#{intent_processor_name}:intent"
37
- end
38
-
39
- end
40
- end
41
- end