prism-cli 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. checksums.yaml +4 -4
  2. metadata +7 -138
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e4528b6762c4f5de379ad5335fee2915579ab3ab29ed63055eb9c3bae4b3d4c
4
- data.tar.gz: db8e97a66f737d30b5ea0919cc26c030db4dac3f171cf15be6a73c8c3670bb8c
3
+ metadata.gz: 88754ad71aa92c584889769ef7ac4cad2fc92bc2f51a2b0cf88360d6f4d98dd8
4
+ data.tar.gz: fb6a5e2b05bde801ea658a5c733bbd8a4c72bec68ddccaf2d10395ce5892c5c3
5
5
  SHA512:
6
- metadata.gz: 4d45d7b56eb3cf139bc855c4c7e48fd65791f1a2e6d20caa2bd8816bc4e1dde35ff42450b3baf4e187c63b2b9ef0b1146be59ba71e5fe752e625a77b95236897
7
- data.tar.gz: 4929bb432cc89acd018d4bf298b909d5752017244a52bb832bcb8174f1b8fa93a1118c156d79b36b77c5d71ffe41ed020ff7df9a3a6b82274e63dbd24f4e5e25
6
+ metadata.gz: 871f05008cd66c75d871a1e2e45eceec2d69d4b29affefb1b115204d727ec2864e036b67b38ff77b2b3bb73c1dc0e66a3a3a6f9236302cf844d33fb2858a2fd4
7
+ data.tar.gz: 31cb9a4ac5ef768aa53e267075e306df9d0ac655803a0b69ac2cddd1b2777b719b590a0610d5c911f3c86de24b1f36d983a3e3d5cebc13763aaec9b05fee6ac5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Johnstone
@@ -10,143 +10,12 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: "\n## Prism\n\n[![Join the chat at https://gitter.im/prism-rb/community](https://badges.gitter.im/prism-rb/community.svg)](https://gitter.im/prism-rb/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\nBuild
14
- frontend web apps with Ruby and WebAssembly \n\n### Introduction\n\nPrism is a framework
15
- that helps you make frontend web applications with Ruby and WebAssembly. It uses
16
- [mruby](https://github.com/mruby/mruby) and [emscripten](https://emscripten.org/)
17
- to compile ruby code to WebAssembly. It also provides a runtime layer for working
18
- with the DOM and events.\n\n⚡️ Prism is currently in extremely early alpha. Expect
19
- bugs, breaking API changes, missing functionality and rough edges. ⚡️\n\n### Getting
20
- started\n\nYou can install Prism from RubyGems using `gem install prism-cli`.\n\n###
21
- CLI Usage\n\nYou can initialize a new Prism app by running `prism init`. This simply
22
- creates a hello world sample application, by default at `./app.rb` but you can customize
23
- the location by providing an argument to `prism init`.\n\nYou can then run `prism
24
- server`, which will start a development server. If you then navigate to `localhost:3042/app.rb`,
25
- you should see the sample application. Try changing the code and reloading the page,
26
- and the app will update.\n\nIf an error occurs, it will be printed out to the browser
27
- console.\n\nBuilding production releases of Prism apps through the command line
28
- is still a work in progress.\n\n### Writing a Prism App\n\nPrism apps are written
29
- in mruby. mruby is a lightweight implementation of Ruby that's suitable for compiling
30
- to the web.\n\nmruby is similar in many ways to cruby and will be a familiar experience
31
- for someone who has only used the mainline interpreter. The most notable exception
32
- is that mruby only supports syntax up to ruby 1.9, which means there are no keyword
33
- arguments or safe traversal operator.\n\nThere are a number of other small differences,
34
- and it's worth reviewing the [mruby limitations documentation](https://github.com/mruby/mruby/blob/master/doc/limitations.md).
35
- You might also want to refer to the [mruby API docs](http://mruby.org/docs/api/).\n\nIf
36
- you run `prism init`, it will create a sample application that makes a good starting
37
- point. This is the code it outputs:\n\n```ruby\nclass HelloWorld < Prism::Component\n
38
- \ attr_accessor :name\n\n def initialize(name = \"World\")\n @name = name\n
39
- \ end\n\n def render\n div(\".hello-world\", [\n input(onInput: call(:name=).with_target_data(:value)),\n
40
- \ div(\"Hello, #{name}\")\n ])\n end\nend\n\nPrism.mount(HelloWorld.new)\n```\n\nLet's
41
- break this down piece by piece.\n\n----------\n\n```ruby\nclass HelloWorld < Prism::Component\n```\n\nMuch
42
- like Rails, Prism provides most of it's functionality through base classes that
43
- you should inherit from.\n\nThe key concept in Prism is a Component, which should
44
- be familiar to anyone who has worked with JS frameworks like React, Vue or similar.\n\n`Prism::Component`
45
- provides helper methods for creating virtual dom elements, and for handling events.\n\n----------\n\n```ruby\n
46
- \ attr_accessor :name\n\n def initialize(name = \"World\")\n @name = name\n
47
- \ end\n```\n\nThis is fairly standard Ruby, and there's nothing actually unique
48
- to Prism or mruby going on. Note that we're defining an `attr_accessor` rather than
49
- just an `attr_reader`, so that we can set the name directly when it changes.\n\n----------\n\n```ruby\n
50
- \ def render\n div(\".hello-world\", [\n input(onInput: call(:name=).with_target_data(:value)),\n
51
- \ div(\"Hello, #{name}\")\n ])\n end\n```\n\nIt's expected that Prism components
52
- implement a `#render` method that returns a representation of what the current view
53
- should be.\n\nThis should be familiar to anyone who has worked with React, Cycle.js
54
- or Elm. There is a method defined for each different dom element. You can provide
55
- a class name or id as a string (`\".todo-list-item\"` or `\"#login\"`), an object
56
- with options to configure the attributes, props, styles, classes and event listeners,
57
- and an array of child elements.\n\nPrism's virtual dom is powered by `snabddom`,
58
- a tried and true lightweight JavaScript vdom library. For the most part, the API
59
- is simply passed through to snabbdom, so it's worth reading the [snabddom docs](https://github.com/mruby/mruby/blob/master/doc/limitations.md).\n\n----------\n\n```ruby\n
60
- \ input(onInput: call(:name=).with_target_data(:value)),\n```\n\nThe most interesting
61
- line in this example is the event handler for the `input` event.\n\n`Prism::Component`
62
- defines a `#call` method that you can use to call methods on your component when
63
- events occur.\n\n`#call` takes a symbol that is the method name to call, and any
64
- arguments you want passed to the method.\n\nYou can also include data from the event
65
- or target element using `.with_event_data` and `.with_target_data`. These methods
66
- can be chained as needed.\n\n----------\n\n```ruby\nPrism.mount(HelloWorld.new)\n```\n\nThe
67
- last line mounts the HelloWorld component. Prism is currently hardcoded to mount
68
- to an element with id `#root` on load. In future this will be configurable.\n\n\n###
69
- Components and State\n\nPrism aims to provide a component system that should feel
70
- very similar to most virtual dom based JavaScript frameworks.\n\nYou can nest Prism
71
- components, and use instances of Prism components directly when rendering in place
72
- of dom elements.\n\nPrism has no explicit state management built in, preferring
73
- to rely on Ruby's built-in state management tools, primarily instance variables
74
- in class instances.\n\nComponents in a Prism app persist in memory, and will often
75
- have multiple methods call over their lifetime.\n\nLarger Prism applications would
76
- likely benefit from adapting a more structured approach to managing certain parts
77
- of state, a la Redux.\n\n\n### API\n\n#### **`Prism::Component`**\n\n##### `#div(identifier,
78
- options, children), #img, #p, ...`\n\nHelpers for creating virtual dom elements.
79
- There is a method for every type DOM element.\n\nThe arguments are all optional
80
- and can be provided in any order for convenience.\n\nArguments:\n\n - `identifier`
81
- *string, optional* - A shorthand for setting the id and classes. E.g. `\"#login\"`,
82
- `.alert`, `#header.flex.dark`\n\n - `options` *object, optional* - Element configuration\n\n
83
- \ - `attrs` *object, optional* - Attributes that are set when the element is created.
84
- Equivalent to putting items directly into the element in the HTML.\n - `props`
85
- *object, optional* - Props to be set on the object.\n - `style` *object, optional*
86
- - Element styles, keys are css properties and values are strings.\n - `class`
87
- *object, optional* - Keys are class names, values are booleans indicating whether
88
- or not the class is active. An easy way to add or remove classes based on a condition.\n
89
- \ - `on` *function, optional* - Keys are browser events (like `click` or `input`),
90
- values are `Prism::EventHandler` instances. See below on how to create `EventHandler`
91
- instances. Additionally, there are a number of aliases that let you set event handlers
92
- directly on the `options` object. The full list that is currently aliased is: `onClick`,
93
- `onChange`, `onInput`, `onMousedown`, `onMouseup`, `onKeydown`, `onKeyup` and `onScroll`\n\n
94
- \ - `children` *array or string, optional* - Either a string of content for the
95
- element or an array of children. Each child should either be a string, a virtual
96
- dom tree, or an instance of a `Prism::Component` with `#render`.\n\n\n##### `#call(method_name,
97
- *arguments)`\n\nArguments:\n \n - `method_name` *symbol* - The name of the method
98
- to call when the event occurs. Returns a `Prism::EventHandler`.\n - `*arguments`
99
- *any, variadic* - You can provide arguments that will be passed to the method after
100
- the method name. Please note any argument currently needs to be serializable, this
101
- will change in future.\n\n##### `#prevent_default`\n\nTakes no arguments, returns
102
- a `Prism::EventHandler` that does nothing but call `event.preventDefault()`.\n\n#####
103
- `#stop_propagation`\n\nTakes no arguments, returns a `Prism::EventHandler` that
104
- does nothing but call `event.stopPropagation()`.\n\n---------\n\n#### **`Prism::EventHandler`**\n\nRepresents
105
- a handler for an event, with a method to call and arguments to pass. The arguments
106
- are a mixture of values passed from Ruby and values pulled from the event and targed
107
- in JS. The order of arguments is based on how the event handler was constructed.\n\n#####
108
- `#with_args(*args)`\n\nAdds arguments to an existing event handler.\n\n##### `#with_event`\n\nAdd
109
- an event argument to the handler. When the method is called, a serialized version
110
- of the event will be passed.\n\n##### `#with_event_data(*properties)`\n\nAdd arguments
111
- that contain data from the event. The properties should be either a string or a
112
- symbol. One property you might want to extract from the event is `:key` for `keydown`
113
- events.\n\n##### `#with_target_data(*properties)`\n\nAdd arguments that contain
114
- data from the target element. The properties should be either a string or a symbol.
115
- You could for example extract the `:value` of an `input` or the `:checked` field
116
- of a tickbox.\n\n##### `#prevent_default`\n\nCalls `.preventDefault()` on the event
117
- when it occurs.\n\n##### `#stop_propagation`\n\nCalls `.stopPropagation()` on the
118
- event when it occurs.\n\n#### Examples:\n\n`call(:name=).with_target_data(:value)`
119
- - calls a setter with the content of the target element\n`call(:goto_page, 5).with_event`
120
- - calls a method with the number 5 as the first argument and the event data as the
121
- second\n\n#### `Prism.mount(component)`\n\nTakes an instance of a `Prism::Component`
122
- and returns a `Prism::MountPoint`.\n\nThe `MountPoint` should be the result of the
123
- last expression in the file, as it is used by the Prism C and JS runtime to interact
124
- with the application.\n\n### Future\n\nAs mentioned above, Prism is still in extremely
125
- early development. The following would be nice to have but has yet to be implemented.\n\n
126
- - support for require\n - transpile modern ruby syntax to 1.9\n - a way for users
127
- to make their own IO drivers\n - built in support for HTTP\n - compile time improvements\n
128
- - fallback to asm.js for old browsers\n - rails integration\n - SSR\n - sourcemaps
129
- for mruby code\n - linting for incompatibilities with cruby\n - elm-reactor style
130
- dev server\n\nIf you're interested in helping implement any of those features, or
131
- you want to contribute in any way, please make an issue or a pull request or just
132
- [get in touch with me](mailto:ncwjohnston@gmail.com).\n\nPrism is currently developed
133
- by a single person (who also has a lot of other ambitious projects). I would love
134
- to have some other people to help share the load. There's lots of low hanging fruit
135
- still to be plucked.\n\n### Supporting Prism Development\n\nMost open source projects
136
- are built on a mountain of unpaid labour. Even hugely successful projects that have
137
- good funding tend to have a history of excess unpaid labour to get to that point.\n\nPrism
138
- is taking a different approach, by launching with an Open Collective page. We're
139
- using Open Collective because it enables us to fund Prism as a project rather than
140
- one particular person. Funds in the Open Collective will only go towards future
141
- development.\n\nIf you think this is a worthwhile project, please support us on
142
- Open Collective. If you think your company could benefit from Prism in the future,
143
- please advocate for your company to financially support Prism.\n\nMy main goal around
144
- starting Prism with funding is that I want as much of the work that's done on Prism
145
- as possible to be reimbursed, no matter who's doing it. The other aspect is that
146
- I don't have very much spare time for projects but if I can get paid for my work
147
- I can do Prism as part of my day to day contract work.\n\n**[Support Prism on Open
148
- Collective](https://opencollective.com/prism)**\n\n### License\n\nPrism is available
149
- under the MIT license. Please see the LICENSE file for more details.\n"
13
+ description: |-
14
+ Prism is a framework for building clientside web apps with Ruby.
15
+
16
+ It's powered by mruby, emscripten and WebAssembly.
17
+
18
+ For more information check out the docs on the github repo.
150
19
  email: ncwjohnstone@gmail.com
151
20
  executables:
152
21
  - prism