organizer-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3e91878913dc46de82d051515ae95701982e56898dd29b2f7904027f141b4e95
4
+ data.tar.gz: 3be44a3b6e77c8874902553273cf1a84dff0569c2587b5deaae24cab66ede6bc
5
+ SHA512:
6
+ metadata.gz: 7dfa7797f8eff39028f58681463bec5dc5f65ba52958f8b54e63111a3bde4d94dbfef8660957433fd9ba7d36e06e344dc343dbe164f70f3e3ac7fb12cc2f9076
7
+ data.tar.gz: b2af4b380c145031992e9a452e1ad79338488af4a5008760a4804043b545aa07db407d05dc3940fc3847dba7441d404cbdee49d6a07b6f47a8b24bed6162a522
data/CHANGELOG.md ADDED
File without changes
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright Alexander Senko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Organizer
2
+
3
+ A Rails Engine providing some tools to organize your application records, e.g. _lists_, _tags_, _flags_, etc.
4
+
5
+ ## Usage
6
+
7
+ ### `Identifiable`
8
+
9
+ Presuming `MyModel` has a unique `name` attribute:
10
+
11
+ ```ruby
12
+ class MyModel < ApplicationRecord
13
+ include Organizer::Identifiable.by :name
14
+ end
15
+
16
+ MyModel.names # => [:my_name, :other_name, …]
17
+ MyModel[:my_name] # => #<MyModel1 id: 1, name: "my_name">
18
+ ```
19
+
20
+ ## Installation
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem "organizer-rails"
25
+ ```
26
+
27
+ And then execute:
28
+ ```bash
29
+ $ bundle
30
+ ```
31
+
32
+ Or install it yourself as:
33
+ ```bash
34
+ $ gem install organizer-rails
35
+ ```
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
44
+
45
+ ## License
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/organizer .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,2 @@
1
+ class ListsController < InheritedResources::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ module Organizer
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,5 @@
1
+ class ListDecorator < ApplicationDecorator
2
+ delegate_all
3
+
4
+ decorates_association :messages
5
+ end
@@ -0,0 +1,4 @@
1
+ module Organizer
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Organizer
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Organizer
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: "from@example.com"
4
+ layout "mailer"
5
+ end
6
+ end
@@ -0,0 +1,46 @@
1
+ module Organizer
2
+ concern :Identifiable do
3
+ class << self
4
+ def by column_name
5
+ dup.tap do
6
+ _1.module_eval do
7
+ included do
8
+ @identified_by = column_name
9
+ end
10
+
11
+ class_methods do # public API
12
+ define_method(column_name.to_s.pluralize) { identifiers }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ class_methods do
20
+ def [] *id
21
+ return id.map { self[_1] } if id.many?
22
+
23
+ case id = id.first
24
+ when Enumerable
25
+ id.filter_map { identified_as _1 }
26
+ else
27
+ identified_as id or
28
+ raise ArgumentError, "Couldn't find #{self} `#{id}`"
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def identifiers
35
+ @identifiers ||= # cache
36
+ all.pluck(@identified_by)
37
+ .map &:to_sym
38
+ end
39
+
40
+ def identified_as identifier
41
+ (@identified ||= {}.with_indifferent_access)[identifier] ||= # cache
42
+ find_by @identified_by => identifier
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ module Organizer
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Organizer</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "organizer/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Organizer::Engine.routes.draw do
2
+ end
@@ -0,0 +1,15 @@
1
+ Gem::Author ||= Struct.new(
2
+ :name,
3
+ :email,
4
+ :github_url,
5
+ )
6
+
7
+ module Organizer
8
+ AUTHORS = [
9
+ Gem::Author.new(
10
+ name: 'Alexander Senko',
11
+ email: 'Alexander.Senko@gmail.com',
12
+ github_url: 'https://github.com/Alexander-Senko',
13
+ ),
14
+ ]
15
+ end
@@ -0,0 +1,5 @@
1
+ module Organizer
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Organizer
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Organizer
2
+ VERSION = "0.1.0"
3
+ end
data/lib/organizer.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "organizer/version"
2
+ require "organizer/engine"
3
+
4
+ module Organizer
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :organizer do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: organizer-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Senko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-12-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.1'
27
+ description: Use lists, tags, flags, etc. to organize your application records.
28
+ email:
29
+ - Alexander.Senko@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - app/assets/config/organizer_manifest.js
39
+ - app/assets/stylesheets/organizer/application.css
40
+ - app/controllers/lists_controller.rb
41
+ - app/controllers/organizer/application_controller.rb
42
+ - app/decorators/list_decorator.rb
43
+ - app/helpers/organizer/application_helper.rb
44
+ - app/jobs/organizer/application_job.rb
45
+ - app/mailers/organizer/application_mailer.rb
46
+ - app/models/concerns/organizer/identifiable.rb
47
+ - app/models/organizer/application_record.rb
48
+ - app/views/layouts/organizer/application.html.erb
49
+ - config/routes.rb
50
+ - lib/organizer.rb
51
+ - lib/organizer/authors.rb
52
+ - lib/organizer/engine.rb
53
+ - lib/organizer/version.rb
54
+ - lib/tasks/organizer_tasks.rake
55
+ homepage: https://github.com/Alexander-Senko/organizer-rails
56
+ licenses:
57
+ - MIT
58
+ metadata:
59
+ homepage_uri: https://github.com/Alexander-Senko/organizer-rails
60
+ source_code_uri: https://github.com/Alexander-Senko/organizer-rails
61
+ changelog_uri: https://github.com/Alexander-Senko/organizer-rails/CHANGELOG.md
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '3.2'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubygems_version: 3.5.0.dev
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Record organizer for Rails
81
+ test_files: []