hyper-console 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 771a51bc72df0a15f6a12898b8aaee315266301c
4
+ data.tar.gz: 9ef9b3bb8ce2447c24e6285ac236768097fe4fdb
5
+ SHA512:
6
+ metadata.gz: 557f5e0621c254ca74227520900d1aaf64f059d3889a41521c113ffec0bb2f4026b99ef1d1db9454a2b1abb64c2c79157d16bd2bb3c3f1785ece6e7001d95b0e
7
+ data.tar.gz: d2331e57ec5830baefc19ae6dee3b8f34e7935638d908b545c35add669e5dd8ed7c2281f45add9d69ba3fd134bd2b3f597ce862dd104256eac3367ad3015acdf
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /db/*.sqlite3-journal
8
+ /public/system
9
+ /coverage/
10
+ /spec/tmp
11
+ **.orig
12
+ rerun.txt
13
+ pickle-email-*.html
14
+
15
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
16
+ config/initializers/secret_token.rb
17
+ config/secrets.yml
18
+
19
+ # dotenv
20
+ # TODO Comment out this rule if environment variables can be committed
21
+ .env
22
+
23
+ ## Environment normalization:
24
+ /.bundle
25
+ /vendor/bundle
26
+
27
+ # these should all be checked in to normalize the environment:
28
+ # Gemfile.lock, .ruby-version, .ruby-gemset
29
+
30
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
31
+ .rvmrc
32
+
33
+ # if using bower-rails ignore default bower_components path bower.json files
34
+ /vendor/assets/bower_components
35
+ *.bowerrc
36
+ bower.json
37
+
38
+ # Ignore pow environment settings
39
+ .powenv
40
+
41
+ # Ignore Byebug command history file.
42
+ .byebug_history
43
+
44
+ # Ignore test app files
45
+ /spec/test_app/log/
46
+ /spec/test_app/tmp/
47
+
48
+ # Ignore built gem
49
+ *.gem
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at mitch@catprint.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hyper-console.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,235 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hyper-console (0.1.0)
5
+ hyper-operation
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.0.2)
11
+ actionpack (= 5.0.2)
12
+ nio4r (>= 1.2, < 3.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.0.2)
15
+ actionpack (= 5.0.2)
16
+ actionview (= 5.0.2)
17
+ activejob (= 5.0.2)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.0.2)
21
+ actionview (= 5.0.2)
22
+ activesupport (= 5.0.2)
23
+ rack (~> 2.0)
24
+ rack-test (~> 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.0.2)
28
+ activesupport (= 5.0.2)
29
+ builder (~> 3.1)
30
+ erubis (~> 2.7.0)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.0.2)
34
+ activesupport (= 5.0.2)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.0.2)
37
+ activesupport (= 5.0.2)
38
+ activerecord (5.0.2)
39
+ activemodel (= 5.0.2)
40
+ activesupport (= 5.0.2)
41
+ arel (~> 7.0)
42
+ activesupport (5.0.2)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
47
+ addressable (2.5.1)
48
+ public_suffix (~> 2.0, >= 2.0.2)
49
+ arel (7.1.4)
50
+ babel-source (5.8.35)
51
+ babel-transpiler (0.7.0)
52
+ babel-source (>= 4.0, < 6)
53
+ execjs (~> 2.0)
54
+ builder (3.2.3)
55
+ coffee-script-source (1.12.2)
56
+ concurrent-ruby (1.0.5)
57
+ connection_pool (2.2.1)
58
+ cookiejar (0.3.3)
59
+ daemons (1.2.4)
60
+ em-http-request (1.1.5)
61
+ addressable (>= 2.3.4)
62
+ cookiejar (!= 0.3.1)
63
+ em-socksify (>= 0.3)
64
+ eventmachine (>= 1.0.3)
65
+ http_parser.rb (>= 0.6.0)
66
+ em-socksify (0.3.1)
67
+ eventmachine (>= 1.0.0.beta.4)
68
+ em-websocket (0.5.1)
69
+ eventmachine (>= 0.12.9)
70
+ http_parser.rb (~> 0.6.0)
71
+ erubis (2.7.0)
72
+ eventmachine (1.2.3)
73
+ execjs (2.7.0)
74
+ globalid (0.4.0)
75
+ activesupport (>= 4.2.0)
76
+ hike (1.2.3)
77
+ http_parser.rb (0.6.0)
78
+ httpclient (2.8.3)
79
+ hyper-component (0.12.3)
80
+ hyper-react (>= 0.12.3)
81
+ hyperloop-config (>= 0.9.2)
82
+ opal-rails (~> 0.9.0)
83
+ react-rails (< 1.10.0)
84
+ hyper-operation (0.5.4)
85
+ activerecord (>= 0.3.0)
86
+ hyper-component (>= 0.12.2)
87
+ hyperloop-config (>= 0.9.7)
88
+ mutations
89
+ opal-activesupport
90
+ pusher
91
+ pusher-fake
92
+ hyper-react (0.12.5)
93
+ hyper-store (>= 0.2.1)
94
+ hyperloop-config (>= 0.9.7)
95
+ opal (>= 0.8.0)
96
+ opal-activesupport (>= 0.2.0)
97
+ hyper-store (0.2.2)
98
+ hyperloop-config (>= 0.9.2)
99
+ hyperloop-config (0.9.8)
100
+ opal
101
+ opal-browser
102
+ i18n (0.8.1)
103
+ jquery-rails (4.3.1)
104
+ rails-dom-testing (>= 1, < 3)
105
+ railties (>= 4.2.0)
106
+ thor (>= 0.14, < 2.0)
107
+ loofah (2.0.3)
108
+ nokogiri (>= 1.5.9)
109
+ mail (2.6.4)
110
+ mime-types (>= 1.16, < 4)
111
+ method_source (0.8.2)
112
+ mime-types (3.1)
113
+ mime-types-data (~> 3.2015)
114
+ mime-types-data (3.2016.0521)
115
+ mini_portile2 (2.1.0)
116
+ minitest (5.10.1)
117
+ multi_json (1.12.1)
118
+ mutations (0.8.1)
119
+ activesupport
120
+ nio4r (2.0.0)
121
+ nokogiri (1.7.1)
122
+ mini_portile2 (~> 2.1.0)
123
+ opal (0.10.3)
124
+ hike (~> 1.2)
125
+ sourcemap (~> 0.1.0)
126
+ sprockets (~> 3.1)
127
+ tilt (>= 1.4)
128
+ opal-activesupport (0.3.0)
129
+ opal (>= 0.5.0, < 1.0.0)
130
+ opal-browser (0.2.0)
131
+ opal
132
+ paggio
133
+ opal-jquery (0.4.2)
134
+ opal (>= 0.7.0, < 0.11.0)
135
+ opal-rails (0.9.1)
136
+ jquery-rails
137
+ opal (>= 0.8.0, < 0.11)
138
+ opal-activesupport (>= 0.0.5)
139
+ opal-jquery (~> 0.4.0)
140
+ opal-sprockets (~> 0.4.0)
141
+ rails (>= 4.0, < 6.0)
142
+ sprockets-rails (< 3.0)
143
+ opal-sprockets (0.4.0.0.10.0.3.0.0)
144
+ opal (~> 0.10.0)
145
+ sprockets (~> 3.0)
146
+ tilt (>= 1.4)
147
+ paggio (0.2.6)
148
+ public_suffix (2.0.5)
149
+ pusher (1.3.1)
150
+ httpclient (~> 2.7)
151
+ multi_json (~> 1.0)
152
+ pusher-signature (~> 0.1.8)
153
+ pusher-fake (1.8.0)
154
+ em-http-request (~> 1.1)
155
+ em-websocket (~> 0.5)
156
+ multi_json (~> 1.6)
157
+ thin (~> 1.5)
158
+ pusher-signature (0.1.8)
159
+ rack (2.0.1)
160
+ rack-test (0.6.3)
161
+ rack (>= 1.0)
162
+ rails (5.0.2)
163
+ actioncable (= 5.0.2)
164
+ actionmailer (= 5.0.2)
165
+ actionpack (= 5.0.2)
166
+ actionview (= 5.0.2)
167
+ activejob (= 5.0.2)
168
+ activemodel (= 5.0.2)
169
+ activerecord (= 5.0.2)
170
+ activesupport (= 5.0.2)
171
+ bundler (>= 1.3.0, < 2.0)
172
+ railties (= 5.0.2)
173
+ sprockets-rails (>= 2.0.0)
174
+ rails-dom-testing (2.0.2)
175
+ activesupport (>= 4.2.0, < 6.0)
176
+ nokogiri (~> 1.6)
177
+ rails-html-sanitizer (1.0.3)
178
+ loofah (~> 2.0)
179
+ railties (5.0.2)
180
+ actionpack (= 5.0.2)
181
+ activesupport (= 5.0.2)
182
+ method_source
183
+ rake (>= 0.8.7)
184
+ thor (>= 0.18.1, < 2.0)
185
+ rake (10.5.0)
186
+ react-rails (1.9.0)
187
+ babel-transpiler (>= 0.7.0)
188
+ coffee-script-source (~> 1.8)
189
+ connection_pool
190
+ execjs
191
+ railties (>= 3.2)
192
+ tilt
193
+ sourcemap (0.1.1)
194
+ sprockets (3.7.1)
195
+ concurrent-ruby (~> 1.0)
196
+ rack (> 1, < 3)
197
+ sprockets-rails (2.3.3)
198
+ actionpack (>= 3.0)
199
+ activesupport (>= 3.0)
200
+ sprockets (>= 2.8, < 4.0)
201
+ thin (1.7.0)
202
+ daemons (~> 1.0, >= 1.0.9)
203
+ eventmachine (~> 1.0, >= 1.0.4)
204
+ rack (>= 1, < 3)
205
+ thor (0.19.4)
206
+ thread_safe (0.3.6)
207
+ tilt (2.0.7)
208
+ tzinfo (1.2.3)
209
+ thread_safe (~> 0.1)
210
+ uglifier (3.2.0)
211
+ execjs (>= 0.3.0, < 3)
212
+ websocket-driver (0.6.5)
213
+ websocket-extensions (>= 0.1.0)
214
+ websocket-extensions (0.1.2)
215
+
216
+ PLATFORMS
217
+ ruby
218
+
219
+ DEPENDENCIES
220
+ bundler (~> 1.12)
221
+ hyper-component
222
+ hyper-console!
223
+ hyper-operation
224
+ hyper-store
225
+ hyperloop-config
226
+ opal
227
+ opal-browser
228
+ opal-jquery
229
+ opal-rails (>= 0.8.1)
230
+ rails
231
+ rake (~> 10.0)
232
+ uglifier
233
+
234
+ BUNDLED WITH
235
+ 1.12.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 catmando
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # Hyper-Console
2
+
3
+ IRB style console for [Hyperloop](http://ruby-hyperloop.io) applications.
4
+
5
+ ![Screen](screen_shot.png)
6
+
7
+ ### Installation
8
+
9
+ Add
10
+
11
+ ```ruby
12
+ gem 'hyper-console'
13
+ ```
14
+
15
+ To the development and test sections of your Gemfile.
16
+
17
+ Do a `bundle install`, and `rm -rf tmp/cache`, then restart the server, hit one of your web pages, and the console will open.
18
+
19
+ *Note currently you must have enabled the `Hyperloop::Application` channel in your policies. Hopefully we can remove this in the future*
20
+
21
+ *Note for Rails 4.x you will also need to add these lines to `config/initializer/assets.rb`:*
22
+
23
+ ```ruby
24
+ Rails.application.config.assets.precompile += %w( hyper-console-client.css )
25
+ Rails.application.config.assets.precompile += %w( hyper-console-client.min.js )
26
+ ```
27
+
28
+ ### Details
29
+
30
+ The `hyper-console` gem adds the `console` method to `Kernel`. If you call `console` from anywhere in your client code, it will open a new *popup* window, that is running an IRB style read-eval loop. The console window will compile what ever ruby code you type, and if it compiles, will send it to your main window for execution. The result (or error message) plus any console output will be displayed in the console window.
31
+
32
+ + You may use the up/down arrow keys to move to previous expressions, edit them, and resend.
33
+ + If you are editing a block of code you can send the block immediately without moving to the end of the expression by using command (or ctrl) enter.
34
+ + The console history is stored in the popups html local store, so it will be retained across window reloads.
35
+ + The expression can be arbitrarily complex. You can investigate model scopes, and attributes, run Operations, and get the current value of component states.
36
+ + You can even create classes, or open existing classes and modify their behavior.
37
+
38
+ ### The `instance` method
39
+
40
+ The console gem adds an `instance` method to all classes. This will return an array like object of all the current instances of that class, *except instances bound to closures (sorry!)*.
41
+
42
+ For example if you have a component named `Components::TodoItem` then
43
+
44
+ ```ruby
45
+ Components::TodoItem.instance[0] # first instance
46
+ Components::TodoItem.instance # array of all the instances
47
+ Components::TodoItem.instance[0].dom_node # returns the mount point
48
+ ```
49
+
50
+ This is all very handy for investigating the state of Components and Stores. For example assuming your top level component is named `App` and is using hyper-router, you can do things like this:
51
+
52
+ ```ruby
53
+ App.instance[0].location.pathname # current path
54
+ App.instance[0].history.push '/topics' # change path to `/topics`
55
+ ```
56
+
57
+ Because its common for there to be a single instance of some classes, the expression `instance[0]` can be shortened to just `instance` when there is only one instance of a class. For example in the above example you could just say `App.instance.location.pathname`.
58
+
59
+ ### Console Context
60
+
61
+ Each console window (you can have several) has an execution context, which is simply an expression that is used to determine the value of `self` that console executes in.
62
+
63
+ For example let's say you have a `Todo` model. You could in the console window evaluate
64
+
65
+ ```ruby
66
+ console context: 'Todo.first'
67
+ ```
68
+
69
+ And a new console window will be opened that is "bound" to `Todo.first` so that in this window you can simply evaluate
70
+
71
+ ```ruby
72
+ title
73
+ ```
74
+ Instead of `Todo.first.title`
75
+
76
+ Combining this with the `instance` method gives you a way to create a console window on a specific object in your application:
77
+
78
+ ```ruby
79
+ console context: 'App.instance'
80
+ ```
81
+
82
+ Will create a console window whose `self` is your top level application component.
83
+
84
+ *Note: if no context is provided, the context will be main opal context.*
85
+
86
+ ### Console Titles
87
+
88
+ You can also give console windows a title:
89
+
90
+ ```ruby
91
+ console text: 'App.instance', title: 'App'
92
+ ```
93
+
94
+ ### Loading / Reloading from Javascript
95
+
96
+ The `hyperconsole` method is added to the javascript window object, so in your application's javascript console you can say `hyperconsole()` to load (or reload) the main hyperconsole window. When reloading any prior command history will be retained, so this makes a nice escape hatch if things ever become totally confused.
97
+
98
+ ### Loading at Application Boot
99
+
100
+ By default a console will be created when your page loads. You can turn this off by setting
101
+ ```ruby
102
+ config.console_auto_start = false
103
+ ```
104
+ in your hyperloop rails initializer.
105
+
106
+ You can still start the console using `hyperconsole()` as described above.
107
+
108
+ ### How it works
109
+
110
+ The console and main application window communicate via two Hyperloop Operations: `Evaluate`, and `Response`.
111
+
112
+ As you type, the console runs the Opal compiler in the console window, and when you have a valid ruby expression, the resulting compiled code is sent to the main window using `Evaluate`. The main window receives the Evaluate dispatch, does a javascript eval and returns the result.
113
+
114
+ ## Development
115
+
116
+ After checking out the repo, run bundle install.
117
+
118
+ The console assets are packaged into a single JS file, and a single style sheet. Running `rake` will build the packages, and put them in the appropriate directories.
119
+
120
+ ## TODO (help wanted)
121
+
122
+ + configurable themes, especially smaller font size
123
+ + full keyboard controls (i.e things like ctrl-a moves to beginning of line)
124
+ + remove dependency on `Hyperloop::Application` channel
125
+ + Peer to peer communication once initial connection is made
126
+ + Chrome extension so that console can be attached physically to main window
127
+ + add some kind of test suite, and ability to test without building the asset package
128
+
129
+ ## Contributing
130
+
131
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hyper-console. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
132
+
133
+ ## License
134
+
135
+ Hyperloop gems are released under the [MIT License](http://www.opensource.org/licenses/MIT).