trestle-resource_helpers 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: c69e695763e8a4cc47225caf10e0c03fd4365156bc644d77cff33fef4528aa3b
4
+ data.tar.gz: 75dc508779e3e0ce1d78938b9a9eb74b92e98481d875f2e192e35e9ec141d7e4
5
+ SHA512:
6
+ metadata.gz: e923121008b87d753fcf7fec63e9b06d23291d5b75db2500ae6c35364e24830d2403cd70ef9e25bd8a82ef54097074b6dd93363de2d0c858dbc690cba1bcf4c8
7
+ data.tar.gz: a36e16de13ccc73d85e5de1581fb9a51b67270f99f2a41807a67cd39524ca04fda1b8ba3c31854f521c080145e7fbed242b9586724480e131b2f38891a5bf0c2
data/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /spec/examples.txt
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+
14
+ # Used by dotenv library to load environment variables.
15
+ # .env
16
+
17
+ # Ignore Byebug command history file.
18
+ .byebug_history
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ # Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
55
+
56
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
57
+ # .rubocop-https?--*
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
8
+
9
+ rvm:
10
+ - 2.6.5
11
+
12
+ gemfile:
13
+ - gemfiles/rails-5.0.gemfile
14
+ - gemfiles/rails-5.1.gemfile
15
+ - gemfiles/rails-5.2.gemfile
16
+ - gemfiles/rails-6.0.gemfile
17
+ - gemfiles/rails-6.1.gemfile
18
+ - gemfiles/rails-6.2.gemfile
19
+
20
+ jobs:
21
+ include:
22
+ gemfile: gemfiles/rails-4.2.gemfile
23
+ before_install:
24
+ - gem install bundler -v '< 2'
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trestle-auth.gemspec
4
+ gemspec
5
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Matthieu "Ezveus" Ciappara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Trestle Model Helper (trestle-resource_helpers)
2
+
3
+ > Add helpers for Trestle resources
4
+
5
+
6
+ ## Getting Started
7
+
8
+ These instructions assume you have a working Trestle application. To integrate trestle-resource_helpers, first add it to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'trestle-resource_helpers'
12
+ ```
13
+
14
+ Run `bundle install`, and then restart your Rails server.
15
+
16
+ To add a description block within an admin resource, use the `resource_description` method:
17
+
18
+ ```ruby
19
+ Trestle.resource(:articles) do
20
+ resource_description do
21
+ 'An article is a super dupper class to add some content to the blog!'
22
+ end
23
+ end
24
+ ```
25
+
26
+ ## License
27
+
28
+ 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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ .main-content-header {
2
+ flex-wrap: wrap;
3
+ gap: 10px;
4
+ }
5
+
6
+ .resource-description {
7
+ width: 100%;
8
+ color: #5790a0;
9
+ background-color: #bee6f2;
10
+ border-color: #b7e4f1;
11
+ display: flex;
12
+ position: relative;
13
+ padding: 1.5rem 1.25rem;
14
+ margin-bottom: 1rem;
15
+ border: 1px solid rgba(0,0,0,0);
16
+ border-radius: 0.1rem;
17
+ flex-direction: column;
18
+ align-items: start;
19
+ }
@@ -0,0 +1,3 @@
1
+ <div class="resource-description">
2
+ <%= I18n.t("admin.#{admin.model.table_name}.resource_description", default: "No description found for key admin.#{admin.model.table_name}.resource_description") %>
3
+ </div>
@@ -0,0 +1,9 @@
1
+ Trestle.configure do |config|
2
+ config.hook("stylesheets") do
3
+ stylesheet_link_tag "trestle/resource_description"
4
+ end
5
+
6
+ config.hook("resource.index.header", if: -> { admin.resource_described? }) do
7
+ render "trestle/resource_helpers/resource_description"
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Trestle
2
+ module ResourceHelpers
3
+ module Builder
4
+ def resource_description
5
+ admin.define_adapter_method(:resource_description) do
6
+ # noop
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module Trestle
2
+ module ResourceHelpers
3
+ class Engine < Rails::Engine
4
+ config.assets.precompile << 'trestle/resource_description.css'
5
+
6
+ # config.to_prepare do
7
+ # Trestle::ResourceController.send(:include, Trestle::ResourceHelpers::ControllerConcern)
8
+ # end
9
+
10
+ initializer :extensions do
11
+ Trestle::Resource.send(:include, Trestle::ResourceHelpers::Resource)
12
+ Trestle::Resource::Builder.send(:include, Trestle::ResourceHelpers::Builder)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,25 @@
1
+ module Trestle
2
+ module ResourceHelpers
3
+ module Resource
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ prepend Collection
8
+
9
+ singleton_class.send(:prepend, Collection)
10
+ end
11
+
12
+ module Collection
13
+ def resource_description
14
+ adapter.resource_description if resource_described?
15
+ end
16
+ end
17
+
18
+ module ClassMethods
19
+ def resource_described?
20
+ adapter.respond_to?(:resource_description)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,5 @@
1
+ module Trestle
2
+ module ResourceHelpers
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'resource_helpers/version'
2
+
3
+ require 'trestle'
4
+
5
+ module Trestle
6
+ module ResourceHelpers
7
+
8
+ require_relative "resource_helpers/builder"
9
+ require_relative "resource_helpers/resource"
10
+
11
+ end
12
+ end
13
+
14
+ require_relative 'resource_helpers/engine' if defined?(Rails)
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/trestle/resource_helpers/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "trestle-resource_helpers"
5
+ spec.version = Trestle::ResourceHelpers::VERSION
6
+
7
+ spec.authors = ["Matthieu Ciappara"]
8
+ spec.email = ["matthieu.ciappara@outlook.com"]
9
+
10
+ spec.summary = "Add helpers for Trestle resources"
11
+ spec.homepage = "https://github.com/Ezveus/trestle-resource_helpers.git"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
15
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
16
+ end
17
+
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/Ezveus/trestle-resource_helpers"
24
+
25
+ spec.add_dependency 'rails', '>= 5.2', '< 7'
26
+ spec.add_dependency "trestle", "~> 0.9.0", ">= 0.9.3"
27
+
28
+ spec.add_development_dependency "rspec-rails", "~> 4.0"
29
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trestle-resource_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthieu Ciappara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-12 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: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
33
+ - !ruby/object:Gem::Dependency
34
+ name: trestle
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.9.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.9.3
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.9.3
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec-rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '4.0'
67
+ description:
68
+ email:
69
+ - matthieu.ciappara@outlook.com
70
+ executables: []
71
+ extensions: []
72
+ extra_rdoc_files: []
73
+ files:
74
+ - ".gitignore"
75
+ - ".travis.yml"
76
+ - Gemfile
77
+ - LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - app/assets/stylesheets/trestle/resource_description.css
81
+ - app/views/trestle/resource_helpers/_resource_description.html.erb
82
+ - config/initializers/trestle.rb
83
+ - lib/trestle/resource_helpers.rb
84
+ - lib/trestle/resource_helpers/builder.rb
85
+ - lib/trestle/resource_helpers/engine.rb
86
+ - lib/trestle/resource_helpers/resource.rb
87
+ - lib/trestle/resource_helpers/version.rb
88
+ - trestle-resource_helpers.gemspec
89
+ homepage: https://github.com/Ezveus/trestle-resource_helpers.git
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ homepage_uri: https://github.com/Ezveus/trestle-resource_helpers.git
94
+ source_code_uri: https://github.com/Ezveus/trestle-resource_helpers
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.3.0
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubygems_version: 3.0.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Add helpers for Trestle resources
114
+ test_files: []