alki-dsl 0.5.1 → 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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -0
- data/README.adoc +2 -0
- data/alki-dsl.gemspec +4 -3
- data/lib/alki/dsl/evaluator.rb +11 -2
- data/lib/alki/dsl/version.rb +1 -1
- data/test/feature/build_context_test.rb +19 -0
- data/test/feature/runtime_requires_test.rb +30 -0
- metadata +18 -13
- data/bin/bundler +0 -17
- data/bin/rake +0 -17
- data/test/feature/runtime_requires.rb +0 -5
- data/test/unit/evaluator_test.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: e7b46619195a15b77b5c230989b6c6962962ecc8
|
4
|
+
data.tar.gz: 9c447613711f688a2edb558b05528d3ae9bb6fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cd54ade2ff7c3dc76abced31938f4732eb963ddb5c1ea2a1f57dcd26e1a2853fc2746b9a5e7b960c378ea04b0010d5158237e1899d7840dbd16be840d558e3b
|
7
|
+
data.tar.gz: 599afb4c7e3854b83b5a0b2d78f877820328da9d019e0481c3dad31ae98d5721762ecb48590a2afdcd8ed622aeaf789abd489c57953bb0304ed78d0a52fc8977
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.adoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Alki::Dsl
|
2
2
|
|
3
|
+
image:https://travis-ci.org/alki-project/alki-dsl.svg?branch=master["Build Status", link="https://travis-ci.org/alki-project/alki-dsl"]
|
4
|
+
|
3
5
|
Alki::Dsl is a library for building DSLs. The resulting DSL buliders can be used standalone or as builders for
|
4
6
|
https://github.com/alki-project/alki-loader[Alki::Loader].
|
5
7
|
|
data/alki-dsl.gemspec
CHANGED
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.email = ["matt.edlefsen@gmail.com"]
|
9
9
|
spec.summary = %q{Alki dsl library}
|
10
10
|
spec.description = %q{Library for defining and using DSLs}
|
11
|
-
spec.homepage = "
|
11
|
+
spec.homepage = "http://alki.io/projects/alki-dsl"
|
12
12
|
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = '>= 2.1.0'
|
13
14
|
|
14
15
|
spec.files = `git ls-files -z`.split("\x0")
|
15
16
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -17,6 +18,6 @@ Gem::Specification.new do |spec|
|
|
17
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
19
|
spec.require_paths = ["lib"]
|
19
20
|
|
20
|
-
spec.add_dependency 'alki-support', '~> 0.7'
|
21
|
-
spec.add_dependency 'alki-loader', '~> 0.2', '>= 0.2.
|
21
|
+
spec.add_dependency 'alki-support', '~> 0.7', ">= 0.7.1"
|
22
|
+
spec.add_dependency 'alki-loader', '~> 0.2', '>= 0.2.4'
|
22
23
|
end
|
data/lib/alki/dsl/evaluator.rb
CHANGED
@@ -36,11 +36,11 @@ module Alki
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def context
|
39
|
-
|
39
|
+
@context
|
40
40
|
end
|
41
41
|
|
42
42
|
def evaluate(&blk)
|
43
|
-
|
43
|
+
@context = @data[:context] || block_context(blk)
|
44
44
|
@mod.class_exec &blk
|
45
45
|
end
|
46
46
|
|
@@ -95,6 +95,15 @@ module Alki
|
|
95
95
|
@mod.singleton_class.send :remove_method, m
|
96
96
|
end
|
97
97
|
end
|
98
|
+
|
99
|
+
def block_context(blk)
|
100
|
+
b = blk.binding
|
101
|
+
if b.respond_to? :receiver
|
102
|
+
b.receiver
|
103
|
+
else
|
104
|
+
b.eval('self')
|
105
|
+
end
|
106
|
+
end
|
98
107
|
end
|
99
108
|
end
|
100
109
|
end
|
data/lib/alki/dsl/version.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'alki/feature_test'
|
2
|
+
|
3
|
+
describe 'Build Context' do
|
4
|
+
def foo
|
5
|
+
:foo
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
@dsl = Alki::Dsl.build('alki/dsls/dsl') do
|
10
|
+
dsl_method :result do |v|
|
11
|
+
ctx[:result] = v
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be accessable when evaluating a dsl' do
|
17
|
+
@dsl.build { result foo }.must_equal :foo
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'alki/feature_test'
|
2
|
+
|
3
|
+
describe 'Runtime requires' do
|
4
|
+
before do
|
5
|
+
foo_dsl = Alki::Dsl.build('alki/dsls/dsl') do
|
6
|
+
dsl_method :foo do
|
7
|
+
ctx[:result] = :foo
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
@dsl = Alki::Dsl.build('alki/dsls/dsl') do
|
12
|
+
dsl_method :load_foo do
|
13
|
+
require_dsl foo_dsl
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should add the dsl methods to the running dsl' do
|
19
|
+
@dsl.build do
|
20
|
+
load_foo
|
21
|
+
foo
|
22
|
+
end.must_equal :foo
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should not add the dsl methods before it is required' do
|
26
|
+
assert_raises NoMethodError do
|
27
|
+
@dsl.build { foo }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alki-dsl
|
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
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alki-support
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.7'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.7.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0.7'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.7.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: alki-loader
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +39,7 @@ dependencies:
|
|
33
39
|
version: '0.2'
|
34
40
|
- - ">="
|
35
41
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.2.
|
42
|
+
version: 0.2.4
|
37
43
|
type: :runtime
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +49,7 @@ dependencies:
|
|
43
49
|
version: '0.2'
|
44
50
|
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.2.
|
52
|
+
version: 0.2.4
|
47
53
|
description: Library for defining and using DSLs
|
48
54
|
email:
|
49
55
|
- matt.edlefsen@gmail.com
|
@@ -52,12 +58,11 @@ extensions: []
|
|
52
58
|
extra_rdoc_files: []
|
53
59
|
files:
|
54
60
|
- ".gitignore"
|
61
|
+
- ".travis.yml"
|
55
62
|
- Gemfile
|
56
63
|
- README.adoc
|
57
64
|
- Rakefile
|
58
65
|
- alki-dsl.gemspec
|
59
|
-
- bin/bundler
|
60
|
-
- bin/rake
|
61
66
|
- lib/alki/class_builder.rb
|
62
67
|
- lib/alki/dsl.rb
|
63
68
|
- lib/alki/dsl/base.rb
|
@@ -69,9 +74,10 @@ files:
|
|
69
74
|
- lib/alki/dsl/version.rb
|
70
75
|
- lib/alki/dsls/class.rb
|
71
76
|
- lib/alki/dsls/dsl.rb
|
77
|
+
- test/feature/build_context_test.rb
|
72
78
|
- test/feature/config_test.rb
|
73
79
|
- test/feature/merge_test.rb
|
74
|
-
- test/feature/
|
80
|
+
- test/feature/runtime_requires_test.rb
|
75
81
|
- test/feature_test_helper.rb
|
76
82
|
- test/fixtures/example/lib/alki_loader.rb
|
77
83
|
- test/fixtures/example/lib/alki_test/dsls/number.rb
|
@@ -81,8 +87,7 @@ files:
|
|
81
87
|
- test/fixtures/example/numbers/three.rb
|
82
88
|
- test/integration/class_builder_test.rb
|
83
89
|
- test/test_helper.rb
|
84
|
-
|
85
|
-
homepage: https://github.com/medlefsen/alki-dsl
|
90
|
+
homepage: http://alki.io/projects/alki-dsl
|
86
91
|
licenses:
|
87
92
|
- MIT
|
88
93
|
metadata: {}
|
@@ -94,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
99
|
requirements:
|
95
100
|
- - ">="
|
96
101
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
102
|
+
version: 2.1.0
|
98
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
104
|
requirements:
|
100
105
|
- - ">="
|
@@ -102,14 +107,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
107
|
version: '0'
|
103
108
|
requirements: []
|
104
109
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.6.12
|
106
111
|
signing_key:
|
107
112
|
specification_version: 4
|
108
113
|
summary: Alki dsl library
|
109
114
|
test_files:
|
115
|
+
- test/feature/build_context_test.rb
|
110
116
|
- test/feature/config_test.rb
|
111
117
|
- test/feature/merge_test.rb
|
112
|
-
- test/feature/
|
118
|
+
- test/feature/runtime_requires_test.rb
|
113
119
|
- test/feature_test_helper.rb
|
114
120
|
- test/fixtures/example/lib/alki_loader.rb
|
115
121
|
- test/fixtures/example/lib/alki_test/dsls/number.rb
|
@@ -119,4 +125,3 @@ test_files:
|
|
119
125
|
- test/fixtures/example/numbers/three.rb
|
120
126
|
- test/integration/class_builder_test.rb
|
121
127
|
- test/test_helper.rb
|
122
|
-
- test/unit/evaluator_test.rb
|
data/bin/bundler
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
#
|
4
|
-
# This file was generated by Bundler.
|
5
|
-
#
|
6
|
-
# The application 'bundler' is installed as part of a gem, and
|
7
|
-
# this file is here to facilitate running it.
|
8
|
-
#
|
9
|
-
|
10
|
-
require "pathname"
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
-
Pathname.new(__FILE__).realpath)
|
13
|
-
|
14
|
-
require "rubygems"
|
15
|
-
require "bundler/setup"
|
16
|
-
|
17
|
-
load Gem.bin_path("bundler", "bundler")
|
data/bin/rake
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
#
|
4
|
-
# This file was generated by Bundler.
|
5
|
-
#
|
6
|
-
# The application 'rake' is installed as part of a gem, and
|
7
|
-
# this file is here to facilitate running it.
|
8
|
-
#
|
9
|
-
|
10
|
-
require "pathname"
|
11
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
-
Pathname.new(__FILE__).realpath)
|
13
|
-
|
14
|
-
require "rubygems"
|
15
|
-
require "bundler/setup"
|
16
|
-
|
17
|
-
load Gem.bin_path("rake", "rake")
|