motion 0.1.2 → 0.4.0

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.
@@ -6,6 +6,7 @@ module Motion
6
6
  class MyRailtie < Rails::Railtie
7
7
  generators do
8
8
  require "generators/motion/install_generator"
9
+ require "generators/motion/component_generator"
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+ require "motion"
5
+
6
+ module Motion
7
+ class RevisionCalculator
8
+ attr_reader :revision_paths
9
+
10
+ def initialize(revision_paths:)
11
+ @revision_paths = revision_paths
12
+ end
13
+
14
+ def perform
15
+ derive_file_hash
16
+ end
17
+
18
+ private
19
+
20
+ def derive_file_hash
21
+ digest = Digest::MD5.new
22
+
23
+ files.each do |file|
24
+ digest << file # include filename as well as contents
25
+ digest << File.read(file)
26
+ end
27
+
28
+ digest.hexdigest
29
+ end
30
+
31
+ def existent_paths
32
+ @existent_paths ||=
33
+ begin
34
+ revision_paths.all_paths.flat_map(&:existent)
35
+ rescue
36
+ raise BadRevisionPathsError
37
+ end
38
+ end
39
+
40
+ def existent_files(path)
41
+ Dir["#{path}/**/*", path].reject { |f| File.directory?(f) }.uniq
42
+ end
43
+
44
+ def files
45
+ @files ||= existent_paths.flat_map { |path| existent_files(path) }.sort
46
+ end
47
+ end
48
+ end
@@ -32,6 +32,10 @@ module Motion
32
32
  @revision = revision
33
33
  end
34
34
 
35
+ def weak_digest(component)
36
+ dump(component).hash
37
+ end
38
+
35
39
  def serialize(component)
36
40
  state = dump(component)
37
41
  state_with_revision = "#{revision}#{NULL_BYTE}#{state}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motion
4
- VERSION = "0.1.2"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alec Larsen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-06-26 00:00:00.000000000 Z
12
+ date: 2020-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -49,18 +49,24 @@ executables: []
49
49
  extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
+ - lib/generators/motion/component_generator.rb
52
53
  - lib/generators/motion/install_generator.rb
54
+ - lib/generators/motion/templates/motion.js
53
55
  - lib/generators/motion/templates/motion.rb
54
- - lib/generators/motion/templates/motion_controller.js
55
56
  - lib/motion.rb
56
57
  - lib/motion/action_cable_extentions.rb
58
+ - lib/motion/action_cable_extentions/declarative_notifications.rb
57
59
  - lib/motion/action_cable_extentions/declarative_streams.rb
58
60
  - lib/motion/action_cable_extentions/log_suppression.rb
61
+ - lib/motion/action_cable_extentions/synchronization.rb
62
+ - lib/motion/callback.rb
59
63
  - lib/motion/channel.rb
60
64
  - lib/motion/component.rb
61
65
  - lib/motion/component/broadcasts.rb
66
+ - lib/motion/component/callbacks.rb
62
67
  - lib/motion/component/lifecycle.rb
63
68
  - lib/motion/component/motions.rb
69
+ - lib/motion/component/periodic_timers.rb
64
70
  - lib/motion/component/rendering.rb
65
71
  - lib/motion/component_connection.rb
66
72
  - lib/motion/configuration.rb
@@ -70,6 +76,7 @@ files:
70
76
  - lib/motion/log_helper.rb
71
77
  - lib/motion/markup_transformer.rb
72
78
  - lib/motion/railtie.rb
79
+ - lib/motion/revision_calculator.rb
73
80
  - lib/motion/serializer.rb
74
81
  - lib/motion/test_helpers.rb
75
82
  - lib/motion/version.rb
@@ -81,7 +88,7 @@ metadata:
81
88
  source_code_uri: https://github.com/unabridged/motion
82
89
  post_install_message: |
83
90
  Friendly reminder: When updating the motion gem, don't forget to update the
84
- NPM package as well (`bin/yarn add '@unabridged/motion@0.1.2'`).
91
+ NPM package as well (`bin/yarn add '@unabridged/motion@0.4.0'`).
85
92
  rdoc_options: []
86
93
  require_paths:
87
94
  - lib
@@ -1,28 +0,0 @@
1
- import { Controller } from "@unabridged/motion";
2
- import consumer from "../channels/consumer";
3
-
4
- // If you change the name of this controller (determined by the file name),
5
- // make sure to update `Motion.config.stimulus_controller_identifier`.
6
- export default class extends Controller {
7
- // To avoid creating a second websocket, make sure to reuse the application's
8
- // ActionCable consumer.
9
- getConsumer() {
10
- return consumer;
11
- }
12
-
13
- // It is possible to additionally customize the behavior of the client by
14
- // overriding these properties and methods:
15
-
16
- // getExtraDataForEvent(event) {} // `Motion::Event#extra_data`
17
-
18
- // keyAttribute = "data-motion-key"; // `Motion.config.key_attribute`
19
- // stateAttribute = "data-motion-state"; // `Motion.config.state_attribute`
20
- // motionAttribute = "data-motion"; // `Motion.config.motion_attribute`
21
-
22
- // beforeConnect() { /* by default, dispatches `motion:before-connect` */ }
23
- // connected() { /* by default, dispatches `motion:connected` */ }
24
- // connectFailed() { /* by default, dispatches `motion:connect-failed` */ }
25
- // disconnected() { /* by default, dispatches `motion:disconnected` */ }
26
- // beforeRender() { /* by default, dispatches `motion:before-render` */ }
27
- // rendered() { /* by default, dispatches `motion:rendered` */ }
28
- }