loco-rails-core 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1d631f46ff3610cc89a7346ce1418231724a0aabca82a82f36bebb8faa9b4a2
4
- data.tar.gz: 2e74c2c7fb88797ea0a68e969c6f5e25eab7b775dd8a593fc55c0d5691838ccb
3
+ metadata.gz: 26dfb688861249f6eab817d589b6c2f4de7bae1fcb05218db33d69617940c741
4
+ data.tar.gz: 7514dd2f4ba4b8581a20e45cfe9d9a15925db01890ed2190c930cd88e396a629
5
5
  SHA512:
6
- metadata.gz: 005ddaf32a115b3a553fd72e190ed69c0171f3c17f3c70675d93a227e14133c83571d73c8fcb932baf4a9715165967d4a2794b08d9727b4f1607016808224c5e
7
- data.tar.gz: 1ad4f5d5dbf597e4c72642323549c8b970a08de542739227eebc97987b2045944ab7b5248c2d4db64481ac683c53af4fd7a0c2ecc14d1254700aadbe73d3c08f
6
+ metadata.gz: e82d8feab942392d9e8bdd8344a00feb7f8a8c95e254c7b005ade84e93c5c9b594fea5b35e89faaf26f6cb3933ef7d0d1fd5baac17b493bb9a3c66c83621c342
7
+ data.tar.gz: 8b3bb24380d95d267d55f08bad9a1b0bc6d7873d236a71ececb329f046b3e223e12c0eb36175910c7b48d5f6f6761a8faa1b26a2f6f1bbc4d97fc8c8317a675b
data/README.md CHANGED
@@ -1,28 +1,87 @@
1
- # Loco::Core
2
- Short description and motivation.
1
+ ![logo](https://raw.githubusercontent.com/artofcodelabs/artofcodelabs.github.io/master/assets/ext/loco_logo_trans_sqr-300px.png)
3
2
 
4
- ## Usage
5
- How to use my plugin.
3
+ # 🧐 What is Loco-Rails-Core?
4
+
5
+ **Loco-Rails-Core** is a Rails plugin that has been extracted from [Loco-Rails](https://github.com/locoframework/loco-rails).
6
+ The reason for this extraction was to pull out functionality that can be used as a stand-alone lib.
7
+ This functionality was the origin of the [Loco-Rails](https://github.com/locoframework/loco-rails) project.
8
+
9
+ I wanted to provide a logical structure for a JavaScript code that corresponds to Rails` controllers and views.
10
+ The same controller's action that renders a response for a given request on the [Rails](https://rubyonrails.org) side would be called on the JavaScript level.
11
+ By _"the same"_ - I mean action with the same name and defined in an (optionally namespaced) controller with the corresponding name as the one on the server-side.
12
+
13
+ The **Loco-Rails-Core**, by itself, does not provide a lot of value. It should be used with its JavaScript complementary library - [Loco-JS-Core](https://github.com/locoframework/loco-js-core).
14
+ **Loco-Rails-Core**'s single generator adds `Loco::Core::Helpers` module to `ApplicationHelper`.
15
+ It also updates the `application.html.erb` layout by adding `data-*` attributes to HTML `<body>` element.
16
+ **Loco-Rails-Core** does this via methods defined in the mentioned above `Loco::Core::Helpers` module.
17
+
18
+ These attributes store the information about the namespace, controller, and action names involved in handing a given request.
19
+ [Loco-JS-Core](https://github.com/locoframework/loco-js-core) looks at these attributes to call out a method from the corresponding location but inside the JavaScript code.
20
+ In other words - [Loco-JS-Core](https://github.com/locoframework/loco-js-core) calls a JavaScript controller's action with the same name and located inside the same namespace.
21
+
22
+ _Example:_
23
+
24
+ Given that the `index` action from `Main::PagesControllers` handles a given request.
25
+ `<body>`'s data attributes are gonna look like this:
26
+
27
+ ```html
28
+ <body data-namespace="Main" data-controller="Pages" data-action="index">
29
+ </body>
30
+ ```
31
+
32
+ **Loco-JS-Core** will act similarly (simplified version):
33
+
34
+ ```javascript
35
+ // all JavaScript controllers are assigned to the Controllers object
36
+
37
+ namespaceController = new Controllers.Main;
38
+ namespaceController.initialize();
39
+
40
+ controller = new Controllers.Main.Pages;
41
+ controller.initialize();
42
+ controller.index();
43
+ ```
44
+
45
+ If you don't define a namespace controller - it will be skipped.
46
+ If you don't define an `initialize` or `index` actions - **Loco-JS-Core** won't call them.
47
+ You can define JavaScript counterparts only for those actions that you want to augment with JavaScript features.
48
+
49
+ **Loco-Rails-Core** is the right choice if you don't need all features that [Loco-Rails](https://github.com/locoframework/loco-rails) provides.
50
+
51
+
52
+ # 📥 Installation
6
53
 
7
- ## Installation
8
54
  Add this line to your application's Gemfile:
9
55
 
10
56
  ```ruby
11
57
  gem 'loco-rails-core'
12
58
  ```
13
-
14
59
  And then execute:
60
+
15
61
  ```bash
16
62
  $ bundle
17
63
  ```
18
64
 
19
- Or install it yourself as:
65
+
66
+ # 🎮 Usage
67
+
20
68
  ```bash
21
- $ gem install loco-rails-core
69
+ $ bin/rails generate loco:core:file_injector
22
70
  ```
23
71
 
24
- ## Contributing
25
- Contribution directions go here.
26
72
 
27
- ## License
73
+ # 👩🏽‍🔬 Tests
74
+
75
+ ```bash
76
+ $ bin/test
77
+ ```
78
+
79
+
80
+ # 📜 License
81
+
28
82
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
83
+
84
+
85
+ # 👨‍🏭 Author
86
+
87
+ Zbigniew Humeniuk from [Art of Code](https://artofcode.co)
@@ -4,7 +4,7 @@ module Loco
4
4
  module Core
5
5
  class FileInjectorGenerator < Rails::Generators::Base
6
6
  def application_helper
7
- file_path = Rails.root.join 'app', 'helpers', 'application_helper.rb'
7
+ file_path = Rails.root.join('app/helpers/application_helper.rb')
8
8
  line = %( include Loco::Core::Helpers\n)
9
9
  inject_into_file file_path, line, after: "module ApplicationHelper\n"
10
10
  end
@@ -19,12 +19,7 @@ module Loco
19
19
  end
20
20
 
21
21
  def layout_path
22
- Rails.root.join(
23
- 'app',
24
- 'views',
25
- 'layouts',
26
- 'application.html.erb'
27
- )
22
+ Rails.root.join('app/views/layouts/application.html.erb')
28
23
  end
29
24
  end
30
25
  end
@@ -4,13 +4,11 @@ module Loco
4
4
  module Core
5
5
  module Helpers
6
6
  def loco_body_data
7
- data_controller = controller_name.split('_').map(&:capitalize).join ''
7
+ data_controller = controller_name.split('_').map(&:capitalize).join
8
8
  {
9
9
  'data-namespace' => namespace_name,
10
10
  'data-controller' => data_controller,
11
- 'data-action' => action_name,
12
- 'data-rails-env' => Rails.env,
13
- 'data-user-agent' => request.user_agent
11
+ 'data-action' => action_name
14
12
  }
15
13
  end
16
14
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Loco
4
4
  module Core
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loco-rails-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zbigniew Humeniuk
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-06 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,71 +30,71 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.28.0
33
+ version: 3.38.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: 3.28.0
40
+ version: 3.38.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: puma
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.2'
47
+ version: 6.1.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.2'
54
+ version: 6.1.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.48'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.48'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 2.18.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 2.18.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: selenium-webdriver
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.142'
89
+ version: 4.8.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.142'
97
- description: It enhances the layout body element with attributes that contain information
96
+ version: 4.8.1
97
+ description: It enhances layout's body element with attributes containing information
98
98
  about the current namespace, controller and action.
99
99
  email:
100
100
  - hello@artofcode.co
@@ -115,7 +115,8 @@ licenses:
115
115
  - MIT
116
116
  metadata:
117
117
  allowed_push_host: https://rubygems.org
118
- post_install_message:
118
+ rubygems_mfa_required: 'true'
119
+ post_install_message:
119
120
  rdoc_options: []
120
121
  require_paths:
121
122
  - lib
@@ -123,15 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
124
  requirements:
124
125
  - - ">="
125
126
  - !ruby/object:Gem::Version
126
- version: '0'
127
+ version: 3.0.0
127
128
  required_rubygems_version: !ruby/object:Gem::Requirement
128
129
  requirements:
129
130
  - - ">="
130
131
  - !ruby/object:Gem::Version
131
132
  version: '0'
132
133
  requirements: []
133
- rubygems_version: 3.0.3
134
- signing_key:
134
+ rubygems_version: 3.4.6
135
+ signing_key:
135
136
  specification_version: 4
136
- summary: Core part of the Loco framework
137
+ summary: The core part of the Loco framework. It needs Loco-JS to work.
137
138
  test_files: []