wedge 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c03ec1090649b719dd845c4167b3c717886cd59a
4
- data.tar.gz: d8193a5ffec834680dbe884db02416ccc935805b
3
+ metadata.gz: bec19fa97267952287dd19eb59c0ef60ea1ec798
4
+ data.tar.gz: 99539718ec725a14caada41cb292ebc2d607c706
5
5
  SHA512:
6
- metadata.gz: c62a5ab5e18f862c9734e2abb8ccfa3422ac5e6d97942283e01cebd2df94bd4ea2ffbf444b27e1e7844e6797688d217608e0edc35b442cbe3df0f4182bf57a88
7
- data.tar.gz: 0c3746d9d3074b798bb5dc1836785c2e4b46c8a6bbeffdadeb2ad397b8070dced9bbe358e43cd251582a5e58a96afeb777d9bca59d229d5d8a8c40822d35c928
6
+ metadata.gz: b6291df78a9eb3c351d65013afb6719f59a4d08f7b5edffc674aeb7fd53ebf8481020977d47dcb36588c17760398c7d28b6e978fa875a861d062c8a0dfebe0fc
7
+ data.tar.gz: d27efe62f63e0f26e833541ae466042f81fb20dfbbd8f7f83441ea97d658d458b50e0aa3d66b1f8443b356365b700e8ae2a8b911c7cb6972dc38db9477ba7360
data/Gemfile CHANGED
@@ -3,8 +3,9 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in BrowserIO.gemspec
4
4
  gemspec
5
5
 
6
- gem 'opal', github: 'opal/opal', path: '~/gems/opal'
6
+ gem 'opal', github: 'opal/opal'
7
7
  gem 'opal-jquery', github: 'opal/opal-jquery'
8
+ gem 'opal-rspec', github: 'opal/opal-rspec'
8
9
  gem 'binding_of_caller'
9
10
  gem 'better_errors'
10
11
  gem 'slim'
data/Rakefile CHANGED
@@ -1,9 +1,23 @@
1
+ require 'bundler'
1
2
  require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
+ Bundler.require
3
4
 
4
- Rake::TestTask.new do |task|
5
- task.libs << %w(test lib)
6
- task.pattern = 'test/**/test_*.rb'
5
+ Opal.append_path File.expand_path('../lib', __FILE__)
6
+ Opal.append_path File.expand_path('../playground', __FILE__)
7
+
8
+ require 'opal/rspec/rake_task'
9
+ Opal::RSpec::RakeTask.new('opal:rspec') do |s|
10
+ s.index_path = 'spec/index.html.erb'
7
11
  end
8
12
 
9
- task default: :test
13
+ task default: [:test]
14
+
15
+ require 'rspec/core/rake_task'
16
+ RSpec::Core::RakeTask.new('ruby:rspec')
17
+
18
+ task :test do
19
+ puts "--------------------------\nRun specs in Opal\n--------------------------"
20
+ Rake::Task['opal:rspec'].invoke
21
+ puts "--------------------------\nRun specs in normal ruby\n--------------------------"
22
+ Rake::Task['ruby:rspec'].invoke
23
+ end
@@ -126,8 +126,8 @@ class Wedge
126
126
  alias_method :on, :wedge_on
127
127
 
128
128
  def method_missing(method, *args, &block)
129
- if config.scope.respond_to?(method, true)
130
- config.scope.send method, *args, &block
129
+ if wedge_config.scope.respond_to?(method, true)
130
+ wedge_config.scope.send method, *args, &block
131
131
  else
132
132
  super
133
133
  end
@@ -208,7 +208,7 @@ class Wedge
208
208
 
209
209
  def html!(&b)
210
210
  unless RUBY_ENGINE == 'opal'
211
- DOM.new HTML::DSL.html(&b).to_html
211
+ Wedge.html!(&b)
212
212
  end
213
213
  end
214
214
 
@@ -331,7 +331,7 @@ class Wedge
331
331
  end
332
332
 
333
333
  def wedge_html(&b)
334
- DOM.new HTML::DSL.html(&b).to_html
334
+ Wedge.html!(&b)
335
335
  end
336
336
  alias_method :html!, :wedge_html
337
337
 
@@ -37,21 +37,28 @@ class Wedge
37
37
  body << File.read("#{ROOT_PATH}/#{wedge_path}.rb")
38
38
  end if Wedge.config.debug
39
39
  when 'call'
40
- body_data = scope.request.body.read
41
- data = scope.request.params
42
-
43
- begin
44
- data.merge!(body_data ? JSON.parse(body_data) : {})
45
- rescue
46
- # can't be parsed by json
47
- end
48
-
49
- data = data.indifferent
50
- name = data.delete(:wedge_name)
51
- method_called = data.delete(:wedge_method_called)
52
- method_args = data.delete(:wedge_method_args)
53
-
54
- if method_args == 'wedge_data' && data
40
+ body_data = request.body.read
41
+ data = request.params
42
+
43
+ begin
44
+ # try json
45
+ data.merge!(body_data ? JSON.parse(body_data) : {})
46
+ rescue
47
+ begin
48
+ # try form data
49
+ data.merge!(body_data ? Rack::Utils.parse_query(body_data) : {})
50
+ rescue
51
+ # no data
52
+ end
53
+ end
54
+
55
+ data = data.indifferent
56
+ name = data.delete(:__wedge_name__)
57
+ method_called = data.delete(:__wedge_method__)
58
+ method_args = data.delete(:__wedge_args__)
59
+
60
+ binding.pry
61
+ if method_args == '__wedge_data__' && data
55
62
  method_args = [data]
56
63
  body << Wedge.scope!(app)[name].send(method_called, *method_args) || ''
57
64
  else
@@ -260,7 +260,10 @@ class Wedge
260
260
  end
261
261
 
262
262
  def settings
263
- @settings ||= store[:settings].dup
263
+ @settings ||= {
264
+ aws_access_key_id: 123456,
265
+ bucket: 'wedge'
266
+ }
264
267
  end
265
268
  end
266
269
  end
data/lib/wedge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Wedge
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
data/lib/wedge.rb CHANGED
@@ -45,6 +45,10 @@ class Wedge
45
45
  "#{config.assets_url}#{config.cache_assets ? "/#{config.assets_key}" : ''}"
46
46
  end
47
47
 
48
+ def html!(&b)
49
+ DOM.new HTML::DSL.html(&b).to_html
50
+ end
51
+
48
52
  def script_tag
49
53
  "<script src='#{assets_url}/wedge.js'></script>"
50
54
  end
@@ -1,5 +1,14 @@
1
1
  require File.expand_path '../variables', __FILE__
2
2
 
3
+ begin
4
+ # use `bundle install --standalone --binstubs .bundle/bin' to get this...
5
+ require_relative '../.bundle/bundler/setup'
6
+ rescue LoadError
7
+ # fall back to regular bundler if the developer hasn't bundled standalone
8
+ require 'bundler'
9
+ Bundler.setup :default, RACK_ENV
10
+ end
11
+
3
12
  require 'roda'
4
13
  require 'wedge'
5
14
 
@@ -1,13 +1,14 @@
1
1
  Encoding.default_external = 'UTF-8'
2
2
 
3
- APP_ROOT = File.expand_path '../../', __FILE__ unless defined?(APP_ROOT)
4
- RACK_ENV = ENV.fetch('RACK_ENV') { 'development' }.freeze
3
+ APP_ROOT = File.expand_path '../../', __FILE__ unless defined?(APP_ROOT)
4
+ RACK_ENV = ENV.fetch('RACK_ENV') { 'development' }.freeze
5
5
 
6
6
  # Load environment variables
7
7
  %W{.env .env.#{ENV['RACK_ENV']}}.each do |file|
8
- File.foreach file do |line|
8
+ file_path = "#{APP_ROOT}/../#{file}"
9
+ File.foreach file_path do |line|
9
10
  key, value = line.split "=", 2; ENV[key] = value.gsub('\n', '').strip
10
- end if File.file? file
11
+ end if File.file? file_path
11
12
  end if %w{development test}.include? RACK_ENV
12
13
 
13
14
  APP_SECRET = ENV.fetch('APP_SECRET').freeze
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ </head>
5
+ <body>
6
+ <%= javascript_include_tag 'public/vendor/jquery/jquery' %>
7
+ <%= javascript_include_tag 'bower_components/fine-uploader/_build/s3.jquery.fine-uploader' %>
8
+ <%= javascript_include_tag @server.main %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'app/components/layout'
3
+
4
+ describe Playground::LayoutComponent do
5
+ subject(:layout) { Wedge[:layout] }
6
+
7
+ context '#display' do
8
+ subject { layout.display }
9
+
10
+ if Wedge.server?
11
+ it { is_expected.to be_a Wedge::DOM }
12
+ else
13
+ it { is_expected.to be_nil }
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'app/components/uploader'
3
+
4
+ describe Playground::UploaderComponent do
5
+ subject(:uploader) { Wedge[:uploader] }
6
+
7
+ html Wedge.html! { button 'Upload' }.to_html
8
+
9
+ context '#display' do
10
+ subject { uploader.display }
11
+
12
+ if Wedge.server?
13
+ it { is_expected.to be_a Wedge::DOM }
14
+ else
15
+ it { is_expected.to be_nil }
16
+ end
17
+ end
18
+
19
+ context 'browser_events' do
20
+ before do
21
+ Wedge::Plugins::Uploader.any_instance.stub(:settings).and_return({
22
+ aws_access_key_id: 123456,
23
+ bucket: 'wedge'
24
+ })
25
+ uploader.trigger :browser_events
26
+ end
27
+
28
+ it 'should have fine uploader button' do
29
+ expect(uploader.dom.find('.qq-uploader').to_html).not_to be_empty
30
+ end
31
+ end if Wedge.client?
32
+ end
@@ -0,0 +1,23 @@
1
+ if RUBY_ENGINE == 'opal'
2
+ require 'wedge'
3
+ require 'opal-rspec'
4
+ require 'opal/jquery'
5
+ require 'opal/jquery/rspec'
6
+ else
7
+ ENV['RACK_ENV'] ||= 'test'
8
+
9
+ $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
10
+ $:.unshift(File.expand_path("../playground", File.dirname(__FILE__)))
11
+
12
+ # this is so it doesn't throw an error because we use opal/jquery/rspec which
13
+ # adds an html method client side.
14
+ module RSpecHelpers
15
+ def html(_); end
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.extend RSpecHelpers
20
+ end
21
+
22
+ require 'app/config/boot'
23
+ end
data/wedge.gemspec CHANGED
@@ -22,11 +22,15 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "opal-jquery"
23
23
  spec.add_runtime_dependency "nokogiri"
24
24
 
25
+ spec.add_development_dependency 'minitest-line'
26
+ spec.add_development_dependency 'minitest-reporters'
27
+ spec.add_development_dependency 'opal-rspec'
28
+ spec.add_development_dependency 'rspec'
25
29
  spec.add_development_dependency "pry"
30
+ spec.add_development_dependency "rake"
26
31
  spec.add_development_dependency "awesome_print"
27
32
  spec.add_development_dependency "yard"
28
33
  spec.add_development_dependency "phantomjs.rb"
29
- spec.add_development_dependency 'minitest-line'
30
- spec.add_development_dependency 'minitest-reporters'
31
34
  spec.add_development_dependency 'roda'
35
+
32
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wedge
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
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-19 00:00:00.000000000 Z
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pry
56
+ name: minitest-line
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: awesome_print
70
+ name: minitest-reporters
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: yard
84
+ name: opal-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: phantomjs.rb
98
+ name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: minitest-line
112
+ name: pry
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -123,7 +123,49 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: minitest-reporters
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: awesome_print
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: phantomjs.rb
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - ">="
@@ -225,6 +267,10 @@ files:
225
267
  - playground/src/includes/_head.slim
226
268
  - playground/src/index.slim
227
269
  - playground/src/uploader.slim
270
+ - spec/index.html.erb
271
+ - spec/playground/layout_spec.rb
272
+ - spec/playground/uploader_spec.rb
273
+ - spec/spec_helper.rb
228
274
  - test.rb
229
275
  - test/test.js
230
276
  - test/test_basic_component.rb
@@ -256,6 +302,10 @@ signing_key:
256
302
  specification_version: 4
257
303
  summary: Components for the Browser and Server
258
304
  test_files:
305
+ - spec/index.html.erb
306
+ - spec/playground/layout_spec.rb
307
+ - spec/playground/uploader_spec.rb
308
+ - spec/spec_helper.rb
259
309
  - test/test.js
260
310
  - test/test_basic_component.rb
261
311
  - test/test_browserio.rb