rubinius-toolset 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +59 -7
- data/lib/rubinius/toolset/version.rb +2 -2
- data/lib/rubinius/toolset.rb +27 -52
- data/rubinius-toolset.gemspec +2 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/toolset_spec.rb +24 -46
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f0825196ed5777cfc710909b29e10aa3d20667
|
4
|
+
data.tar.gz: 5a72876dca2c3aebbf9a66a06dfd74ac617b0bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f19965971f1a89d744fcba5561f756955149f9464df94084f4aa87c7c68180193de60f2008f6b0e5e53cdb22bd0fc5bd1a06fcc935627760857b92fb0ac53661
|
7
|
+
data.tar.gz: 7eb5c692a474c1cf7464abfc1eab50df70fddae78d8cafe3e7e8cdaca26db05af370fc4ae48457ea954bbdc8744c6c4f51e13473c608295c24e71fc452fc17c4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Rubinius::
|
1
|
+
# Rubinius::Toolsets
|
2
2
|
|
3
|
-
Rubinius::
|
4
|
-
the Rubinius bytecode compiler and parser. These, in turn, depend on
|
5
|
-
other components like the AST and bytecode emitter and serializer.
|
3
|
+
Rubinius::ToolSets provides a registry for code tools.
|
6
4
|
|
7
|
-
ToolSets provide a mechanism for
|
8
|
-
the Rubinius
|
5
|
+
The goal of ToolSets is to provide a mechanism for sharing as much as possible
|
6
|
+
between the Rubinius build tools (e.g. the parser, the AST, tools to operate
|
7
|
+
on bytecode) and custom build tools for specific tasks or for other languages
|
8
|
+
targeting Rubinius.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -23,7 +23,59 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
|
26
|
+
There are two operations on ToolSets:
|
27
|
+
|
28
|
+
1. Creating a new ToolSet.
|
29
|
+
2. Accessing the current ToolSet.
|
30
|
+
|
31
|
+
Create a new ToolSet before defining or loading the classes and modules that
|
32
|
+
implement code tools. Access the current ToolSet to build up its various parts
|
33
|
+
as a consistent whole.
|
34
|
+
|
35
|
+
To define a ToolSet in separate pieces, use the following example:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# my_code_tools.rb
|
39
|
+
# Entry point to defining MyCodeTools
|
40
|
+
Rubinius::ToolSets.create :my_code_tools
|
41
|
+
|
42
|
+
# my_code_tools/some_tool.rb
|
43
|
+
module Rubinius::ToolSets.current::ToolSet
|
44
|
+
# define a tool
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Alternatively, define a ToolSet by requiring files in a block as follows:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
Rubinius::ToolSets.create :my_code_tools do
|
52
|
+
require "my_code_tools"
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
The advantage of the latter approach is that multiple ToolSets can be created
|
57
|
+
from some of the same files because `$LOADED_FEATURES` are reset when yielding
|
58
|
+
to the block.
|
59
|
+
|
60
|
+
## Reference
|
61
|
+
|
62
|
+
### Rubinius::ToolSets.create([name [, &block]])
|
63
|
+
|
64
|
+
Creates a new ToolSet.
|
65
|
+
|
66
|
+
If name is not given, the ToolSet is not assigned to a constant under
|
67
|
+
`Rubinius::ToolSets`. If the name is given, it is camelized and set as a
|
68
|
+
constant under Rubinius::ToolSets.
|
69
|
+
|
70
|
+
If a block is passed, `$LOADED_FEATURES` is cleared before yielding to the
|
71
|
+
block and reset afterwards. The ToolSet is yielded to the block.
|
72
|
+
|
73
|
+
Calling `Rubinius::ToolSet.create` a second time creates a new ToolSet.
|
74
|
+
|
75
|
+
### Rubinius::ToolSets.current
|
76
|
+
|
77
|
+
Returns the ToolSet that is being defined. If called before `.create`, a new,
|
78
|
+
anonymous ToolSet is created.
|
27
79
|
|
28
80
|
## Contributing
|
29
81
|
|
data/lib/rubinius/toolset.rb
CHANGED
@@ -1,60 +1,35 @@
|
|
1
1
|
require "rubinius/toolset/version"
|
2
2
|
|
3
3
|
module Rubinius
|
4
|
-
module
|
5
|
-
#
|
6
|
-
|
7
|
-
@current ||= Module.new
|
8
|
-
end
|
9
|
-
|
10
|
-
# Start a new toolset module by clearing out the current one
|
11
|
-
def self.start
|
12
|
-
@current = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
# Access the Hash containing the finished toolset modules
|
16
|
-
def self.map
|
17
|
-
@map ||= {}
|
18
|
-
end
|
19
|
-
|
20
|
-
# Finish the current toolset module by registering it with a name
|
21
|
-
def self.finish(name)
|
22
|
-
ts = current::TS
|
23
|
-
ts.const_set :ToolSet, ts
|
24
|
-
map[name] = ts
|
25
|
-
const_set name.to_s.capitalize.to_sym, ts
|
26
|
-
end
|
27
|
-
|
28
|
-
# Get a finished toolset module by name
|
29
|
-
def self.get(name)
|
30
|
-
map[name]
|
31
|
-
end
|
32
|
-
|
33
|
-
# Set the current toolset module as a constant on Rubinius::ToolSet
|
34
|
-
def self.attach(name)
|
35
|
-
return unless name
|
36
|
-
|
37
|
-
map[name] = current
|
38
|
-
|
39
|
-
name = name.to_s.split("_").map { |x| x.capitalize }.join
|
40
|
-
const_set name, current
|
41
|
-
|
42
|
-
current.const_set :TS, current
|
43
|
-
current::TS.const_set :ToolSet, current
|
44
|
-
end
|
45
|
-
|
46
|
-
# Create a new toolset, optionally with a name. The module enclosing the
|
47
|
-
# toolset yielded to the block.
|
4
|
+
module ToolSets
|
5
|
+
# Create a new ToolSet, with an optional name. The ToolSet is yielded to
|
6
|
+
# the optional block.
|
48
7
|
def self.create(name=nil)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
8
|
+
@current = Module.new
|
9
|
+
@current.const_set :ToolSet, @current
|
10
|
+
|
11
|
+
if name
|
12
|
+
name = name.to_s.split("_").map { |x| x.capitalize }.join
|
13
|
+
const_set name, @current
|
14
|
+
end
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
begin
|
18
|
+
loaded_features = $LOADED_FEATURES
|
19
|
+
$LOADED_FEATURES.clear
|
20
|
+
|
21
|
+
yield @current
|
22
|
+
ensure
|
23
|
+
$LOADED_FEATURES.replace loaded_features
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@current
|
28
|
+
end
|
54
29
|
|
55
|
-
|
56
|
-
|
57
|
-
|
30
|
+
# Returns the current ToolSet.
|
31
|
+
def self.current
|
32
|
+
@current ||= create
|
58
33
|
end
|
59
34
|
end
|
60
35
|
end
|
data/rubinius-toolset.gemspec
CHANGED
@@ -3,7 +3,7 @@ require './lib/rubinius/toolset/version'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "rubinius-toolset"
|
6
|
-
spec.version = Rubinius::
|
6
|
+
spec.version = Rubinius::ToolSets::VERSION
|
7
7
|
spec.authors = ["Brian Shirai"]
|
8
8
|
spec.email = ["brixen@gmail.com"]
|
9
9
|
spec.description = <<-EOD
|
@@ -26,4 +26,5 @@ the Rubinius code tools as are suitable for that language.
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
28
|
spec.add_development_dependency "mspec", "~> 1.5"
|
29
|
+
spec.add_development_dependency "rubinius-bridge", "~> 1.0"
|
29
30
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/toolset_spec.rb
CHANGED
@@ -1,63 +1,41 @@
|
|
1
|
-
describe "Rubinius::
|
2
|
-
it "
|
3
|
-
Rubinius::
|
1
|
+
describe "Rubinius::ToolSets.create" do
|
2
|
+
it "creates a new ToolSet" do
|
3
|
+
m = Rubinius::ToolSets.current
|
4
|
+
Rubinius::ToolSets.create.should_not equal(m)
|
4
5
|
end
|
5
|
-
end
|
6
|
-
|
7
|
-
describe "Rubinius::ToolSet.finish" do
|
8
|
-
before do
|
9
|
-
Rubinius::ToolSet.start
|
10
|
-
module Rubinius::ToolSet.current::TS; end
|
11
|
-
end
|
12
|
-
|
13
|
-
it "adds name to the ToolSet map" do
|
14
|
-
Rubinius::ToolSet.finish :testing
|
15
|
-
Rubinius::ToolSet.map.keys.should include(:testing)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "sets a constant on ToolSet with the capitalized name" do
|
19
|
-
Rubinius::ToolSet.finish :name
|
20
|
-
Rubinius::ToolSet::Name.should be_an_instance_of(Module)
|
21
|
-
end
|
22
|
-
end
|
23
6
|
|
24
|
-
|
25
|
-
|
26
|
-
Rubinius::
|
27
|
-
$LOADED_FEATURES.should == []
|
28
|
-
end
|
7
|
+
it "accepts an optional name for the ToolSet" do
|
8
|
+
ts = Rubinius::ToolSets.create :a_tool_set
|
9
|
+
ts.name.should == "Rubinius::ToolSets::AToolSet"
|
29
10
|
end
|
30
11
|
|
31
|
-
it "
|
32
|
-
Rubinius::
|
33
|
-
|
34
|
-
m.name.should be_nil
|
12
|
+
it "sets .current to the ToolSet that is yielded to the block" do
|
13
|
+
Rubinius::ToolSets.create do |ts|
|
14
|
+
ts.should equal(Rubinius::ToolSets.current)
|
35
15
|
end
|
36
16
|
end
|
37
17
|
|
38
|
-
it "
|
39
|
-
Rubinius::
|
40
|
-
|
18
|
+
it "resets $LOADED_FEATURES while running the block" do
|
19
|
+
Rubinius::ToolSets.create do
|
20
|
+
$LOADED_FEATURES.should == []
|
41
21
|
end
|
42
22
|
end
|
43
23
|
|
44
|
-
it "
|
45
|
-
Rubinius::
|
46
|
-
|
24
|
+
it "sets the 'ToolSet' constant on the yielded ToolSet to refer to itself" do
|
25
|
+
Rubinius::ToolSets.create :spec do |ts|
|
26
|
+
ts.should equal(ts::ToolSet)
|
47
27
|
end
|
48
28
|
end
|
29
|
+
end
|
49
30
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
31
|
+
describe "Rubinius::ToolSets.current" do
|
32
|
+
it "returns the ToolSet created by .create" do
|
33
|
+
ts = Rubinius::ToolSets.create
|
34
|
+
Rubinius::ToolSets.current.should equal(ts)
|
55
35
|
end
|
56
36
|
|
57
|
-
it "
|
58
|
-
Rubinius::
|
59
|
-
|
60
|
-
m::TS::ToolSet.name.should == "Rubinius::ToolSet::Spec"
|
61
|
-
end
|
37
|
+
it "returns the same ToolSet on each call" do
|
38
|
+
ts = Rubinius::ToolSets.current
|
39
|
+
ts.should equal(Rubinius::ToolSets.current)
|
62
40
|
end
|
63
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubinius-toolset
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubinius-bridge
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
55
69
|
description: |
|
56
70
|
Rubinius::ToolSet provides a registry for code tools. These include
|
57
71
|
the Rubinius bytecode compiler and parser. These, in turn, depend on
|
@@ -96,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
110
|
version: '0'
|
97
111
|
requirements: []
|
98
112
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.2.
|
113
|
+
rubygems_version: 2.2.2
|
100
114
|
signing_key:
|
101
115
|
specification_version: 4
|
102
116
|
summary: A registry for Rubinius code tools
|