fron 0.2.0rc1 → 1.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +20 -0
  3. data/.reek +2 -0
  4. data/.rubocop.yml +14 -11
  5. data/Gemfile +6 -3
  6. data/Gemfile.lock +73 -86
  7. data/Rakefile +11 -15
  8. data/Readme.md +1 -1
  9. data/fron.gemspec +2 -2
  10. data/lib/fron/version.rb +1 -1
  11. data/opal/fron.rb +2 -0
  12. data/opal/fron/core.rb +1 -0
  13. data/opal/fron/core/behaviors/components.rb +18 -10
  14. data/opal/fron/core/behaviors/events.rb +9 -10
  15. data/opal/fron/core/behaviors/routes.rb +6 -10
  16. data/opal/fron/core/behaviors/style.rb +30 -0
  17. data/opal/fron/core/component.rb +44 -23
  18. data/opal/fron/core/eventable.rb +3 -3
  19. data/opal/fron/core/logger.rb +1 -1
  20. data/opal/fron/core/sheet.rb +140 -0
  21. data/opal/fron/core_ext.rb +1 -0
  22. data/opal/fron/core_ext/array.rb +23 -0
  23. data/opal/fron/core_ext/hash.rb +6 -6
  24. data/opal/fron/core_ext/kernel.rb +10 -1
  25. data/opal/fron/core_ext/numeric.rb +7 -0
  26. data/opal/fron/core_ext/time.rb +6 -0
  27. data/opal/fron/dom/document.rb +6 -3
  28. data/opal/fron/dom/element.rb +79 -19
  29. data/opal/fron/dom/event.rb +5 -1
  30. data/opal/fron/dom/modules/dimensions.rb +0 -14
  31. data/opal/fron/dom/modules/element_accessor.rb +25 -0
  32. data/opal/fron/dom/modules/events.rb +1 -1
  33. data/opal/fron/dom/node.rb +7 -5
  34. data/opal/fron/dom/style.rb +0 -2
  35. data/opal/fron/dom/window.rb +14 -0
  36. data/opal/fron/event_mock.rb +24 -6
  37. data/opal/fron/js/scroll_into_view_if_needed.js +27 -0
  38. data/opal/fron/js/syntetic_event.js +20 -13
  39. data/opal/fron/request/request.rb +21 -19
  40. data/opal/fron/request/response.rb +1 -1
  41. data/opal/fron/storage.rb +2 -0
  42. data/opal/fron/storage/local_storage.rb +3 -45
  43. data/opal/fron/storage/session_storage.rb +12 -0
  44. data/opal/fron/storage/store.rb +54 -0
  45. data/opal/fron/utils/drag.rb +21 -18
  46. data/opal/fron/utils/keyboard.rb +14 -12
  47. data/opal/fron/utils/point.rb +12 -4
  48. data/opal/fron/utils/render_proc.rb +6 -2
  49. data/spec/core-ext/array_spec.rb +10 -2
  50. data/spec/core-ext/numeric_spec.rb +6 -0
  51. data/spec/core/behaviors/style_spec.rb +51 -0
  52. data/spec/core/component_inheritance_spec.rb +10 -15
  53. data/spec/core/component_spec.rb +10 -15
  54. data/spec/dom/element_spec.rb +12 -1
  55. data/spec/dom/modules/classlist_spec.rb +8 -9
  56. data/spec/dom/modules/dimensions_spec.rb +2 -1
  57. data/spec/dom/modules/events_spec.rb +42 -31
  58. data/spec/dom/style_spec.rb +1 -1
  59. data/spec/spec_helper.rb +0 -1
  60. data/spec/utils/drag_spec.rb +2 -2
  61. data/spec/utils/keyboard_spec.rb +4 -1
  62. data/website/application.rb +4 -0
  63. data/website/config.ru +30 -0
  64. data/website/examples/content_editable.rb +29 -0
  65. data/website/examples/converter.rb +49 -0
  66. data/website/examples/icon_button.rb +20 -0
  67. data/website/examples/image_paragraph.rb +33 -0
  68. data/website/examples/my_blue_box.rb +9 -0
  69. data/website/examples/my_box.rb +9 -0
  70. data/website/examples/my_button.rb +27 -0
  71. data/website/examples/my_green_box.rb +14 -0
  72. data/website/examples/source_reader.rb +32 -0
  73. data/website/examples/text_area.rb +42 -0
  74. data/website/pages/components.md.erb +16 -0
  75. data/website/pages/components/composition.md.erb +9 -0
  76. data/website/pages/components/events.md.erb +20 -0
  77. data/website/pages/components/inheritance.md.erb +19 -0
  78. data/website/pages/components/routes.md.erb +49 -0
  79. data/website/pages/components/styles.md.erb +38 -0
  80. data/website/pages/getting-started.md +8 -0
  81. data/website/pages/home.md +4 -0
  82. data/website/pages/intro.md +30 -0
  83. data/website/pages/utilities.md +10 -0
  84. data/website/pages/utilities/local-storage.md.erb +16 -0
  85. data/website/pages/utilities/request.md.erb +12 -0
  86. data/website/setup.rb +162 -0
  87. data/website/vendor/highlight.js +2 -0
  88. data/website/vendor/highlight.ruby.js +1 -0
  89. data/website/vendor/marked.min.js +6 -0
  90. metadata +43 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a846e18a8992b019b87619c1bdafb965f975400
4
- data.tar.gz: bc56889e6594d08b74da58eab1a29f58ff4f0c5f
3
+ metadata.gz: fea15f954eea89cbb3a7de95982f0c56d3ce08cb
4
+ data.tar.gz: 5982c400ad8af29790fc5e959220f58e76bb5716
5
5
  SHA512:
6
- metadata.gz: 5d5cb8d2303030c60a2cf97b3fa7f8a838e9213b3c533b9ee0502319ce06a5457710843acb7ebca9fac3c30c59f1c967bf2b4b3c2acaba1dd0e6bcc8dc993cd6
7
- data.tar.gz: cf6d819951e9062584dc879c9f864bf6798acd19deafe23f043ec9b02a54e1fd1397d3cecb6f0f2f450b5cd5d2cd6c5b84898078bf5e5263bd7b45fe1660eb4a
6
+ metadata.gz: 7dda415778e26d1496e7e2536abe5b44bfee8a14f7a592bfc3079f60f420ed0533a76f1d0af84e8518d9a8dcfa8c21cd61493702650d90b0aa16841c3b855cc2
7
+ data.tar.gz: 2976245603309abc5b25ac6dc0af3d41f2f1eac9c9bc1c8335a97e59883142d0d86a5ad0c5eed8c636c1db6df27ba4da07be642bad0f402a6b8ebad369aa3316
@@ -0,0 +1,20 @@
1
+ ---
2
+ engines:
3
+ bundler-audit:
4
+ enabled: true
5
+ duplication:
6
+ enabled: true
7
+ config:
8
+ languages:
9
+ - ruby
10
+ fixme:
11
+ enabled: true
12
+ rubocop:
13
+ enabled: true
14
+ ratings:
15
+ paths:
16
+ - Gemfile.lock
17
+ - "**.rb"
18
+ exclude_paths:
19
+ - website/
20
+ - spec/
data/.reek CHANGED
@@ -1,4 +1,6 @@
1
1
  ---
2
+ DuplicateMethodCall:
3
+ max_calls: 3
2
4
  ControlParameter:
3
5
  enabled: false
4
6
  BooleanParameter:
@@ -1,6 +1,6 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - vendor/**/*
3
+ - website/**/*
4
4
 
5
5
  VariableName:
6
6
  EnforcedStyle: snake_case
@@ -11,10 +11,7 @@ MethodName:
11
11
  HandleExceptions:
12
12
  Enabled: false
13
13
 
14
- Blocks:
15
- Enabled: true
16
-
17
- SingleSpaceBeforeFirstArg:
14
+ SpaceBeforeFirstArg:
18
15
  Enabled: false
19
16
 
20
17
  LineLength:
@@ -23,18 +20,12 @@ LineLength:
23
20
  MethodLength:
24
21
  Enabled: false
25
22
 
26
- Blocks:
27
- Enabled: false
28
-
29
23
  TrivialAccessors:
30
24
  Enabled: false
31
25
 
32
26
  ClassLength:
33
27
  Enabled: false
34
28
 
35
- UnneededPercentX:
36
- Enabled: false
37
-
38
29
  CyclomaticComplexity:
39
30
  Enabled: false
40
31
 
@@ -52,3 +43,15 @@ EmptyElse:
52
43
 
53
44
  PredicateName:
54
45
  Enabled: false
46
+
47
+ BlockDelimiters:
48
+ Enabled: false
49
+
50
+ CommandLiteral:
51
+ Enabled: false
52
+
53
+ LiteralInCondition:
54
+ Enabled: false
55
+
56
+ MutableConstant:
57
+ Enabled: false
data/Gemfile CHANGED
@@ -1,6 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- gem 'rake'
5
- gem 'quality_control', github: 'gdotdesign/quality-control', ref: 'next'
6
- gem 'execjs'
4
+ gem 'rake', '~> 11.1'
5
+ gem 'execjs', '~> 2.6'
6
+ gem 'rubocop', '~> 0.39.0'
7
+ gem 'rubycritic', '~> 2.8'
8
+ gem 'yard', '~> 0.8.7.6'
9
+ gem 'activesupport', '~> 4.2'
@@ -1,113 +1,94 @@
1
- GIT
2
- remote: git://github.com/gdotdesign/quality-control.git
3
- revision: 1035bd82c6df8882d831060a2c7a4f89416b18ed
4
- ref: next
5
- specs:
6
- quality_control (0.1.2)
7
- colorize (~> 0.7.3)
8
- opal-rspec
9
- rake
10
- rubocop
11
- rubycritic
12
- scss-lint
13
- yard
14
-
15
1
  PATH
16
2
  remote: .
17
3
  specs:
18
- fron (0.2.0rc1)
19
- opal (~> 0.7.0)
4
+ fron (1.0.0rc1)
5
+ opal (~> 0.9.2)
20
6
 
21
7
  GEM
22
8
  remote: https://rubygems.org/
23
9
  specs:
24
- abstract_type (0.0.7)
25
- adamantium (0.2.0)
26
- ice_nine (~> 0.11.0)
27
- memoizable (~> 0.4.0)
28
- ast (2.0.0)
29
- astrolabe (1.3.0)
30
- parser (>= 2.2.0.pre.3, < 3.0)
10
+ activesupport (4.2.6)
11
+ i18n (~> 0.7)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.3, >= 0.3.4)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.4.0)
17
+ ast (2.2.0)
31
18
  axiom-types (0.1.1)
32
19
  descendants_tracker (~> 0.0.4)
33
20
  ice_nine (~> 0.11.0)
34
21
  thread_safe (~> 0.3, >= 0.3.1)
22
+ codeclimate-engine-rb (0.3.1)
23
+ virtus (~> 1.0)
35
24
  coercible (1.0.0)
36
25
  descendants_tracker (~> 0.0.1)
37
- colorize (0.7.5)
38
- concord (0.1.5)
39
- adamantium (~> 0.2.0)
40
- equalizer (~> 0.0.9)
26
+ colorize (0.7.7)
27
+ concurrent-ruby (1.0.1)
41
28
  descendants_tracker (0.0.4)
42
29
  thread_safe (~> 0.3, >= 0.3.1)
43
- diff-lcs (1.2.5)
44
- equalizer (0.0.10)
45
- execjs (2.4.0)
46
- flay (2.4.0)
30
+ equalizer (0.0.11)
31
+ erubis (2.7.0)
32
+ execjs (2.6.0)
33
+ flay (2.7.0)
34
+ erubis (~> 2.7.0)
47
35
  ruby_parser (~> 3.0)
48
36
  sexp_processor (~> 4.0)
49
- flog (4.2.1)
37
+ flog (4.3.2)
50
38
  ruby_parser (~> 3.1, > 3.1.0)
51
39
  sexp_processor (~> 4.4)
52
40
  hike (1.2.3)
53
- ice_nine (0.11.1)
54
- memoizable (0.4.2)
55
- thread_safe (~> 0.3, >= 0.3.1)
56
- multi_json (1.11.0)
57
- opal (0.7.1)
41
+ i18n (0.7.0)
42
+ ice_nine (0.11.2)
43
+ json (1.8.3)
44
+ launchy (2.4.3)
45
+ addressable (~> 2.3)
46
+ minitest (5.8.4)
47
+ opal (0.9.2)
58
48
  hike (~> 1.2)
59
49
  sourcemap (~> 0.1.0)
60
- sprockets (>= 2.2.3, < 4.0.0)
61
- tilt (~> 1.4)
62
- opal-rspec (0.4.1)
63
- opal (~> 0.7.0)
64
- parser (2.2.0.3)
65
- ast (>= 1.1, < 3.0)
66
- powerpack (0.1.0)
67
- procto (0.0.2)
68
- rack (1.6.0)
69
- rainbow (2.0.0)
70
- rake (10.4.2)
71
- reek (1.6.5)
72
- parser (~> 2.2.0.pre.7)
73
- rainbow (>= 1.99, < 3.0)
74
- unparser (~> 0.2.2)
75
- rubocop (0.29.1)
76
- astrolabe (~> 1.3)
77
- parser (>= 2.2.0.1, < 3.0)
50
+ sprockets (~> 3.1)
51
+ tilt (>= 1.4)
52
+ opal-rspec (0.5.0)
53
+ opal (>= 0.8.0, < 0.10)
54
+ parser (2.3.0.7)
55
+ ast (~> 2.2)
56
+ powerpack (0.1.1)
57
+ rack (1.6.4)
58
+ rainbow (2.1.0)
59
+ rake (11.1.2)
60
+ reek (3.11)
61
+ codeclimate-engine-rb (~> 0.3.1)
62
+ parser (~> 2.3, >= 2.3.0.6)
63
+ rainbow (~> 2.0)
64
+ rubocop (0.39.0)
65
+ parser (>= 2.3.0.7, < 3.0)
78
66
  powerpack (~> 0.1)
79
67
  rainbow (>= 1.99.1, < 3.0)
80
- ruby-progressbar (~> 1.4)
81
- ruby-progressbar (1.7.1)
82
- ruby_parser (3.6.5)
68
+ ruby-progressbar (~> 1.7)
69
+ unicode-display_width (~> 1.0, >= 1.0.1)
70
+ ruby-progressbar (1.7.5)
71
+ ruby_parser (3.8.1)
83
72
  sexp_processor (~> 4.1)
84
- rubycritic (1.4.0)
85
- flay (= 2.4.0)
86
- flog (= 4.2.1)
87
- parser (>= 2.2.0, < 3.0)
88
- reek (= 1.6.5)
73
+ rubycritic (2.8.0)
74
+ colorize
75
+ flay (= 2.7.0)
76
+ flog (= 4.3.2)
77
+ launchy (= 2.4.3)
78
+ parser (~> 2.3)
79
+ reek (= 3.11)
80
+ ruby_parser (~> 3.8)
89
81
  virtus (~> 1.0)
90
- sass (3.4.13)
91
- scss-lint (0.35.0)
92
- rainbow (~> 2.0)
93
- sass (~> 3.4.1)
94
- sexp_processor (4.5.0)
82
+ sexp_processor (4.7.0)
95
83
  sourcemap (0.1.1)
96
- sprockets (2.12.3)
97
- hike (~> 1.2)
98
- multi_json (~> 1.0)
99
- rack (~> 1.0)
100
- tilt (~> 1.1, != 1.3.0)
84
+ sprockets (3.5.2)
85
+ concurrent-ruby (~> 1.0)
86
+ rack (> 1, < 3)
101
87
  thread_safe (0.3.5)
102
- tilt (1.4.1)
103
- unparser (0.2.2)
104
- abstract_type (~> 0.0.7)
105
- adamantium (~> 0.2.0)
106
- concord (~> 0.1.5)
107
- diff-lcs (~> 1.2.5)
108
- equalizer (~> 0.0.9)
109
- parser (~> 2.2.0.2)
110
- procto (~> 0.0.2)
88
+ tilt (2.0.2)
89
+ tzinfo (1.2.2)
90
+ thread_safe (~> 0.1)
91
+ unicode-display_width (1.0.3)
111
92
  virtus (1.0.5)
112
93
  axiom-types (~> 0.1)
113
94
  coercible (~> 1.0)
@@ -119,8 +100,14 @@ PLATFORMS
119
100
  ruby
120
101
 
121
102
  DEPENDENCIES
122
- execjs
103
+ activesupport (~> 4.2)
104
+ execjs (~> 2.6)
123
105
  fron!
124
- opal-rspec (~> 0.4.0)
125
- quality_control!
126
- rake
106
+ opal-rspec (~> 0.5.0)
107
+ rake (~> 11.1)
108
+ rubocop (~> 0.39.0)
109
+ rubycritic (~> 2.8)
110
+ yard (~> 0.8.7.6)
111
+
112
+ BUNDLED WITH
113
+ 1.11.2
data/Rakefile CHANGED
@@ -1,22 +1,18 @@
1
1
  require 'rubygems'
2
+ require 'opal/rspec/rake_task'
2
3
  require 'bundler/setup'
3
- require 'quality_control'
4
- require 'quality_control/rubycritic'
5
- require 'quality_control/rubocop'
6
- require 'quality_control/yard'
7
- require 'quality_control/opal_rspec'
8
4
  require 'fron'
9
5
 
10
6
  Bundler::GemHelper.install_tasks
11
7
 
12
- QualityControl::Rubycritic.directories += %w(opal)
13
- QualityControl::Yard.threshold = 95
14
- QualityControl::OpalRspec.files = /^opal\/fron\/.*\.rb/
15
- QualityControl::OpalRspec.threshold = 98
8
+ Opal::RSpec::RakeTask.new(:spec) do |_, task|
9
+ task.files = FileList[ARGV[1] || 'spec/**/*_spec.rb']
10
+ task.timeout = 120_000
11
+ end
16
12
 
17
- QualityControl.tasks += %w(
18
- syntax:ruby
19
- opal:rspec:coverage
20
- documentation:coverage
21
- rubycritic:coverage
22
- )
13
+ desc 'Run CI Tasks'
14
+ task :ci do
15
+ sh 'SPEC_OPTS="--color" rake spec'
16
+ sh 'rubocop lib opal spec'
17
+ sh 'rubycritic lib opal --mode-ci -s 94 --no-browser'
18
+ end
data/Readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fron
2
2
  [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/digitalnatives/fron?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3
- [![Build Status](https://travis-ci.org/digitalnatives/fron.svg?branch=master)](https://travis-ci.org/digitalnatives/fron)
3
+ [![Build Status](https://codeship.com/projects/c2463aa0-bf15-0132-a675-621d0583fd1f/status?branch=master)](https://codeship.com/projects/72882)
4
4
  [![Code Climate](https://codeclimate.com/github/digitalnatives/fron/badges/gpa.svg)](https://codeclimate.com/github/digitalnatives/fron)
5
5
  [![Inline docs](http://inch-ci.org/github/digitalnatives/fron.svg?branch=master)](http://inch-ci.org/github/digitalnatives/fron)
6
6
 
@@ -15,6 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.require_paths = ['lib']
17
17
 
18
- s.add_runtime_dependency 'opal', ['~> 0.7.0']
19
- s.add_development_dependency 'opal-rspec', '~> 0.4.0'
18
+ s.add_runtime_dependency 'opal', '~> 0.9.2'
19
+ s.add_development_dependency 'opal-rspec', '~> 0.5.0'
20
20
  end
@@ -1,4 +1,4 @@
1
1
  # Fron
2
2
  module Fron
3
- VERSION = '0.2.0rc1'
3
+ VERSION = '1.0.0rc1'.freeze
4
4
  end
@@ -1,6 +1,8 @@
1
1
  require 'opal'
2
+ require 'fron/js/scroll_into_view_if_needed'
2
3
  require 'fron/core_ext'
3
4
  require 'fron/dom'
4
5
  require 'fron/core'
5
6
  require 'fron/request'
6
7
  require 'fron/storage'
8
+ require 'fron/utils/render_proc'
@@ -1,3 +1,4 @@
1
1
  require 'fron/core/logger'
2
2
  require 'fron/core/component'
3
3
  require 'fron/core/eventable'
4
+ require 'fron/core/sheet'
@@ -1,7 +1,6 @@
1
1
  module Fron
2
- # Bevahviors
3
2
  module Behaviors
4
- # Components
3
+ # Behavior for composing and creating child components.
5
4
  module Components
6
5
  # Runs for included classes
7
6
  #
@@ -12,13 +11,11 @@ module Fron
12
11
 
13
12
  # Creates components from the registry
14
13
  #
15
- # @param registry [Array] Registry of components
16
- def self.component(registry)
17
- registry.each do |args|
18
- arguments = args.dup
19
- block = arguments.last.is_a?(Proc) ? arguments.pop : nil
20
- component(*arguments, &block)
21
- end
14
+ # @param item [Array] Component directive
15
+ def self.component(item)
16
+ arguments = item[:args].dup
17
+ block = item[:block]
18
+ component(*arguments, &block)
22
19
  end
23
20
 
24
21
  # Creates a child component
@@ -26,9 +23,20 @@ module Fron
26
23
  # @param name [String] The name of the component
27
24
  # @param comp [Class] The component
28
25
  # @param block [Proc] The block to eval on the new component
29
- def component(name, comp, &block)
26
+ #
27
+ # :reek:TooManyStatements
28
+ def component(name, comp, options = {}, &block)
30
29
  component = comp.is_a?(Class) ? comp.new(nil) : Component.new(comp)
31
30
  component.instance_eval(&block) if block
31
+
32
+ options.each do |key, value|
33
+ if component.respond_to?("#{key}=")
34
+ component.send("#{key}=", value)
35
+ else
36
+ component[key] = value
37
+ end
38
+ end
39
+
32
40
  self << component
33
41
  instance_variable_set "@#{name}", component
34
42
 
@@ -1,7 +1,7 @@
1
1
  module Fron
2
- # Bevahviors
2
+ # Behaviors
3
3
  module Behaviors
4
- # Events
4
+ # Behavior for handling events on components.
5
5
  module Events
6
6
  # Runs for included classes
7
7
  #
@@ -12,14 +12,13 @@ module Fron
12
12
 
13
13
  # Applies events from the registry
14
14
  #
15
- # @param registry [Array] Registry of events
16
- def self.on(registry)
17
- registry.each do |args|
18
- if args.length == 3
19
- delegate(args[0], args[1]) { |event| send args[2], event }
20
- else
21
- on(args[0]) { |event| send args[1], event }
22
- end
15
+ # @param item [Array] Registry of an event
16
+ def self.on(item)
17
+ args = item[:args]
18
+ if args.length == 3
19
+ delegate(args[0], args[1]) { |event| send args[2], event }
20
+ else
21
+ on(args[0]) { |event| send args[1], event }
23
22
  end
24
23
  end
25
24
  end