schmooze 0.1.2 → 0.1.3

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: b6a0a8f35d4f1469388e762084d088396808bddb
4
- data.tar.gz: a580bee0dcadce15ad6b0b0cd3da7b0c7cbca61a
3
+ metadata.gz: a8a15e7e0c0a0e850c397bcf9c6816112484aeb9
4
+ data.tar.gz: df29bca677de10648f809044bd405284721e94a5
5
5
  SHA512:
6
- metadata.gz: 72e0014d48a46d389e088c9ce5675d353febdf1b0cbdb514e496890428ffa067d8c3f1d905f4a3d3892acebc6c9bddd2bf14d8db0ba40148896139e540ddfff6
7
- data.tar.gz: aa9d86a8bed3b12741f68096b01d0865224227bd2c82ed1394abf45f920d9d2d70f05a056d3420dc88659be76f3fc685e58f77a2df318d9e1edfb7bf1b92a693
6
+ metadata.gz: 7f1d9acbb36a475de6bad0176cd768354eea42b8ceb3247d8cc4a2da138d03ff0219a08e1ade100a4888744baad99d70561e785c41d3c987e748942c95b729cc
7
+ data.tar.gz: e3c3e83bec29386d52bdca384ec5b8ce98def024bc105afe944e841005f80e94a330f25c8239194cfcbb261fc5008279c08253fd345ae8c3b4365ca503e7e5ea
@@ -1,3 +1,3 @@
1
1
  module Schmooze
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -11,8 +11,8 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.license = "MIT"
13
13
  spec.summary = %q{Schmooze lets Ruby and Node.js work together intimately.}
14
+ spec.description = %q{Schmooze allows a Ruby library writer to succintly interoperate between Ruby and JavaScript code. It has a clever DSL to make this possible.}
14
15
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
15
- spec.description = File.read(File.join(__dir__, 'README.md'))
16
16
  spec.homepage = 'https://github.com/Shopify/schmooze'
17
17
 
18
18
  spec.require_paths = ['lib']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schmooze
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
@@ -52,113 +52,8 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- description: |
56
- # Schmooze
57
-
58
- Schmooze lets Ruby and Node.js work together intimately. It has a DSL that allows you to define what methods you need, and it executes code by spawning a Node.js process and sending messages back and forth.
59
-
60
- ## Requirements
61
-
62
- Schmooze requires that you have [nodejs](https://nodejs.org/en/) installed and in the `$PATH`.
63
-
64
- ## Gem Installation
65
-
66
- Add this line to your application's Gemfile:
67
-
68
- ```ruby
69
- gem 'schmooze'
70
- ```
71
-
72
- And then execute:
73
-
74
- $ bundle
75
-
76
- ## Usage
77
-
78
- To use Schmooze, you first need to create a sublcass of `Schmooze::Base`. Your subclass needs to list all of the package dependencies, and methods that you want to have available. For example, here is a Schmooze class that interfaces with [Babel](https://babeljs.io/):
79
-
80
- ```ruby
81
- require 'schmooze'
82
-
83
- class BabelSchmoozer < Schmooze::Base
84
- dependencies babel: 'babel-core'
85
-
86
- method :transform, 'babel.transform'
87
- method :version, 'function() { return [process.version, babel.version]; }'
88
- end
89
- ```
90
-
91
- Note that the `babel-core` package is available under the name `babel`, because that's how we requested it.
92
-
93
- To define a method, you simply give it a name and pass in a JavaScript string that should resolve to a function. Let's put this class to use!
94
-
95
- First we need to make sure we install any needed packages.
96
-
97
- `$ npm install babel-core babel-preset-es2015`
98
-
99
- All we need to do next is to instantiate the class with a path to where the node modules are installed, and then we can call the methods! (Note that we need to pass in `ast: false` because of a [caveat](#caveats)).
100
-
101
- ```ruby
102
- $ pry
103
- Ruby 2.2.2
104
- pry> load './babel_schmoozer.rb'
105
- pry> babel = BabelSchmoozer.new(__dir__)
106
- pry> babel.version
107
- => ["v5.5.0", "6.5.2"]
108
- pry> puts babel.transform('a = () => 1', ast: false, presets: ['es2015'])['code']
109
- "use strict";
110
-
111
- a = function a() {
112
- return 1;
113
- };
114
- ```
115
-
116
- This could easily be turned into a Sprockets plugin.
117
-
118
- ## Error handling
119
-
120
- Errors happen, and Schmooze tries to make them as painless as possible to handle. If there is a dependency missing, Schmooze will throw a helpful Error when you try to initialize the class. Here is an example from the tests:
121
-
122
- ```ruby
123
- class ErrorSchmoozer < Schmooze::Base
124
- dependencies nonexistant: 'this-package-is-not-here'
125
- end
126
- ErrorSchmoozer.new(__dir__)
127
- ```
128
-
129
- This will raise
130
-
131
- ```
132
- Schmooze::DependencyError: Cannot find module 'this-package-is-not-here'.
133
- You need to add it to '/Users/bouke/code/schmooze/test/fixtures/uninstalled_package/package.json' and run 'npm install'
134
- ```
135
-
136
- Any JavaScript errors that happen get converted to Ruby errors under the `Schmooze::Javascript` namespace. For example (once again, from the tests):
137
-
138
- ```ruby
139
- class CoffeeSchmoozer < Schmooze::Base
140
- dependencies coffee: 'coffee-script'
141
- method :compile, 'coffee.compile'
142
- end
143
-
144
- CoffeeSchmoozer.new(dir).compile('<=> 1')
145
- ```
146
-
147
- This will raise
148
-
149
- ```
150
- Schmooze::JavaScript::SyntaxError: [stdin]:1:1: error: unexpected <=
151
- <=> 1
152
- ^^
153
- ```
154
-
155
- ## Caveats
156
-
157
- * Because we serialize the return values from JavaScript to JSON, you can't return circular data structures (like the Babel AST).
158
-
159
- ## Contributing
160
-
161
- Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/schmooze.
55
+ description: Schmooze allows a Ruby library writer to succintly interoperate between
56
+ Ruby and JavaScript code. It has a clever DSL to make this possible.
162
57
  email:
163
58
  - bouke@shopify.com
164
59
  executables: []