fron 0.1.4 → 0.2.0rc1

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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.reek +11 -0
  4. data/.rubocop.yml +54 -0
  5. data/.travis.yml +11 -0
  6. data/.yardopts +4 -0
  7. data/Changelog.md +7 -0
  8. data/Gemfile +3 -1
  9. data/Gemfile.lock +106 -15
  10. data/Rakefile +19 -15
  11. data/Readme.md +23 -0
  12. data/fron.gemspec +2 -2
  13. data/lib/fron/version.rb +2 -1
  14. data/opal/fron.rb +5 -5
  15. data/opal/fron/core.rb +3 -10
  16. data/opal/fron/core/behaviors/components.rb +42 -0
  17. data/opal/fron/core/behaviors/events.rb +27 -0
  18. data/opal/fron/core/behaviors/routes.rb +59 -0
  19. data/opal/fron/core/component.rb +64 -90
  20. data/opal/fron/core/eventable.rb +18 -0
  21. data/opal/fron/core/logger.rb +10 -1
  22. data/opal/fron/core_ext.rb +9 -0
  23. data/opal/fron/core_ext/array.rb +12 -0
  24. data/opal/fron/core_ext/date.rb +57 -0
  25. data/opal/fron/core_ext/hash.rb +52 -0
  26. data/opal/fron/core_ext/kernel.rb +57 -0
  27. data/opal/fron/core_ext/nil.rb +7 -0
  28. data/opal/fron/core_ext/numeric.rb +19 -0
  29. data/opal/fron/core_ext/object.rb +11 -0
  30. data/opal/fron/core_ext/proc.rb +19 -0
  31. data/opal/fron/{core-ext → core_ext}/string.rb +4 -0
  32. data/opal/fron/dom.rb +15 -13
  33. data/opal/fron/dom/document.rb +22 -6
  34. data/opal/fron/dom/element.rb +105 -67
  35. data/opal/fron/dom/event.rb +110 -40
  36. data/opal/fron/dom/{file-reader.rb → file_reader.rb} +6 -1
  37. data/opal/fron/dom/fragment.rb +2 -0
  38. data/opal/fron/dom/modules/attributes.rb +43 -0
  39. data/opal/fron/dom/modules/classlist.rb +26 -13
  40. data/opal/fron/dom/modules/dimensions.rb +79 -9
  41. data/opal/fron/dom/modules/element_accessor.rb +35 -0
  42. data/opal/fron/dom/modules/events.rb +67 -20
  43. data/opal/fron/dom/node.rb +98 -39
  44. data/opal/fron/dom/nodelist.rb +9 -2
  45. data/opal/fron/dom/style.rb +23 -2
  46. data/opal/fron/dom/text.rb +4 -0
  47. data/opal/fron/dom/window.rb +31 -2
  48. data/opal/fron/event_mock.rb +54 -0
  49. data/opal/fron/js/syntetic_event.js +16 -0
  50. data/opal/fron/request.rb +2 -2
  51. data/opal/fron/request/request.rb +77 -14
  52. data/opal/fron/request/response.rb +33 -6
  53. data/opal/fron/storage.rb +1 -1
  54. data/opal/fron/storage/local_storage.rb +54 -0
  55. data/opal/fron/utils/drag.rb +135 -0
  56. data/opal/fron/utils/keyboard.rb +70 -0
  57. data/opal/fron/utils/point.rb +78 -0
  58. data/opal/fron/utils/render_proc.rb +27 -0
  59. data/spec/core-ext/array_spec.rb +15 -0
  60. data/spec/core-ext/date_spec.rb +54 -0
  61. data/spec/core-ext/hash_spec.rb +18 -2
  62. data/spec/core-ext/kernel_spec.rb +57 -0
  63. data/spec/core-ext/nil_spec.rb +9 -0
  64. data/spec/core-ext/numeric_spec.rb +25 -0
  65. data/spec/core-ext/proc_spec.rb +15 -0
  66. data/spec/core-ext/string_spec.rb +11 -0
  67. data/spec/core/behaviors/events_spec.rb +25 -0
  68. data/spec/core/behaviors/routes_spec.rb +59 -0
  69. data/spec/core/component_inheritance_spec.rb +26 -16
  70. data/spec/core/component_spec.rb +25 -29
  71. data/spec/core/eventable_spec.rb +19 -19
  72. data/spec/core/logger_spec.rb +5 -6
  73. data/spec/dom/document_spec.rb +4 -5
  74. data/spec/dom/element_spec.rb +106 -15
  75. data/spec/dom/event_spec.rb +101 -61
  76. data/spec/dom/file_reader_spec.rb +11 -0
  77. data/spec/dom/fragment_spec.rb +3 -4
  78. data/spec/dom/instance_retaining_spec.rb +58 -0
  79. data/spec/dom/modules/classlist_spec.rb +18 -19
  80. data/spec/dom/modules/dimensions_spec.rb +87 -22
  81. data/spec/dom/modules/events_spec.rb +22 -8
  82. data/spec/dom/node_spec.rb +25 -17
  83. data/spec/dom/nodelist_spec.rb +2 -3
  84. data/spec/dom/style_spec.rb +6 -5
  85. data/spec/dom/text_spec.rb +4 -3
  86. data/spec/dom/window_spec.rb +24 -9
  87. data/spec/js/mocks.js +14 -0
  88. data/spec/request/request_spec.rb +34 -15
  89. data/spec/request/response_spec.rb +9 -10
  90. data/spec/spec_helper.rb +11 -0
  91. data/spec/storage/{local-storage_spec.rb → local_storage_spec.rb} +6 -7
  92. data/spec/utils/drag_spec.rb +136 -0
  93. data/spec/utils/keyboard_spec.rb +75 -0
  94. data/spec/utils/point_spec.rb +55 -0
  95. data/spec/utils/render_proc_spec.rb +18 -0
  96. metadata +58 -36
  97. data/docs/application.md +0 -7
  98. data/docs/configuration.md +0 -29
  99. data/docs/controllers.md +0 -35
  100. data/docs/routing.md +0 -63
  101. data/opal/fron/core-ext.rb +0 -5
  102. data/opal/fron/core-ext/hash.rb +0 -31
  103. data/opal/fron/core-ext/kernel.rb +0 -10
  104. data/opal/fron/core-ext/numeric.rb +0 -9
  105. data/opal/fron/core-ext/proc.rb +0 -9
  106. data/opal/fron/core/adapters/local.rb +0 -43
  107. data/opal/fron/core/adapters/rails.rb +0 -65
  108. data/opal/fron/core/application.rb +0 -42
  109. data/opal/fron/core/configuration.rb +0 -29
  110. data/opal/fron/core/controller.rb +0 -41
  111. data/opal/fron/core/model.rb +0 -90
  112. data/opal/fron/core/router.rb +0 -86
  113. data/opal/fron/storage/local-storage.rb +0 -34
  114. data/spec/core/adapter/local_spec.rb +0 -65
  115. data/spec/core/adapter/rails_spec.rb +0 -77
  116. data/spec/core/application_spec.rb +0 -35
  117. data/spec/core/configuration_spec.rb +0 -20
  118. data/spec/core/controlller_spec.rb +0 -68
  119. data/spec/core/model_spec.rb +0 -125
  120. data/spec/core/router_spec.rb +0 -124
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'fron/utils/point'
3
+
4
+ describe Fron::Point do
5
+ let(:other) { described_class.new 20, 20 }
6
+ subject { described_class.new 10, 10 }
7
+
8
+ describe '#-' do
9
+ it 'should return the difference' do
10
+ diff = subject - other
11
+ diff.should be_a described_class
12
+ diff.x.should eq(-10)
13
+ diff.y.should eq(-10)
14
+ end
15
+ end
16
+
17
+ describe '#+' do
18
+ it 'should return the addition' do
19
+ diff = subject + other
20
+ diff.should be_a described_class
21
+ diff.x.should eq(30)
22
+ diff.y.should eq(30)
23
+ end
24
+ end
25
+
26
+ describe '#*' do
27
+ it 'should multipy by scalar' do
28
+ diff = subject * 2
29
+ diff.should be_a described_class
30
+ diff.x.should eq(20)
31
+ diff.y.should eq(20)
32
+ end
33
+ end
34
+
35
+ describe '#/' do
36
+ it 'should devide by scalar' do
37
+ diff = subject / 2
38
+ diff.should be_a described_class
39
+ diff.x.should eq(5)
40
+ diff.y.should eq(5)
41
+ end
42
+ end
43
+
44
+ describe '#distance' do
45
+ it 'should return the distance' do
46
+ subject.distance.round(2).should eq 14.14
47
+ end
48
+ end
49
+
50
+ describe '#to_s' do
51
+ it 'should return string representation' do
52
+ subject.to_s.should eq '[10, 10]'
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'fron/utils/render_proc'
3
+
4
+ describe Fron::RenderProc do
5
+ let(:method) { proc {} }
6
+ let(:logger) { double }
7
+
8
+ subject { described_class.new method, true }
9
+
10
+ it 'should call the method' do
11
+ subject.should receive(:logger).and_return logger
12
+ logger.should receive(:info)
13
+ method.should receive(:owner).and_return 'test'
14
+ method.should receive(:call)
15
+ subject.should receive(:request_animation_frame).and_yield
16
+ subject.call
17
+ end
18
+ 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.4
4
+ version: 0.2.0rc1
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-06-25 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -16,99 +16,114 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.2
19
+ version: 0.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.2
26
+ version: 0.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.0.beta3
33
+ version: 0.4.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.0.beta3
40
+ version: 0.4.0
41
41
  description: Frontend Application Framework that uses Opal
42
42
  email: gusztav.szikszai@digitalnatives.hu
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - .gitignore
48
+ - .reek
49
+ - .rubocop.yml
47
50
  - .ruby-gemset
48
51
  - .ruby-version
52
+ - .travis.yml
53
+ - .yardopts
54
+ - Changelog.md
49
55
  - Gemfile
50
56
  - Gemfile.lock
51
57
  - Rakefile
52
- - docs/application.md
53
- - docs/configuration.md
54
- - docs/controllers.md
55
- - docs/routing.md
58
+ - Readme.md
56
59
  - fron.gemspec
57
60
  - lib/fron.rb
58
61
  - lib/fron/version.rb
59
62
  - opal/fron.rb
60
- - opal/fron/core-ext.rb
61
- - opal/fron/core-ext/hash.rb
62
- - opal/fron/core-ext/kernel.rb
63
- - opal/fron/core-ext/numeric.rb
64
- - opal/fron/core-ext/proc.rb
65
- - opal/fron/core-ext/string.rb
66
63
  - opal/fron/core.rb
67
- - opal/fron/core/adapters/local.rb
68
- - opal/fron/core/adapters/rails.rb
69
- - opal/fron/core/application.rb
64
+ - opal/fron/core/behaviors/components.rb
65
+ - opal/fron/core/behaviors/events.rb
66
+ - opal/fron/core/behaviors/routes.rb
70
67
  - opal/fron/core/component.rb
71
- - opal/fron/core/configuration.rb
72
- - opal/fron/core/controller.rb
73
68
  - opal/fron/core/eventable.rb
74
69
  - opal/fron/core/logger.rb
75
- - opal/fron/core/model.rb
76
- - opal/fron/core/router.rb
70
+ - opal/fron/core_ext.rb
71
+ - opal/fron/core_ext/array.rb
72
+ - opal/fron/core_ext/date.rb
73
+ - opal/fron/core_ext/hash.rb
74
+ - opal/fron/core_ext/kernel.rb
75
+ - opal/fron/core_ext/nil.rb
76
+ - opal/fron/core_ext/numeric.rb
77
+ - opal/fron/core_ext/object.rb
78
+ - opal/fron/core_ext/proc.rb
79
+ - opal/fron/core_ext/string.rb
77
80
  - opal/fron/dom.rb
78
81
  - opal/fron/dom/document.rb
79
82
  - opal/fron/dom/element.rb
80
83
  - opal/fron/dom/event.rb
81
- - opal/fron/dom/file-reader.rb
84
+ - opal/fron/dom/file_reader.rb
82
85
  - opal/fron/dom/fragment.rb
86
+ - opal/fron/dom/modules/attributes.rb
83
87
  - opal/fron/dom/modules/classlist.rb
84
88
  - opal/fron/dom/modules/dimensions.rb
89
+ - opal/fron/dom/modules/element_accessor.rb
85
90
  - opal/fron/dom/modules/events.rb
86
91
  - opal/fron/dom/node.rb
87
92
  - opal/fron/dom/nodelist.rb
88
93
  - opal/fron/dom/style.rb
89
94
  - opal/fron/dom/text.rb
90
95
  - opal/fron/dom/window.rb
96
+ - opal/fron/event_mock.rb
97
+ - opal/fron/js/syntetic_event.js
91
98
  - opal/fron/request.rb
92
99
  - opal/fron/request/request.rb
93
100
  - opal/fron/request/response.rb
94
101
  - opal/fron/storage.rb
95
- - opal/fron/storage/local-storage.rb
102
+ - opal/fron/storage/local_storage.rb
103
+ - opal/fron/utils/drag.rb
104
+ - opal/fron/utils/keyboard.rb
105
+ - opal/fron/utils/point.rb
106
+ - opal/fron/utils/render_proc.rb
107
+ - spec/core-ext/array_spec.rb
108
+ - spec/core-ext/date_spec.rb
96
109
  - spec/core-ext/hash_spec.rb
97
- - spec/core/adapter/local_spec.rb
98
- - spec/core/adapter/rails_spec.rb
99
- - spec/core/application_spec.rb
110
+ - spec/core-ext/kernel_spec.rb
111
+ - spec/core-ext/nil_spec.rb
112
+ - spec/core-ext/numeric_spec.rb
113
+ - spec/core-ext/proc_spec.rb
114
+ - spec/core-ext/string_spec.rb
115
+ - spec/core/behaviors/events_spec.rb
116
+ - spec/core/behaviors/routes_spec.rb
100
117
  - spec/core/component_inheritance_spec.rb
101
118
  - spec/core/component_spec.rb
102
- - spec/core/configuration_spec.rb
103
- - spec/core/controlller_spec.rb
104
119
  - spec/core/eventable_spec.rb
105
120
  - spec/core/logger_spec.rb
106
- - spec/core/model_spec.rb
107
- - spec/core/router_spec.rb
108
121
  - spec/dom/document_spec.rb
109
122
  - spec/dom/element_spec.rb
110
123
  - spec/dom/event_spec.rb
124
+ - spec/dom/file_reader_spec.rb
111
125
  - spec/dom/fragment_spec.rb
126
+ - spec/dom/instance_retaining_spec.rb
112
127
  - spec/dom/modules/classlist_spec.rb
113
128
  - spec/dom/modules/dimensions_spec.rb
114
129
  - spec/dom/modules/events_spec.rb
@@ -117,9 +132,15 @@ files:
117
132
  - spec/dom/style_spec.rb
118
133
  - spec/dom/text_spec.rb
119
134
  - spec/dom/window_spec.rb
135
+ - spec/js/mocks.js
120
136
  - spec/request/request_spec.rb
121
137
  - spec/request/response_spec.rb
122
- - spec/storage/local-storage_spec.rb
138
+ - spec/spec_helper.rb
139
+ - spec/storage/local_storage_spec.rb
140
+ - spec/utils/drag_spec.rb
141
+ - spec/utils/keyboard_spec.rb
142
+ - spec/utils/point_spec.rb
143
+ - spec/utils/render_proc_spec.rb
123
144
  homepage: ''
124
145
  licenses: []
125
146
  metadata: {}
@@ -134,13 +155,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
155
  version: '0'
135
156
  required_rubygems_version: !ruby/object:Gem::Requirement
136
157
  requirements:
137
- - - '>='
158
+ - - '>'
138
159
  - !ruby/object:Gem::Version
139
- version: '0'
160
+ version: 1.3.1
140
161
  requirements: []
141
162
  rubyforge_project:
142
- rubygems_version: 2.1.9
163
+ rubygems_version: 2.2.2
143
164
  signing_key:
144
165
  specification_version: 4
145
166
  summary: Frontend Application Framework
146
167
  test_files: []
168
+ has_rdoc:
@@ -1,7 +0,0 @@
1
- # Application
2
-
3
- * [Configuration]()
4
- * [Controllers]()
5
- * [Routers]()
6
- * [Components]()
7
- * [DOM]()
@@ -1,29 +0,0 @@
1
- # Configuration
2
- Application configuration utility.
3
-
4
- ## Title
5
- The layout of the application can be set with the 'title' DSL.
6
-
7
- ## Layout
8
- The layout of the application can be set with the 'layout' DSL.
9
-
10
- This DSL takes a block and runs it in the context of the main application component, with the injection poin for controllers as the argument.
11
-
12
- ## Routes
13
- For using routes see the [routing documentation]().
14
-
15
- ## Example
16
- ```ruby
17
- class TestApplication < Application
18
- config.title = 'Test Application'
19
-
20
- config.layout do |main|
21
- component :header, 'header'
22
- self << main
23
- end
24
-
25
- config.routes do
26
- map SiteController
27
- end
28
- end
29
- ```
@@ -1,35 +0,0 @@
1
- # Controllers
2
- Controllers are responsible for parts of the application, it handles state / view changes for itself only.
3
-
4
- ## Base Component
5
- The base component can be specified with the `base` DSL method.
6
-
7
- The base component is the "page" wthich is injected into the document when a route matches this controller. It is accessible with the `@base` attribute. It must be a subclass of `Component`.
8
-
9
- ## Global Events
10
- A controller can listen on Global Events with the `on` DSL.
11
-
12
- The first argument is the event to listen to and the second argument is the method to run when the event triggered. Globa Events can be trigger like so:
13
- ```ruby
14
- Eventable.trigger 'load'
15
- ```
16
-
17
- ## Routes
18
- For using routes see the [routing documentation]().
19
-
20
- ## Example
21
- ```ruby
22
- class TestController < Controller
23
- base BaseComponent
24
-
25
- on :load, :loaded
26
-
27
- def loaded
28
-
29
- end
30
-
31
- def test
32
- puts @base
33
- end
34
- end
35
- ```
@@ -1,63 +0,0 @@
1
- # Routing
2
- There are two leves of routing:
3
-
4
- * Application level: This defines which controller is responsibe for specified paths
5
- * Controller level: This defines which actions / sub controllers on the controller are called for specified paths
6
-
7
- ## Applications Routes
8
- Routes are defined in the Application Configuration with the `routes` DSL method.
9
-
10
- You can define controllers for specific paths, for example the following `map 'users/', UserController` will delegate all paths under the `users/` to the `UserController`. The controller only recieves the portion of the path which remains after the matched path.
11
-
12
- ## Controller Routes
13
- Routes are defined with the `route` DSL method.
14
-
15
- The first argument is the path, the second argument is the action / sub controller to be called. The path can contain parameter identifiers such as `:name`. These will be passed along to the action as a hash in the first parameter.
16
-
17
- ## Before Filters
18
- Before filters can be added to the controllers actions with the `beforeFilter` DSL method.
19
-
20
- The first argument is the action to be called, the second argument is an array of methods which before the action should be called.
21
-
22
- ## Example
23
- ```ruby
24
- class TestApplication < Application
25
- config.routes do
26
- # Both 'users/new' and 'users/10' will be
27
- # handled by an instance of UserController
28
- map 'users/', UserController
29
-
30
- # Anything else will be handled by
31
- # an instance of IndexController
32
- map IndexController
33
- end
34
- end
35
-
36
- class CommentsController < Controller
37
- ...
38
- end
39
-
40
- class UserController < Controller
41
- # users/new -> UserController#authorize -> UserController#new
42
- route 'new', :new
43
- # users/10/comments -> CommentsController with params[:id] = 10
44
- route ':id/comments/', CommentsController
45
- # users/10 -> UserController#authorize -> USerController#user with params[:id] = 10
46
- route ':id', :user
47
-
48
- beforeFilter :authorize, [:new,:user]
49
-
50
- def new
51
- ...
52
- end
53
-
54
- def user(params)
55
- puts params[:id]
56
- ...
57
- end
58
-
59
- def authorize
60
- ...
61
- end
62
- end
63
- ```
@@ -1,5 +0,0 @@
1
- require './core-ext/hash'
2
- require './core-ext/kernel'
3
- require './core-ext/numeric'
4
- require './core-ext/proc'
5
- require './core-ext/string'
@@ -1,31 +0,0 @@
1
- class Hash
2
- def to_query_string
3
- r = []
4
- each do |key,value|
5
- r << `encodeURIComponent(#{key})+"="+encodeURIComponent(#{value})`
6
- end
7
- r.join "&"
8
- end
9
-
10
- def to_form_data
11
- r = `new FormData()`
12
- each do |key,value|
13
- `r.append(#{key},#{value})`
14
- end
15
- r
16
- end
17
-
18
- def deepDiff(b)
19
- a = self
20
- (a.keys + b.keys).uniq.inject({}) do |diff, k|
21
- if a[k] != b[k]
22
- if a[k].respond_to?(:deepDiff) && b[k].respond_to?(:deepDiff)
23
- diff[k] = a[k].deepDiff(b[k])
24
- else
25
- diff[k] = [a[k], b[k]]
26
- end
27
- end
28
- diff
29
- end
30
- end
31
- end