rubinius-toolset 2.1.0 → 2.2.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: b2aad3df20490e7a2c8e152d1eddb761507af34f
4
- data.tar.gz: 4906ca7ef0d5e91d91027c161a4c9c042334a34b
3
+ metadata.gz: d8f0825196ed5777cfc710909b29e10aa3d20667
4
+ data.tar.gz: 5a72876dca2c3aebbf9a66a06dfd74ac617b0bac
5
5
  SHA512:
6
- metadata.gz: a08a7edbad2974977ca83fd4932452ac70d557744940eff7927cda5463dac33e346459b8604894392e148c053edc4112c054f25b5724fd064f716638a25905ed
7
- data.tar.gz: 7778d1ffef79250342255372009cf36551a9f094f6f8e446bb3c110ee8703fd29bdbbe66a6e034c35cb0fe64e21bbc65d8b87b1161efc4d97fe2f88ccbec19c7
6
+ metadata.gz: f19965971f1a89d744fcba5561f756955149f9464df94084f4aa87c7c68180193de60f2008f6b0e5e53cdb22bd0fc5bd1a06fcc935627760857b92fb0ac53661
7
+ data.tar.gz: 7eb5c692a474c1cf7464abfc1eab50df70fddae78d8cafe3e7e8cdaca26db05af370fc4ae48457ea954bbdc8744c6c4f51e13473c608295c24e71fc452fc17c4
data/.travis.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
- - RUBYLIB=.
2
+ env:
3
+ - RUBYLIB=lib:.
3
4
  script: mspec -r spec/spec_helper spec
4
5
  rvm:
6
+ - 1.8.7
5
7
  - 2.1.0
8
+ - 2.1.1
6
9
  - rbx-2
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # Rubinius::Toolset
1
+ # Rubinius::Toolsets
2
2
 
3
- Rubinius::ToolSet provides a registry for code tools. These include
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 other languages to reuse as much of
8
- the Rubinius code tools as are suitable for that language.
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
- TODO: Write usage instructions here
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
 
@@ -1,5 +1,5 @@
1
1
  module Rubinius
2
- module Toolset
3
- VERSION = "2.1.0"
2
+ module ToolSets
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
@@ -1,60 +1,35 @@
1
1
  require "rubinius/toolset/version"
2
2
 
3
3
  module Rubinius
4
- module ToolSet
5
- # Returns the module enclosing the current toolset.
6
- def self.current
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
- loaded_features = $LOADED_FEATURES
50
- $LOADED_FEATURES.clear
51
-
52
- start
53
- attach name
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
- yield current
56
- ensure
57
- $LOADED_FEATURES.replace loaded_features
30
+ # Returns the current ToolSet.
31
+ def self.current
32
+ @current ||= create
58
33
  end
59
34
  end
60
35
  end
@@ -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::Toolset::VERSION
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
@@ -1,2 +1,3 @@
1
+ require 'rubygems'
1
2
  require 'rubinius/bridge'
2
3
  require 'lib/rubinius/toolset'
data/spec/toolset_spec.rb CHANGED
@@ -1,63 +1,41 @@
1
- describe "Rubinius::ToolSet.current" do
2
- it "returns a Module" do
3
- Rubinius::ToolSet.current.should be_an_instance_of(Module)
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
- describe "Rubinius::ToolSet.create" do
25
- it "it resets $LOADED_FEATURES while running the block" do
26
- Rubinius::ToolSet.create do
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 "yields an anonymous Module to the block if no name is given" do
32
- Rubinius::ToolSet.create do |m|
33
- m.should be_an_instance_of(Module)
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 "sets .current to the module that is yielded to the block" do
39
- Rubinius::ToolSet.create do |m|
40
- m.should equal(Rubinius::ToolSet.current)
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 "accepts an optional name for the toolset module" do
45
- Rubinius::ToolSet.create :a_tool_set do |m|
46
- m.name.should == "Rubinius::ToolSet::AToolSet"
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
- it "creates a temporary module named 'TS' on the current toolset module" do
51
- Rubinius::ToolSet.create :spec do |m|
52
- m.should equal(m::TS)
53
- m::TS.name.should == "Rubinius::ToolSet::Spec"
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 "creates a ToolSet module under the TS module" do
58
- Rubinius::ToolSet.create :spec do |m|
59
- m::TS.should equal(m::TS::ToolSet)
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.1.0
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-01 00:00:00.000000000 Z
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.1
113
+ rubygems_version: 2.2.2
100
114
  signing_key:
101
115
  specification_version: 4
102
116
  summary: A registry for Rubinius code tools