pogo-script 0.0.1

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.
Files changed (5) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +40 -0
  3. data/lib/pogo-script.rb +1 -0
  4. data/lib/pogo_script.rb +53 -0
  5. metadata +82 -0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010 Joshua Peek, Josh Chisholm
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Ruby PogoScript
2
+ =================
3
+
4
+ Ruby PogoScript is a bridge to the official PogoScript compiler.
5
+
6
+ PogoScript.compile File.read("script.pogo")
7
+
8
+
9
+ Installation
10
+ ------------
11
+
12
+ gem install pogo-script
13
+
14
+
15
+ Dependencies
16
+ ------------
17
+
18
+ This library depends on the `pogo-script-source` gem which is
19
+ updated any time a new version of PogoScript is released. (The
20
+ `pogo-script-source` gem's version number is synced with each
21
+ official PogoScript release.) This way you can build against
22
+ different versions of PogoScript by requiring the correct version of
23
+ the `pogo-script-source` gem.
24
+
25
+ In addition, you can use this library with unreleased versions of
26
+ PogoScript by setting the `POGOSCRIPT_SOURCE_PATH` environment
27
+ variable:
28
+
29
+ export POGOSCRIPT_SOURCE_PATH=/path/to/pogo-script/extras/pogo-script.js
30
+
31
+ ### JSON
32
+
33
+ The `json` library is also required but is not explicitly stated as a
34
+ gem dependency. If you're on Ruby 1.8 you'll need to install the
35
+ `json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
36
+ standard library.
37
+
38
+ ### ExecJS
39
+
40
+ The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
@@ -0,0 +1 @@
1
+ require 'pogo_script'
@@ -0,0 +1,53 @@
1
+ require 'execjs'
2
+ require 'pogo_script/source'
3
+
4
+ module PogoScript
5
+ EngineError = ExecJS::RuntimeError
6
+ CompilationError = ExecJS::ProgramError
7
+
8
+ module Source
9
+ def self.path
10
+ @path ||= ENV['POGOSCRIPT_SOURCE_PATH'] || bundled_path
11
+ end
12
+
13
+ def self.path=(path)
14
+ @contents = @version = @bare_option = @context = nil
15
+ @path = path
16
+ end
17
+
18
+ def self.contents
19
+ @contents ||= File.read(path)
20
+ end
21
+
22
+ def self.version
23
+ @version ||= contents[/PogoScript Compiler v([\d.]+)/, 1]
24
+ end
25
+
26
+ def self.bare_option
27
+ @bare_option ||= contents.match(/noWrap/) ? 'noWrap' : 'bare'
28
+ end
29
+
30
+ def self.context
31
+ @context ||= ExecJS.compile(contents)
32
+ end
33
+ end
34
+
35
+ class << self
36
+ def engine
37
+ end
38
+
39
+ def engine=(engine)
40
+ end
41
+
42
+ def version
43
+ Source.version
44
+ end
45
+
46
+ # Compile a script (String or IO) to JavaScript.
47
+ def compile(script, options = {})
48
+ script = script.read if script.respond_to?(:read)
49
+
50
+ Source.context.call("pogoscript.compile", script, { :ugly => true })
51
+ end
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pogo-script
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josh Chisholm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pogo-script-source
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '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'
30
+ - !ruby/object:Gem::Dependency
31
+ name: execjs
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! ' Ruby PogoScript is a bridge to the JS PogoScript compiler.
47
+
48
+ '
49
+ email: josh@featurist.co.uk
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - lib/pogo-script.rb
55
+ - lib/pogo_script.rb
56
+ - LICENSE
57
+ - README.md
58
+ homepage: http://github.com/featurist/ruby-pogo-script
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.24
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Ruby PogoScript Compiler
82
+ test_files: []