opal 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +8 -7
- data/README.md +21 -13
- data/Rakefile +64 -78
- data/bin/opal +18 -29
- data/core/alpha.rb +2 -9
- data/core/array.rb +106 -50
- data/core/basic_object.rb +10 -8
- data/core/boolean.rb +2 -0
- data/core/class.rb +25 -13
- data/core/comparable.rb +6 -6
- data/core/enumerable.rb +90 -94
- data/core/enumerator.rb +3 -3
- data/core/hash.rb +86 -46
- data/core/kernel.rb +55 -39
- data/core/load_order +2 -5
- data/core/match_data.rb +1 -1
- data/core/module.rb +45 -20
- data/core/nil_class.rb +6 -2
- data/core/numeric.rb +20 -10
- data/core/proc.rb +2 -2
- data/core/range.rb +72 -13
- data/core/regexp.rb +5 -3
- data/core/runtime.js +228 -287
- data/core/string.rb +345 -37
- data/core/top_self.rb +1 -1
- data/lib/opal.rb +13 -91
- data/lib/opal/builder.rb +47 -120
- data/lib/opal/builder_task.rb +74 -0
- data/lib/opal/{parser/grammar.rb → grammar.rb} +1094 -1083
- data/lib/opal/{parser/grammar.y → grammar.y} +7 -0
- data/lib/opal/{parser/lexer.rb → lexer.rb} +32 -11
- data/lib/opal/{parser/parser.rb → parser.rb} +232 -238
- data/lib/opal/{parser/scope.rb → scope.rb} +72 -9
- data/lib/opal/version.rb +2 -3
- data/opal.gemspec +1 -2
- data/{core_spec → spec}/core/array/allocate_spec.rb +1 -3
- data/{core_spec → spec}/core/array/append_spec.rb +1 -4
- data/{core_spec → spec}/core/array/assoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/at_spec.rb +1 -3
- data/{core_spec → spec}/core/array/clear_spec.rb +1 -3
- data/spec/core/array/clone_spec.rb +15 -0
- data/{core_spec/core/array/shared/collect.rb → spec/core/array/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/compact_spec.rb +1 -3
- data/{core_spec → spec}/core/array/concat_spec.rb +1 -3
- data/{core_spec → spec}/core/array/constructor_spec.rb +9 -3
- data/{core_spec → spec}/core/array/count_spec.rb +1 -3
- data/{core_spec → spec}/core/array/delete_at_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_if_spec.rb +1 -4
- data/{core_spec → spec}/core/array/delete_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_index_spec.rb +1 -4
- data/{core_spec → spec}/core/array/each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/element_reference_spec.rb +74 -4
- data/{core_spec → spec}/core/array/empty_spec.rb +1 -4
- data/{core_spec/core/array/shared/eql.rb → spec/core/array/eql_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/fetch_spec.rb +1 -4
- data/{core_spec → spec}/core/array/first_spec.rb +1 -3
- data/{core_spec → spec}/core/array/flatten_spec.rb +1 -3
- data/{core_spec → spec}/core/array/include_spec.rb +1 -3
- data/{core_spec → spec}/core/array/insert_spec.rb +1 -4
- data/{core_spec → spec}/core/array/last_spec.rb +1 -4
- data/{core_spec/core/array/shared/length.rb → spec/core/array/length_spec.rb} +1 -1
- data/spec/core/array/map_spec.rb +53 -0
- data/{core_spec → spec}/core/array/plus_spec.rb +1 -4
- data/{core_spec → spec}/core/array/pop_spec.rb +1 -4
- data/{core_spec → spec}/core/array/push_spec.rb +1 -4
- data/{core_spec → spec}/core/array/rassoc_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reject_spec.rb +1 -4
- data/{core_spec/core/array/shared/replace.rb → spec/core/array/replace_spec.rb} +1 -1
- data/{core_spec → spec}/core/array/reverse_each_spec.rb +1 -4
- data/{core_spec → spec}/core/array/reverse_spec.rb +1 -4
- data/spec/core/array/size_spec.rb +6 -0
- data/spec/core/array/to_ary_spec.rb +6 -0
- data/spec/core/array/uniq_spec.rb +22 -0
- data/spec/core/array/zip_spec.rb +20 -0
- data/{core_spec → spec}/core/class/new_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/all_spec.rb +1 -4
- data/{core_spec → spec}/core/enumerable/any_spec.rb +1 -4
- data/{core_spec/core/enumerable/shared/collect.rb → spec/core/enumerable/collect_spec.rb} +1 -1
- data/{core_spec → spec}/core/enumerable/count_spec.rb +2 -5
- data/{core_spec → spec}/core/enumerable/fixtures/classes.rb +1 -2
- data/{core_spec → spec}/core/false/and_spec.rb +1 -3
- data/{core_spec → spec}/core/false/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/false/or_spec.rb +1 -3
- data/{core_spec → spec}/core/false/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/false/xor_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/allocate_spec.rb +1 -3
- data/spec/core/hash/assoc_spec.rb +25 -0
- data/{core_spec → spec}/core/hash/clear_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/clone_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/default_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/delete_if_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_reference_spec.rb +1 -3
- data/{core_spec → spec}/core/hash/element_set_spec.rb +1 -3
- data/spec/core/hash/merge_spec.rb +37 -0
- data/{core_spec → spec}/core/hash/new_spec.rb +1 -3
- data/{core_spec → spec}/core/matchdata/to_a_spec.rb +1 -3
- data/{core_spec → spec}/core/nil/and_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/inspect_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/nil_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/or_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_a_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_f_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_i_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/to_s_spec.rb +1 -4
- data/{core_spec → spec}/core/nil/xor_spec.rb +1 -4
- data/{core_spec → spec}/core/numeric/equal_value_spec.rb +1 -3
- data/{core_spec → spec}/core/regexp/match_spec.rb +10 -3
- data/{core_spec → spec}/core/symbol/to_proc_spec.rb +1 -3
- data/{core_spec → spec}/core/true/and_spec.rb +1 -3
- data/{core_spec → spec}/core/true/inspect_spec.rb +1 -3
- data/{core_spec → spec}/core/true/or_spec.rb +1 -3
- data/{core_spec → spec}/core/true/to_s_spec.rb +1 -3
- data/{core_spec → spec}/core/true/xor_spec.rb +1 -3
- data/spec/index.html +11 -0
- data/{core_spec → spec}/language/alias_spec.rb +1 -3
- data/{core_spec → spec}/language/and_spec.rb +1 -4
- data/{core_spec → spec}/language/array_spec.rb +1 -4
- data/{core_spec → spec}/language/block_spec.rb +20 -3
- data/{core_spec → spec}/language/break_spec.rb +40 -3
- data/{core_spec → spec}/language/case_spec.rb +1 -4
- data/{core_spec → spec}/language/defined_spec.rb +9 -3
- data/{core_spec → spec}/language/ensure_spec.rb +38 -3
- data/{core_spec → spec}/language/hash_spec.rb +1 -3
- data/{core_spec → spec}/language/if_spec.rb +1 -4
- data/{core_spec → spec}/language/loop_spec.rb +1 -3
- data/spec/language/metaclass_spec.rb +13 -0
- data/{core_spec → spec}/language/next_spec.rb +47 -3
- data/{core_spec → spec}/language/or_spec.rb +1 -4
- data/{core_spec → spec}/language/predefined_spec.rb +1 -3
- data/{core_spec/language/regexp/interpolation_spec.rb → spec/language/regexp_spec.rb} +6 -3
- data/{core_spec → spec}/language/send_spec.rb +38 -4
- data/spec/language/singleton_class_spec.rb +31 -0
- data/spec/language/super_spec.rb +188 -0
- data/{core_spec → spec}/language/symbol_spec.rb +1 -3
- data/{core_spec → spec}/language/undef_spec.rb +1 -3
- data/{core_spec → spec}/language/unless_spec.rb +1 -4
- data/{core_spec → spec}/language/until_spec.rb +1 -3
- data/{core_spec → spec}/language/variables_spec.rb +1 -3
- data/{core_spec → spec}/language/while_spec.rb +1 -3
- data/{spec → test}/builder/build_source_spec.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/adam.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/bar/wow/cow/c.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/beynon.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/charles.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/a.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/b.rb +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/x.js +0 -0
- data/{spec → test}/builder/fixtures/build_source/foo/y.js +0 -0
- data/{spec → test}/grammar/alias_spec.rb +0 -0
- data/{spec → test}/grammar/and_spec.rb +0 -0
- data/{spec → test}/grammar/array_spec.rb +0 -0
- data/{spec → test}/grammar/attrasgn_spec.rb +0 -0
- data/{spec → test}/grammar/begin_spec.rb +0 -0
- data/{spec → test}/grammar/block_spec.rb +0 -0
- data/{spec → test}/grammar/break_spec.rb +0 -0
- data/{spec → test}/grammar/call_spec.rb +0 -0
- data/{spec → test}/grammar/class_spec.rb +0 -0
- data/{spec → test}/grammar/const_spec.rb +0 -0
- data/{spec → test}/grammar/cvar_spec.rb +0 -0
- data/{spec → test}/grammar/def_spec.rb +0 -0
- data/{spec → test}/grammar/false_spec.rb +0 -0
- data/{spec → test}/grammar/file_spec.rb +0 -0
- data/{spec → test}/grammar/gvar_spec.rb +0 -0
- data/{spec → test}/grammar/hash_spec.rb +0 -0
- data/{spec → test}/grammar/iasgn_spec.rb +0 -0
- data/{spec → test}/grammar/if_spec.rb +0 -0
- data/{spec → test}/grammar/iter_spec.rb +0 -0
- data/{spec → test}/grammar/ivar_spec.rb +0 -0
- data/{spec → test}/grammar/lasgn_spec.rb +0 -0
- data/{spec → test}/grammar/line_spec.rb +0 -0
- data/{spec → test}/grammar/lvar_spec.rb +0 -0
- data/{spec → test}/grammar/masgn_spec.rb +0 -0
- data/{spec → test}/grammar/module_spec.rb +0 -0
- data/{spec → test}/grammar/nil_spec.rb +0 -0
- data/{spec → test}/grammar/not_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn1_spec.rb +0 -0
- data/{spec → test}/grammar/op_asgn2_spec.rb +0 -0
- data/{spec → test}/grammar/or_spec.rb +0 -0
- data/{spec → test}/grammar/return_spec.rb +0 -0
- data/{spec → test}/grammar/sclass_spec.rb +0 -0
- data/{spec → test}/grammar/self_spec.rb +0 -0
- data/{spec → test}/grammar/str_spec.rb +0 -0
- data/{spec → test}/grammar/super_spec.rb +0 -0
- data/{spec → test}/grammar/true_spec.rb +0 -0
- data/{spec → test}/grammar/undef_spec.rb +0 -0
- data/{spec → test}/grammar/unless_spec.rb +0 -0
- data/{spec → test}/grammar/while_spec.rb +0 -0
- data/{spec → test}/grammar/xstr_spec.rb +0 -0
- data/{spec → test}/grammar/yield_spec.rb +0 -0
- data/{spec → test}/spec_helper.rb +0 -0
- metadata +330 -264
- data/core/debug.js +0 -59
- data/core/debug.rb +0 -35
- data/core/dir.rb +0 -90
- data/core/file.rb +0 -83
- data/core/gemlib.rb +0 -30
- data/core/io.rb +0 -44
- data/core_spec/README.md +0 -34
- data/core_spec/core/array/collect_spec.rb +0 -3
- data/core_spec/core/array/element_set_spec.rb +0 -7
- data/core_spec/core/array/eql_spec.rb +0 -3
- data/core_spec/core/array/equal_value_spec.rb +0 -3
- data/core_spec/core/array/fixtures/classes.rb +0 -8
- data/core_spec/core/array/length_spec.rb +0 -3
- data/core_spec/core/array/map_spec.rb +0 -3
- data/core_spec/core/array/replace_spec.rb +0 -3
- data/core_spec/core/enumerable/collect_spec.rb +0 -3
- data/core_spec/core/enumerable/detect_spec.rb +0 -3
- data/core_spec/core/enumerable/find_spec.rb +0 -3
- data/core_spec/core/enumerable/first_spec.rb +0 -3
- data/core_spec/core/enumerable/shared/entries.rb +0 -7
- data/core_spec/core/enumerable/shared/find.rb +0 -49
- data/core_spec/core/enumerable/shared/take.rb +0 -31
- data/core_spec/core/enumerable/to_a_spec.rb +0 -7
- data/core_spec/core/hash/assoc_spec.rb +0 -29
- data/core_spec/core/object/is_a_spec.rb +0 -2
- data/core_spec/core/object/shared/kind_of.rb +0 -0
- data/core_spec/core/regexp/shared/match.rb +0 -11
- data/core_spec/language/fixtures/block.rb +0 -19
- data/core_spec/language/fixtures/break.rb +0 -39
- data/core_spec/language/fixtures/defined.rb +0 -9
- data/core_spec/language/fixtures/ensure.rb +0 -37
- data/core_spec/language/fixtures/next.rb +0 -46
- data/core_spec/language/fixtures/send.rb +0 -36
- data/core_spec/language/fixtures/super.rb +0 -43
- data/core_spec/language/regexp_spec.rb +0 -7
- data/core_spec/language/string_spec.rb +0 -4
- data/core_spec/language/super_spec.rb +0 -18
- data/core_spec/language/versions/hash_1.9.rb +0 -20
- data/core_spec/opal/opal/defined_spec.rb +0 -15
- data/core_spec/opal/opal/function_spec.rb +0 -11
- data/core_spec/opal/opal/native_spec.rb +0 -16
- data/core_spec/opal/opal/null_spec.rb +0 -10
- data/core_spec/opal/opal/number_spec.rb +0 -11
- data/core_spec/opal/opal/object_spec.rb +0 -16
- data/core_spec/opal/opal/string_spec.rb +0 -11
- data/core_spec/opal/opal/typeof_spec.rb +0 -9
- data/core_spec/opal/opal/undefined_spec.rb +0 -10
- data/core_spec/opal/true/case_compare_spec.rb +0 -12
- data/core_spec/opal/true/class_spec.rb +0 -10
- data/core_spec/release_runner.html +0 -17
- data/core_spec/runner.html +0 -16
- data/core_spec/spec_helper.rb +0 -23
- data/lib/opal/context.rb +0 -269
- data/lib/opal/dependency_builder.rb +0 -133
- data/lib/opal/environment.rb +0 -87
- data/lib/opal/parser/sexp.rb +0 -17
@@ -1,133 +0,0 @@
|
|
1
|
-
#### Opal Dependency Builder
|
2
|
-
#
|
3
|
-
# The `DependencyBuilder` class is used to build all dependencies for
|
4
|
-
# an app/lib, including the opal runtime. Dependencies in opal are
|
5
|
-
# simply gems that have been installed or are referenced by any relevant
|
6
|
-
# `Gemfile` or `.gemspec`.
|
7
|
-
#
|
8
|
-
# To build a predefined set of dependencies, they can be passed directly
|
9
|
-
# to `DependencyBuilder`. Any gems here must be already installed and
|
10
|
-
# available to opal to find. An example may be:
|
11
|
-
#
|
12
|
-
# Opal::DependencyBuilder.new(:gems => ['opal-spec']).build
|
13
|
-
#
|
14
|
-
# This will build the `opal-spec` dependency into the working directory.
|
15
|
-
# This will create `opal-spec.js` and `opal-spec.debug.js`, which are the
|
16
|
-
# release and debug versions of the gem respectively.
|
17
|
-
#
|
18
|
-
# The alternative to this approach is to use a `Gemfile`. Opal can pick
|
19
|
-
# out dependencies from a `Gemfile` in the current working directory. As
|
20
|
-
# there will be some non-opal dependnecies in the `Gemfile`, all gems that
|
21
|
-
# should be built **must** be inside an `:opal` group:
|
22
|
-
#
|
23
|
-
# # Gemfile
|
24
|
-
# gem "opal"
|
25
|
-
# gem "therubyracer"
|
26
|
-
#
|
27
|
-
# group :opal do
|
28
|
-
# gem "opal-spec"
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# Now running the dependency builder as:
|
32
|
-
#
|
33
|
-
# Opal::DependencyBuilder.new.build
|
34
|
-
#
|
35
|
-
# Will built all dependnecies inside the opal group (just `opal-spec`) in
|
36
|
-
# both debug and release mode.
|
37
|
-
#
|
38
|
-
# When developing a gem for opal, the `.gemspec` already has a list of
|
39
|
-
# buildable gems inside the gem specification. If a `.gemspec` is also
|
40
|
-
# found then all runtime dependnecies will be built as well. It is crucial
|
41
|
-
# that **only** dependencies to run inside opal should be listed as a runtime
|
42
|
-
# dependency.
|
43
|
-
#
|
44
|
-
# Note, `opal` is **not** a runtime dependency, as it is built as a special
|
45
|
-
# case. Whenever `DependencyBuilder` is run, `opal.js` and `opal.debug.js`
|
46
|
-
# are also built.
|
47
|
-
#
|
48
|
-
# Finally, to write to a custom output directory, `:out` can be passed. This
|
49
|
-
# should be a directory and not a file as all dependnecies are built
|
50
|
-
# individually. For example:
|
51
|
-
#
|
52
|
-
# Opal::DependencyBuilder.new(:gems => 'opal-spec', :out => 'build').build
|
53
|
-
#
|
54
|
-
# This will create `build/opal-spec.js` and `build/opal-spec.debug.js` (as well
|
55
|
-
# as the runtime files `opal.js` and `opal.debug.js`.
|
56
|
-
#
|
57
|
-
|
58
|
-
# The `Environment` is used to find relevant `Gemfile` and `.gemspec` to use to
|
59
|
-
# gather dependency names.
|
60
|
-
require 'opal/environment'
|
61
|
-
|
62
|
-
module Opal
|
63
|
-
# `DependencyBuilder.new` takes an optional hash of build options which control
|
64
|
-
# what dependencies are being built. The possible `options` are:
|
65
|
-
#
|
66
|
-
# * `:out`: specifies the directory to build the resulting files to. This
|
67
|
-
# directory will be created if it doesn't exist. _Defaults to `Dir.getwd`_.
|
68
|
-
#
|
69
|
-
# * `:gems`: an array (or single string) of gem dependencies to build. If not
|
70
|
-
# given then the `Gemfile` or `.gemspec` will be inspected as described above.
|
71
|
-
class DependencyBuilder
|
72
|
-
|
73
|
-
def initialize(options = {})
|
74
|
-
@options = options
|
75
|
-
end
|
76
|
-
|
77
|
-
def build
|
78
|
-
@environment = Environment.load Dir.getwd
|
79
|
-
@verbose = true
|
80
|
-
@base = File.expand_path(@options[:out] || '.')
|
81
|
-
|
82
|
-
FileUtils.mkdir_p @base
|
83
|
-
|
84
|
-
calculate_dependencies(@options[:gems]).each do |g|
|
85
|
-
if spec = @environment.find_spec(g)
|
86
|
-
build_spec spec
|
87
|
-
else
|
88
|
-
puts "Cannot find gem dependency #{g}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
build_opal
|
93
|
-
end
|
94
|
-
|
95
|
-
# Gather a list of dependencies to build. These are taken from the
|
96
|
-
# following order:
|
97
|
-
#
|
98
|
-
# 1. if rake task given a list, use those.
|
99
|
-
# 2. Use dependnecies listed in Gemfile :opal group, if it exists
|
100
|
-
# 3. Use all runtime dependnecies from local gemspec (if it exists)
|
101
|
-
#
|
102
|
-
# If none of these are applicable, no dependnecies will be built.
|
103
|
-
#
|
104
|
-
# @param [Array, String] gems gems passed to rake task
|
105
|
-
# @return [Array<String>] an array of gem names to build
|
106
|
-
def calculate_dependencies(gems)
|
107
|
-
return Array(gems) if gems
|
108
|
-
@environment.specs
|
109
|
-
end
|
110
|
-
|
111
|
-
def build_spec(spec)
|
112
|
-
sources = spec.require_paths
|
113
|
-
output = File.expand_path("#{spec.name}.js", @options[:out] || '.')
|
114
|
-
|
115
|
-
Dir.chdir(spec.full_gem_path) do
|
116
|
-
Builder.new(:files => sources, :out => output).build
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Builds/copies the opal runtime into the :out directory.
|
121
|
-
def build_opal
|
122
|
-
release = File.expand_path("opal.js", @options[:out] || '.')
|
123
|
-
debug = File.expand_path("opal.debug.js", @options[:out] || '.')
|
124
|
-
puts "[opal] building runtime (#{release}, #{debug})"
|
125
|
-
|
126
|
-
runtime = Opal.runtime_code
|
127
|
-
debugrun = Opal.runtime_debug_code
|
128
|
-
|
129
|
-
File.open(release, 'w+') { |o| o.write runtime }
|
130
|
-
File.open(debug, 'w+') { |o| o.write debugrun }
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
data/lib/opal/environment.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
module Opal
|
2
|
-
# Default Environment that assumes no Gemfile or gemspec for the given
|
3
|
-
# app/library.
|
4
|
-
class Environment
|
5
|
-
def self.load(dir)
|
6
|
-
return GemfileEnvironment.new dir if File.exists? File.join(dir, 'Gemfile')
|
7
|
-
return GemspecEnvironment.new dir unless Dir["#{dir}/*.gemspec"].empty?
|
8
|
-
return Environment.new dir
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_accessor :files
|
12
|
-
attr_reader :root
|
13
|
-
|
14
|
-
def initialize(root)
|
15
|
-
@root = root
|
16
|
-
end
|
17
|
-
|
18
|
-
# Find a gem specification with the given name. Returns nil if one
|
19
|
-
# can't be found
|
20
|
-
# @return [Gem::Specification]
|
21
|
-
def find_spec(name)
|
22
|
-
Gem::Specification.find_by_name name
|
23
|
-
rescue Gem::LoadError
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
def specs
|
28
|
-
[]
|
29
|
-
end
|
30
|
-
|
31
|
-
def name
|
32
|
-
File.basename @root
|
33
|
-
end
|
34
|
-
|
35
|
-
# Default require paths is just 'lib'
|
36
|
-
def require_paths
|
37
|
-
['lib']
|
38
|
-
end
|
39
|
-
|
40
|
-
def gemspec
|
41
|
-
@gemspec ||= Dir['*.gemspec'].first
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# Used for libs/gems that have a gemspec (but no Gemfile!).
|
46
|
-
class GemspecEnvironment < Environment
|
47
|
-
def specs
|
48
|
-
if spec = self.gemspec
|
49
|
-
gemspec = Gem::Specification.load spec
|
50
|
-
return gemspec.runtime_dependencies.map(&:name)
|
51
|
-
end
|
52
|
-
|
53
|
-
[]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Used for environments which use a Gemfile
|
58
|
-
class GemfileEnvironment < Environment
|
59
|
-
def bundler
|
60
|
-
return @bundler if @bundler
|
61
|
-
require 'bundler'
|
62
|
-
@bundler = Bundler.load
|
63
|
-
end
|
64
|
-
|
65
|
-
# Returns an array of names of the specs that are listed inside the
|
66
|
-
# given group. This defaults to :opal as that is where specs are
|
67
|
-
# built from.
|
68
|
-
# @return [Array<String>]
|
69
|
-
def specs(group = :opal)
|
70
|
-
names = bundler.dependencies_for(group).map(&:name)
|
71
|
-
|
72
|
-
if gemspec = self.gemspec
|
73
|
-
gemspec = Gem::Specification.load gemspec
|
74
|
-
names += gemspec.runtime_dependencies.map(&:name)
|
75
|
-
end
|
76
|
-
|
77
|
-
names.uniq
|
78
|
-
end
|
79
|
-
|
80
|
-
def find_spec(name)
|
81
|
-
bundler
|
82
|
-
Gem::Specification.find_by_name name
|
83
|
-
rescue Gem::LoadError
|
84
|
-
nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
data/lib/opal/parser/sexp.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Opal
|
2
|
-
class Sexp < Array
|
3
|
-
attr_accessor :line, :end_line
|
4
|
-
|
5
|
-
def initialize *parts
|
6
|
-
push *parts
|
7
|
-
@line = 0
|
8
|
-
@end_line = 0
|
9
|
-
end
|
10
|
-
|
11
|
-
def inspect
|
12
|
-
"s(#{map { |x| x.inspect }.join ', ' })"
|
13
|
-
end
|
14
|
-
|
15
|
-
alias_method :to_s, :inspect
|
16
|
-
end
|
17
|
-
end
|