mimi-core 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # When required, `mimi/core/rake` loads all rake tasks exported by *loaded* modules
4
+ # and current application (found under `app_root_path`).
5
+ #
6
+ # Usage:
7
+ #
8
+ # ```ruby
9
+ # # lib/my_app.rb
10
+ # require 'mimi/core'
11
+ # require 'mimi/db'
12
+ #
13
+ #
14
+ # # lib/tasks/my_task.rake
15
+ # desc 'My application task'
16
+ # task :my_task do
17
+ # puts
18
+ # end
19
+ #
20
+ #
21
+ # # Rakefile
22
+ # require_relative 'lib/my_app'
23
+ # require 'mimi/core/rake'
24
+ # ```
25
+ #
26
+ # This makes rake tasks exported by `mimi-db` and other loaded modules available:
27
+ #
28
+ # ```ruby
29
+ # $ rake -T
30
+ # rake db:clear # Clear database
31
+ # rake db:config # Show database config
32
+ # rake db:create # Create database
33
+ # ...
34
+ # rake my_task # My application task
35
+ # ```
36
+ #
37
+ #
1
38
  module Mimi
2
39
  module Core
40
+ #
41
+ # Mimi::Core::Rake module contains various rake helpers
42
+ #
3
43
  module Rake
44
+ #
45
+ # Loads rake tasks exported by *loaded* modules
46
+ #
4
47
  def self.load_rake_tasks
48
+ unless Mimi.respond_to?(:app_root_path)
49
+ raise 'Cannot load rake tasks before mimi-core module is loaded'
50
+ end
5
51
  app_and_modules_paths = [Mimi.app_root_path] + Mimi.loaded_modules_paths
6
52
  rakefiles = app_and_modules_paths.map do |path|
7
53
  Pathname.glob(path.join('lib', 'tasks', '**', '*.rake'))
@@ -1,5 +1,5 @@
1
1
  module Mimi
2
2
  module Core
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
5
5
  end
data/lib/mimi/core.rb CHANGED
@@ -1,6 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Mimi
6
+ #
7
+ # `Mimi::Core` extends the `Mimi` namespace with its instance methods.
8
+ #
4
9
  module Core
5
10
  # Returns the application's root path.
6
11
  #
@@ -8,12 +13,17 @@ module Mimi
8
13
  # If you need to use a different path as the app root path,
9
14
  # use #app_root_path=()
10
15
  #
16
+ # @return [Pathname]
17
+ #
11
18
  def app_root_path
12
19
  @app_root_path ||= Pathname.pwd.expand_path
13
20
  end
14
21
 
15
22
  # Sets the application's root path explicitly
16
23
  #
24
+ # @param path [String,Pathname]
25
+ # @return [Pathname]
26
+ #
17
27
  def app_root_path=(path)
18
28
  @app_root_path = Pathname.new(path).expand_path
19
29
  end
@@ -24,12 +34,21 @@ module Mimi
24
34
  # Mimi.app_root_path # => /path/to/my_app
25
35
  # Mimi.app_path_to('app', 'models') # => /path/to/my_app/app/models
26
36
  #
37
+ # @param args [Array<String,Pathname>]
38
+ # @return [Pathname]
39
+ #
27
40
  def app_path_to(*args)
28
41
  app_root_path.join(*args)
29
42
  end
30
43
 
31
44
  # Use the given module
32
45
  #
46
+ # Includes the module in the list of *used* Mimi modules. Used modules are automatically
47
+ # started/stopped when Mimi.start is performed, in the order of appending.
48
+ #
49
+ # @param mod [Module]
50
+ # @param opts [Hash,nil] optional parameters to be passed to the module's .configure method
51
+ #
33
52
  def use(mod, opts = {})
34
53
  raise ArgumentError, "#{mod} is not a Mimi module" unless mod < Mimi::Core::Module
35
54
  mod.configure(opts)
@@ -37,7 +56,9 @@ module Mimi
37
56
  true
38
57
  end
39
58
 
40
- # Returns the list of loaded (require-d) modules
59
+ # Returns the list of loaded (require'd) modules
60
+ #
61
+ # @return [Array<Module>]
41
62
  #
42
63
  def loaded_modules
43
64
  @loaded_modules ||= []
@@ -45,18 +66,25 @@ module Mimi
45
66
 
46
67
  # Returns the list of used modules
47
68
  #
69
+ # @return [Array<Module>]
70
+ #
48
71
  def used_modules
49
72
  @used_modules ||= []
50
73
  end
51
74
 
52
75
  # Returns all loaded module paths, which are defined (non nil)
53
76
  #
77
+ # @return [Array<Pathname>]
78
+ #
54
79
  def loaded_modules_paths
55
80
  loaded_modules.map(&:module_path).reject(&:nil?)
56
81
  end
57
82
 
58
83
  # Requires all files that match the glob.
59
84
  #
85
+ # @param glob [String]
86
+ # @param root_path [Pathname,nil] if not specified, app_root_path will be used
87
+ #
60
88
  def require_files(glob, root_path = app_root_path)
61
89
  Pathname.glob(root_path.join(glob)).each do |filename|
62
90
  require filename.expand_path
@@ -81,5 +109,7 @@ module Mimi
81
109
  end # module Mimi
82
110
 
83
111
  require_relative 'core/version'
84
- require_relative 'core/module'
85
112
  require_relative 'core/core_ext'
113
+ require_relative 'core/inheritable_property'
114
+ require_relative 'core/module'
115
+ require_relative 'core/manifest'
data/mimi-core.gemspec CHANGED
@@ -27,8 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_dependency 'activesupport', '~> 5.0'
31
- spec.add_dependency 'hashie', '~> 3.4'
30
+ spec.add_dependency 'hashie', '~> 3.6'
32
31
 
33
32
  spec.add_development_dependency 'bundler', '~> 1.11'
34
33
  spec.add_development_dependency 'pry', '~> 0.10'
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimi-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kukushkin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-05 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '5.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: hashie
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '3.4'
19
+ version: '3.6'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: '3.4'
26
+ version: '3.6'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +90,7 @@ files:
104
90
  - ".gitignore"
105
91
  - ".rspec"
106
92
  - ".travis.yml"
93
+ - ".yardopts"
107
94
  - CODE_OF_CONDUCT.md
108
95
  - Gemfile
109
96
  - LICENSE.txt
@@ -113,6 +100,8 @@ files:
113
100
  - bin/setup
114
101
  - lib/mimi/core.rb
115
102
  - lib/mimi/core/core_ext.rb
103
+ - lib/mimi/core/inheritable_property.rb
104
+ - lib/mimi/core/manifest.rb
116
105
  - lib/mimi/core/module.rb
117
106
  - lib/mimi/core/rake.rb
118
107
  - lib/mimi/core/version.rb
@@ -138,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
127
  version: '0'
139
128
  requirements: []
140
129
  rubyforge_project:
141
- rubygems_version: 2.5.2
130
+ rubygems_version: 2.6.14.4
142
131
  signing_key:
143
132
  specification_version: 4
144
133
  summary: Core module for mimi, microframework for microservices