fron 0.1.0 → 0.1.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +4 -0
  5. data/Gemfile.lock +35 -0
  6. data/Rakefile +18 -0
  7. data/docs/configuration.md +8 -8
  8. data/lib/fron/version.rb +1 -1
  9. data/opal/fron/core.rb +1 -1
  10. data/opal/fron/core/adapters/{local-storage.rb → local.rb} +7 -6
  11. data/opal/fron/core/application.rb +13 -11
  12. data/opal/fron/core/configuration.rb +3 -4
  13. data/opal/fron/core/controller.rb +2 -2
  14. data/opal/fron/core/eventable.rb +5 -2
  15. data/opal/fron/core/logger.rb +7 -0
  16. data/opal/fron/core/model.rb +10 -8
  17. data/opal/fron/core/router.rb +1 -1
  18. data/opal/fron/dom.rb +1 -0
  19. data/opal/fron/dom/document.rb +4 -0
  20. data/opal/fron/dom/element.rb +22 -6
  21. data/opal/fron/dom/event.rb +71 -68
  22. data/opal/fron/dom/fragment.rb +1 -3
  23. data/opal/fron/dom/modules/classlist.rb +2 -2
  24. data/opal/fron/dom/modules/dimensions.rb +7 -8
  25. data/opal/fron/dom/modules/events.rb +57 -12
  26. data/opal/fron/dom/node.rb +45 -11
  27. data/opal/fron/dom/nodelist.rb +14 -0
  28. data/opal/fron/dom/style.rb +17 -15
  29. data/opal/fron/dom/text.rb +2 -4
  30. data/opal/fron/dom/window.rb +2 -3
  31. data/opal/fron/request/request.rb +17 -14
  32. data/opal/fron/storage/local-storage.rb +29 -13
  33. data/spec/core-ext/hash_spec.rb +18 -0
  34. data/spec/core/adapter/local_spec.rb +65 -0
  35. data/spec/core/adapter/rails_spec.rb +72 -0
  36. data/spec/core/application_spec.rb +35 -0
  37. data/spec/core/component_spec.rb +107 -0
  38. data/spec/core/configuration_spec.rb +20 -0
  39. data/spec/core/controlller_spec.rb +68 -0
  40. data/spec/core/eventable_spec.rb +74 -0
  41. data/spec/core/logger_spec.rb +28 -0
  42. data/spec/core/model_spec.rb +125 -0
  43. data/spec/core/router_spec.rb +127 -0
  44. data/spec/dom/document_spec.rb +41 -0
  45. data/spec/dom/element_spec.rb +164 -0
  46. data/spec/dom/event_spec.rb +121 -0
  47. data/spec/dom/fragment_spec.rb +13 -0
  48. data/spec/dom/modules/classlist_spec.rb +72 -0
  49. data/spec/dom/modules/dimensions_spec.rb +55 -0
  50. data/spec/dom/modules/events_spec.rb +73 -0
  51. data/spec/dom/node_spec.rb +189 -0
  52. data/spec/dom/nodelist_spec.rb +12 -0
  53. data/spec/dom/style_spec.rb +31 -0
  54. data/spec/dom/text_spec.rb +12 -0
  55. data/spec/dom/window_spec.rb +30 -0
  56. data/spec/request/request_spec.rb +71 -0
  57. data/spec/request/response_spec.rb +46 -0
  58. data/spec/storage/local-storage_spec.rb +58 -0
  59. metadata +36 -4
@@ -0,0 +1,12 @@
1
+ describe DOM::Text do
2
+
3
+ subject { described_class.new('test') }
4
+ let(:el) { subject.instance_variable_get("@el") }
5
+
6
+ describe "#initailize" do
7
+ it 'should create textNode with given value' do
8
+ subject.text.should eq 'test'
9
+ `#{el} instanceof Text`.should be true
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ describe DOM::Window do
2
+
3
+ subject { described_class }
4
+
5
+ describe "#hash" do
6
+ it 'should return the hash of the url' do
7
+ `window.location.hash = 'test'`
8
+ subject.hash.should eq 'test'
9
+ end
10
+ end
11
+
12
+ describe "#hash=" do
13
+ it 'should set the hash of the url' do
14
+ subject.hash = 'test'
15
+ `window.location.hash.slice(1)`.should eq 'test'
16
+ end
17
+ end
18
+
19
+ describe "scrollY" do
20
+ it 'should return the vertical scroll position' do
21
+ subject.scrollY.should eq 0
22
+ end
23
+ end
24
+
25
+ describe "scrollX" do
26
+ it 'should return the horizontal scroll position' do
27
+ subject.scrollX.should eq 0
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,71 @@
1
+ require 'fron/request'
2
+
3
+ describe Fron::Request do
4
+
5
+ subject { described_class.new 'url' }
6
+ let(:request) {%x{
7
+ return { readyState: 0,
8
+ open: function(){this.opened = true},
9
+ send: function(){this.sent = true}}
10
+ }}
11
+ let(:data) { double :data, to_query_string: '', to_form_data: true }
12
+
13
+ before do
14
+ subject.instance_variable_set("@request", request)
15
+ end
16
+
17
+ describe "#request" do
18
+ it 'should raise if the rquest is already running' do
19
+ allow(subject).to receive(:ready_state).and_return 1
20
+ expect(Proc.new {subject.request} ).to raise_error
21
+ end
22
+
23
+ it 'should call #open on request' do
24
+ subject.get
25
+ expect(`#{request}.opened`).to be true
26
+ end
27
+
28
+ it 'should call #send on request' do
29
+ subject.get
30
+ expect(`#{request}.sent`).to be true
31
+ end
32
+
33
+ it 'should call #to_query_string on data if it is a GET' do
34
+ expect(data).to receive(:to_query_string)
35
+ expect(data).not_to receive(:to_form_data)
36
+ subject.get data
37
+ end
38
+
39
+ it 'should call #to_form_data on data if it is a GET' do
40
+ expect(data).not_to receive(:to_query_string)
41
+ expect(data).to receive(:to_form_data)
42
+ subject.post data
43
+ end
44
+
45
+ it 'should set @callback' do
46
+ subject.get do end
47
+ subject.instance_variable_get('@callback').should_not be nil
48
+ end
49
+ end
50
+
51
+ describe "#get" do
52
+ it 'should call #request with GET' do
53
+ expect(subject).to receive(:request).once
54
+ subject.get
55
+ end
56
+ end
57
+
58
+ describe "#post" do
59
+ it 'should call #request with POST' do
60
+ expect(subject).to receive(:request).once
61
+ subject.post
62
+ end
63
+ end
64
+
65
+ describe "#put" do
66
+ it 'should call #request with PUT' do
67
+ expect(subject).to receive(:request).once
68
+ subject.put
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,46 @@
1
+ require 'fron/request'
2
+
3
+ describe Fron::Response do
4
+
5
+ let(:headers) { "Content-Type: application/json"}
6
+ let(:status) { 200 }
7
+ let(:body) {'<div></div>'}
8
+ subject { described_class.new status, body, headers }
9
+
10
+ describe "#json" do
11
+ let(:body) { {key: 'value'}.to_json }
12
+
13
+ it 'should return the json body as a hash' do
14
+ subject.json.class.should eq Hash
15
+ subject.json[:key].should eq 'value'
16
+ end
17
+ end
18
+
19
+ describe "#ok?" do
20
+ context "200" do
21
+ it 'should return true if status is 200' do
22
+ subject.ok?.should be true
23
+ end
24
+ end
25
+
26
+ context "404" do
27
+ let(:status) { 404 }
28
+ it 'should return false if status is not 200' do
29
+ subject.ok?.should be false
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#dom" do
35
+ it 'should return with a Fragment' do
36
+ subject.dom.class.should eq DOM::Fragment
37
+ subject.dom.children[0].should_not be nil
38
+ end
39
+ end
40
+
41
+ describe '#content_type' do
42
+ it 'should return content type' do
43
+ subject.content_type.should eq 'application/json'
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,58 @@
1
+ require 'fron/storage'
2
+
3
+ describe Fron::Storage::LocalStorage do
4
+
5
+ subject { described_class }
6
+
7
+ before do
8
+ subject.clear
9
+ subject.set 'key', { data: 'value' }
10
+ end
11
+
12
+ describe "#get" do
13
+ it 'should get the data for the key' do
14
+ data = subject.get('key')
15
+ data.class.should eq Hash
16
+ data[:data].should eq 'value'
17
+ end
18
+ end
19
+
20
+ describe "#set" do
21
+ it 'should set data for the key' do
22
+ subject.set 'key2', { data: 'value' }
23
+ subject.keys.include?('key2').should be true
24
+ subject.all.length.should be 2
25
+ end
26
+ end
27
+
28
+ describe '#keys' do
29
+ it 'should return all the keys' do
30
+ subject.keys.include?('key').should be true
31
+ subject.all.length.should eq 1
32
+ end
33
+ end
34
+
35
+ describe '#remove' do
36
+ it 'should remove the key' do
37
+ subject.all.length.should eq 1
38
+ subject.remove 'key'
39
+ subject.all.length.should eq 0
40
+ end
41
+ end
42
+
43
+ describe "#all" do
44
+ it 'should get the data for all key' do
45
+ data = subject.all[0]
46
+ data.class.should eq Hash
47
+ data[:data].should eq 'value'
48
+ end
49
+ end
50
+
51
+ describe '#clear' do
52
+ it 'should remove all keys' do
53
+ subject.all.length.should eq 1
54
+ subject.clear
55
+ subject.all.length.should eq 0
56
+ end
57
+ end
58
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusztav Szikszai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-11 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -44,6 +44,11 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - .ruby-gemset
48
+ - .ruby-version
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - Rakefile
47
52
  - docs/application.md
48
53
  - docs/configuration.md
49
54
  - docs/controllers.md
@@ -54,7 +59,7 @@ files:
54
59
  - opal/fron.rb
55
60
  - opal/fron/core-ext/hash.rb
56
61
  - opal/fron/core.rb
57
- - opal/fron/core/adapters/local-storage.rb
62
+ - opal/fron/core/adapters/local.rb
58
63
  - opal/fron/core/adapters/rails.rb
59
64
  - opal/fron/core/application.rb
60
65
  - opal/fron/core/component.rb
@@ -73,6 +78,7 @@ files:
73
78
  - opal/fron/dom/modules/dimensions.rb
74
79
  - opal/fron/dom/modules/events.rb
75
80
  - opal/fron/dom/node.rb
81
+ - opal/fron/dom/nodelist.rb
76
82
  - opal/fron/dom/style.rb
77
83
  - opal/fron/dom/text.rb
78
84
  - opal/fron/dom/window.rb
@@ -81,6 +87,32 @@ files:
81
87
  - opal/fron/request/response.rb
82
88
  - opal/fron/storage.rb
83
89
  - opal/fron/storage/local-storage.rb
90
+ - spec/core-ext/hash_spec.rb
91
+ - spec/core/adapter/local_spec.rb
92
+ - spec/core/adapter/rails_spec.rb
93
+ - spec/core/application_spec.rb
94
+ - spec/core/component_spec.rb
95
+ - spec/core/configuration_spec.rb
96
+ - spec/core/controlller_spec.rb
97
+ - spec/core/eventable_spec.rb
98
+ - spec/core/logger_spec.rb
99
+ - spec/core/model_spec.rb
100
+ - spec/core/router_spec.rb
101
+ - spec/dom/document_spec.rb
102
+ - spec/dom/element_spec.rb
103
+ - spec/dom/event_spec.rb
104
+ - spec/dom/fragment_spec.rb
105
+ - spec/dom/modules/classlist_spec.rb
106
+ - spec/dom/modules/dimensions_spec.rb
107
+ - spec/dom/modules/events_spec.rb
108
+ - spec/dom/node_spec.rb
109
+ - spec/dom/nodelist_spec.rb
110
+ - spec/dom/style_spec.rb
111
+ - spec/dom/text_spec.rb
112
+ - spec/dom/window_spec.rb
113
+ - spec/request/request_spec.rb
114
+ - spec/request/response_spec.rb
115
+ - spec/storage/local-storage_spec.rb
84
116
  homepage: ''
85
117
  licenses: []
86
118
  metadata: {}
@@ -100,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
132
  version: '0'
101
133
  requirements: []
102
134
  rubyforge_project:
103
- rubygems_version: 2.1.11
135
+ rubygems_version: 2.1.9
104
136
  signing_key:
105
137
  specification_version: 4
106
138
  summary: Frontend Application Framework