alki 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +53 -2
- data/lib/alki.rb +10 -6
- data/lib/alki/assembly_builder.rb +2 -2
- data/lib/alki/version.rb +1 -1
- data/test/feature/alki_test.rb +3 -3
- data/test/fixtures/example/lib/example.rb +1 -1
- data/test/fixtures/tlogger/lib/tlogger.rb +1 -1
- metadata +1 -3
- data/test/fixtures/config.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d43f615a01e47c804aef85ffd38c686eee21bf51
|
4
|
+
data.tar.gz: 87ed48fa6b70d31c1afecc2d8e79c2bced1f3faa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
+
```
|
data/lib/alki.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'alki/assembly_builder'
|
2
2
|
|
3
3
|
module Alki
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
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
|
-
|
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
|
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')) ||
|
data/lib/alki/version.rb
CHANGED
data/test/feature/alki_test.rb
CHANGED
@@ -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
|
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(
|
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 :
|
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
|
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.
|
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
|