sweetjs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ # encoding: UTF-8
2
+ require 'sweetjs'
3
+ require 'rspec'
4
+
5
+ # Requires supporting files with custom matchers and macros, etc,
6
+ # in ./support/ and its subdirectories.
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+
9
+ RSpec.configure do |config|
10
+
11
+ end
@@ -0,0 +1,43 @@
1
+ # encodeing: UTF-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ describe "SweetJS" do
6
+ let(:source) {
7
+ (<<-JS)
8
+ macro def {
9
+ case $name:ident $params $body => {
10
+ function $name $params $body
11
+ }
12
+ }
13
+ def sweet(a) {
14
+ console.log("Macros are sweet!");
15
+ }
16
+ JS
17
+ }
18
+
19
+ it "compiles macros" do
20
+ compiled = SweetJS.new.compile(source)
21
+ compiled.should =~ /function sweet/
22
+ end
23
+
24
+ it "has a class method to compile macros" do
25
+ compiled = SweetJS.compile(source)
26
+ compiled.should =~ /function sweet/
27
+ end
28
+
29
+ it "throws an exception when compilation fails" do
30
+ lambda {
31
+ compiled = SweetJS.new.compile((<<-JS))
32
+ def sweet(a) { console.log("Macros are sweet!"); }
33
+ JS
34
+ }.should raise_error(SweetJS::Error)
35
+ end
36
+
37
+ it "compiles IO objects as well as strings" do
38
+ io = StringIO.new(source)
39
+ lambda {
40
+ SweetJS.compile(io).should =~ /function sweet/
41
+ }.should_not raise_error(SweetJS::Error)
42
+ end
43
+ end
@@ -0,0 +1,77 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'sweetjs'
16
+ s.version = '0.1.0'
17
+ s.date = '2012-10-02'
18
+ s.rubyforge_project = 'sweetjs'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Ruby wrapper for the Sweet.js JavaScript macro library"
23
+ s.description = "See http://sweetjs.org for more information about Sweet.js macros"
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Garry Hill"]
29
+ s.email = 'garry@magnetised.net'
30
+ s.homepage = 'http://github.com/magnetised/sweetjs'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## If your gem includes any executables, list them here.
37
+ # s.executables = ["name"]
38
+
39
+ ## Specify any RDoc options here. You'll want to add your README and
40
+ ## LICENSE files to the extra_rdoc_files list.
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.extra_rdoc_files = %w[README.md LICENSE.txt]
43
+
44
+ ## List your runtime dependencies here. Runtime dependencies are those
45
+ ## that are needed for an end user to actually USE your code.
46
+ s.add_dependency('execjs', [">= 0.3.0"])
47
+ s.add_dependency('multi_json', ["~> 1.0", ">= 1.0.2"])
48
+
49
+ ## List your development dependencies here. Development dependencies are
50
+ ## those that are only needed during development
51
+ s.add_development_dependency('rake', ["~> 0.9.2"])
52
+ s.add_development_dependency('rspec', ["~> 2.7"])
53
+ s.add_development_dependency('bundler', ["~> 1.0"])
54
+
55
+ ## Leave this section as-is. It will be automatically generated from the
56
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
57
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
58
+ # = MANIFEST =
59
+ s.files = %w[
60
+ Gemfile
61
+ LICENSE.txt
62
+ README.md
63
+ Rakefile
64
+ lib/sweetjs.rb
65
+ lib/sweetjs/escodegen.js
66
+ lib/sweetjs/sweet.js
67
+ lib/sweetjs/underscore.js
68
+ spec/spec_helper.rb
69
+ spec/sweet_spec.rb
70
+ sweetjs.gemspec
71
+ ]
72
+ # = MANIFEST =
73
+
74
+ ## Test files will be grabbed from the file list. Make sure the path glob
75
+ ## matches what you actually use.
76
+ s.test_files = s.files.select { |path| path =~ /^spec\/.+\.rb/ }
77
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sweetjs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Garry Hill
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: execjs
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.3.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.3.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.2
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.0'
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: 1.0.2
52
+ - !ruby/object:Gem::Dependency
53
+ name: rake
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: 0.9.2
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 0.9.2
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec
70
+ requirement: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '2.7'
84
+ - !ruby/object:Gem::Dependency
85
+ name: bundler
86
+ requirement: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: '1.0'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: '1.0'
100
+ description: See http://sweetjs.org for more information about Sweet.js macros
101
+ email: garry@magnetised.net
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files:
105
+ - README.md
106
+ - LICENSE.txt
107
+ files:
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/sweetjs.rb
113
+ - lib/sweetjs/escodegen.js
114
+ - lib/sweetjs/sweet.js
115
+ - lib/sweetjs/underscore.js
116
+ - spec/spec_helper.rb
117
+ - spec/sweet_spec.rb
118
+ - sweetjs.gemspec
119
+ homepage: http://github.com/magnetised/sweetjs
120
+ licenses: []
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --charset=UTF-8
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ segments:
133
+ - 0
134
+ hash: 174048803357668219
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project: sweetjs
143
+ rubygems_version: 1.8.21
144
+ signing_key:
145
+ specification_version: 2
146
+ summary: Ruby wrapper for the Sweet.js JavaScript macro library
147
+ test_files:
148
+ - spec/spec_helper.rb
149
+ - spec/sweet_spec.rb