alki 0.5.0 → 0.6.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: b62e2164cbf952d15c45aa1845bdd03afac913b0
4
- data.tar.gz: 749ebc7d797b44ec3ecd900d4cb48b2e45af625d
3
+ metadata.gz: d43f615a01e47c804aef85ffd38c686eee21bf51
4
+ data.tar.gz: 87ed48fa6b70d31c1afecc2d8e79c2bced1f3faa
5
5
  SHA512:
6
- metadata.gz: 56a1e7009e25e8c846f13cbeefa8e5043f3d1148675534f6082358f8ed4de0f0a53f146af5ec19219e0d9ec9ecf618abb9e290e1db731d86d28b51cd133c6ef3
7
- data.tar.gz: db587ec5e1a2a6f3594ec7081729b96aa666da5bc2ebceba4c3360fa723befb900c45e9c24e07d4d4c9b29f94a49af8c644ce491f41beb27516737a8c8b62893
6
+ metadata.gz: 3111b599c8899e0962810df466bd66141a40720cddd03425084cb7ac8eb435a48b1212bd098449ae08fb6f2c175c70c176280b5a38b7a0afc02ca23d45f92ab4
7
+ data.tar.gz: 96e3b8c35bb8998d1cee45664a407c16b9f348f3140f17a69d48279835b4d84015e4f0996538a0b2607a6cba2201b909182af184f8ec14b8a26b1fe5975d74e0
data/README.md CHANGED
@@ -1,4 +1,55 @@
1
- # Alki
1
+ # What is Alki?
2
2
 
3
- Basic library for creating applications.
3
+ Alki is a framework for creating projects that are modular, testable, and well organized.
4
4
 
5
+ It's goal is to remove uncertainty and friction when building Ruby projects, allowing developers to focus on implementing business logic.
6
+
7
+ # Synopsis
8
+
9
+ Best place to start would be to check out some examples:
10
+
11
+ * https://github.com/alki-project/alki-example
12
+ * https://github.com/alki-project/alki/test/fixtures/example
13
+
14
+ # The Alki Assembly
15
+
16
+ If a set of classes are the raw materials of your product, an Assembly is the finished product, ready to ship.
17
+
18
+ To get there, you provide Alki with your assembly definition, which acts as the instructions for how to piece together your classes and objects.
19
+
20
+ Assembly definitions are written in a simple DSL and are transformed into classes.
21
+
22
+ ```ruby
23
+ require 'alki'
24
+
25
+ class Printer
26
+ def print(msg)
27
+ puts msg
28
+ end
29
+ end
30
+
31
+ MyAssembly = Alki.create_assembly do
32
+ service :printer do
33
+ Printer.new
34
+ end
35
+ end
36
+
37
+ MyAssembly.new.printer.print "hello world"
38
+ ```
39
+
40
+ ## Project Assemblies
41
+
42
+ While Assemblies can be created directly as in the previous example, most
43
+ of the time an entire project will contain instructions for a single Assembly.
44
+
45
+ To ease this use case, Alki supports a simple standard project layout.
46
+
47
+ * `config` and `lib` directories in your project root.
48
+ * A file called `config/assembly.rb` with your assembly definition inside an `Alki do ... end` block.
49
+ * A file under lib that has the name of your project. For example if your project was called `MyProject`, create a file called `lib/my_project.rb`.
50
+ Inside the file put the following two lines:
51
+
52
+ ```ruby
53
+ require 'alki'
54
+ Alki.project_assembly!
55
+ ```
@@ -1,12 +1,16 @@
1
1
  require 'alki/assembly_builder'
2
2
 
3
3
  module Alki
4
- def self.create_assembly!(opts={},&blk)
5
- opts[:path] ||= caller_locations(1,1)[0].absolute_path
6
- AssemblyBuilder.build(opts,&blk)
7
- end
4
+ class << self
5
+ def project_assembly!(opts={},&blk)
6
+ opts[:project_assembly] ||= caller_locations(1,1)[0].absolute_path
7
+ AssemblyBuilder.build(opts,&blk)
8
+ end
9
+
10
+ alias_method :create_assembly!, :project_assembly!
8
11
 
9
- def self.create_assembly(opts={},&blk)
10
- AssemblyBuilder.build(opts,&blk)
12
+ def create_assembly(opts={},&blk)
13
+ AssemblyBuilder.build(opts,&blk)
14
+ end
11
15
  end
12
16
  end
@@ -21,13 +21,13 @@ module Alki
21
21
  build_assembly blk if blk
22
22
  set_config_directory opts[:config_dir] if opts[:config_dir]
23
23
  set_assembly_name opts[:name] if opts[:name]
24
- detect_from_path opts[:path] if opts[:path]
24
+ setup_project_assembly opts[:project_assembly] if opts[:project_assembly]
25
25
  load_assembly_file opts[:primary_config] unless definition
26
26
  build_empty_assembly unless definition
27
27
  build_class
28
28
  end
29
29
 
30
- def detect_from_path(path)
30
+ def setup_project_assembly(path)
31
31
  root = Alki::Support.find_root(path) do |dir|
32
32
  File.exists?(File.join(dir,'config','assembly.rb')) ||
33
33
  File.exists?(File.join(dir,'Gemfile')) ||
@@ -1,3 +1,3 @@
1
1
  module Alki
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -40,17 +40,17 @@ describe Alki do
40
40
  Object.send :remove_const, :AlkiTest
41
41
  end
42
42
 
43
- it 'should automatically determine config_dir and name if path provided' do
43
+ it 'should automatically determine config_dir and name if project_assembly provided' do
44
44
  was_defined = defined? Tlogger
45
45
  Object.send :remove_const, :Tlogger if was_defined
46
- klass = build(path: fixture_path('tlogger','lib','tlogger.rb'))
46
+ klass = build(project_assembly: fixture_path('tlogger','lib','tlogger.rb'))
47
47
  Tlogger.must_equal klass
48
48
  klass.new.must_respond_to :log
49
49
  Object.send :remove_const, :Tlogger unless was_defined
50
50
  end
51
51
  end
52
52
 
53
- describe :create_assembly! do
53
+ describe :project_assembly! do
54
54
  it 'should automatically set path option using path of caller' do
55
55
  require fixture_path('tlogger','lib','tlogger.rb')
56
56
  Tlogger.new.must_respond_to :log
@@ -1,3 +1,3 @@
1
1
  require 'alki'
2
2
 
3
- Alki.create_assembly!
3
+ Alki.project_assembly!
@@ -1,3 +1,3 @@
1
1
  require 'alki'
2
2
 
3
- Alki.create_assembly!
3
+ Alki.project_assembly!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Edlefsen
@@ -121,7 +121,6 @@ files:
121
121
  - lib/alki/version.rb
122
122
  - test/feature/alki_test.rb
123
123
  - test/feature/example_test.rb
124
- - test/fixtures/config.rb
125
124
  - test/fixtures/example/config/assembly.rb
126
125
  - test/fixtures/example/config/handlers.rb
127
126
  - test/fixtures/example/config/settings.rb
@@ -165,7 +164,6 @@ summary: Base library for building applications.
165
164
  test_files:
166
165
  - test/feature/alki_test.rb
167
166
  - test/feature/example_test.rb
168
- - test/fixtures/config.rb
169
167
  - test/fixtures/example/config/assembly.rb
170
168
  - test/fixtures/example/config/handlers.rb
171
169
  - test/fixtures/example/config/settings.rb
@@ -1,6 +0,0 @@
1
- wait = $wait || 0
2
- $wait =nil
3
- Alki do
4
- wait
5
- end
6
- sleep wait if wait > 0