essence 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/exe/essence +7 -0
- data/lib/essence/cli/add.rb +27 -0
- data/lib/essence/cli/install.rb +28 -0
- data/lib/essence/cli/version.rb +13 -0
- data/lib/essence/cli.rb +63 -0
- data/lib/essence/components/button.rb +1 -1
- data/lib/essence/{component.rb → components/essence.rb} +3 -1
- data/lib/essence/components/link.rb +1 -1
- data/lib/essence/components/row.rb +1 -1
- data/lib/essence/components/skeleton.rb +1 -1
- data/lib/essence/version.rb +1 -1
- data/lib/essence.rb +32 -1
- metadata +32 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a46dd9be7eb9ea84ba3ca4ad2f3a20333154644472673c347117bd6fb6b652
|
4
|
+
data.tar.gz: 3fd04819b2f327760571d3ec200a7300c45b7a4d7627b425e969a6999a051925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5688120d6baf34e1de5049978bd7a8b63f18bfd9dae45ab8acfbe3096b42f36168c5408502e7d4fc24bdafb4cda29fa1e7db77469fc3b6cd297ec685e89bb0a7
|
7
|
+
data.tar.gz: 9067b68f43129af1e0d5e4398b1d3682cf10bb05b0e06898ba708cec4d79e531e00129998a4697306c1b229fb139f33b985980c6216129a04279c1d02fb8e4d9
|
data/README.md
ADDED
data/exe/essence
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Essence
|
4
|
+
module CLI
|
5
|
+
class Add < Dry::CLI::Command
|
6
|
+
desc "Add an Essence component to your project"
|
7
|
+
argument :component_name, required: true, desc: "Component name"
|
8
|
+
example Essence.component_names
|
9
|
+
|
10
|
+
def call(*args)
|
11
|
+
component_name = args[0][:component_name]
|
12
|
+
|
13
|
+
return puts "> #{component_name}: component unsupported" unless Essence.component_names.include?(component_name.to_sym)
|
14
|
+
|
15
|
+
Essence::CLI::Commands.copy_component(component_name:)
|
16
|
+
Essence::CLI::Commands.replace_component_contents(component_name:)
|
17
|
+
Essence::CLI::Commands.replace_component_contents(
|
18
|
+
component_name:,
|
19
|
+
from: Essence::CLI::Commands::COMPONENT_DEFINITION_SUFFIX,
|
20
|
+
to: Essence::CLI::Commands::PHLEX_COMPONENT_DEFINITION_SUFFIX
|
21
|
+
)
|
22
|
+
|
23
|
+
puts "> Successfully added #{component_name} component to #{Essence::CLI::Commands::DESTINATION_DIR.join("#{component_name}.rb")}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Essence
|
4
|
+
module CLI
|
5
|
+
class Install < Dry::CLI::Command
|
6
|
+
BASE_COMPONENT_NAME = "essence"
|
7
|
+
BASE_DEFINITION_PREFIX = "class Essence::Essence"
|
8
|
+
PHLEX_BASE_DEFINITION_PREFIX = "class Components::Essence"
|
9
|
+
|
10
|
+
desc "Install Essence to your project"
|
11
|
+
def call(*)
|
12
|
+
puts "> Installing Essence..."
|
13
|
+
puts "> Copying base component to your project"
|
14
|
+
Essence::CLI::Commands.copy_component(component_name: BASE_COMPONENT_NAME)
|
15
|
+
Essence::CLI::Commands.replace_component_contents(
|
16
|
+
component_name: BASE_COMPONENT_NAME,
|
17
|
+
from: BASE_DEFINITION_PREFIX,
|
18
|
+
to: PHLEX_BASE_DEFINITION_PREFIX
|
19
|
+
)
|
20
|
+
# Essence::CLI::Commands.rename_component_file(
|
21
|
+
# from: Essence::CLI::Commands::DESTINATION_DIR.join("#{BASE_COMPONENT_NAME}.rb"),
|
22
|
+
# to: Essence::CLI::Commands::DESTINATION_DIR.join("essence.rb")
|
23
|
+
# )
|
24
|
+
puts "> Essence has been successfully installed!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/essence/cli.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dry/cli"
|
4
|
+
|
5
|
+
# CLI Commands
|
6
|
+
require_relative "cli/add"
|
7
|
+
require_relative "cli/install"
|
8
|
+
require_relative "cli/version"
|
9
|
+
|
10
|
+
module Essence
|
11
|
+
module CLI
|
12
|
+
def self.call(*args)
|
13
|
+
Dry::CLI.new(Commands).call
|
14
|
+
end
|
15
|
+
|
16
|
+
module Commands
|
17
|
+
extend Dry::CLI::Registry
|
18
|
+
|
19
|
+
# Constants
|
20
|
+
COMPONENTS_DIR = Pathname.new(File.expand_path("components", __dir__))
|
21
|
+
DESTINATION_DIR = Pathname.new(File.expand_path(Dir.pwd)).join("app/components")
|
22
|
+
COMPONENT_DEFINITION_PREFIX = "class Essence::"
|
23
|
+
COMPONENT_DEFINITION_SUFFIX = "< Essence::Essence"
|
24
|
+
PHLEX_COMPONENT_DEFINITION_PREFIX = "class Components::"
|
25
|
+
PHLEX_COMPONENT_DEFINITION_SUFFIX = "< Components::Essence"
|
26
|
+
|
27
|
+
# Registering commands
|
28
|
+
register "add", Add, aliases: ["a", "generate", "g"]
|
29
|
+
register "install", Install, aliases: ["i"]
|
30
|
+
register "version", Version, aliases: ["v", "-v", "--version"]
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# UTILITIES
|
35
|
+
def self.copy_component(component_name:)
|
36
|
+
source_path = COMPONENTS_DIR.join("#{component_name}.rb")
|
37
|
+
destination_path = DESTINATION_DIR.join("#{component_name}.rb")
|
38
|
+
|
39
|
+
FileUtils.mkdir_p(DESTINATION_DIR)
|
40
|
+
FileUtils.copy(source_path, destination_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.replace_component_contents(
|
44
|
+
component_name:,
|
45
|
+
from: COMPONENT_DEFINITION_PREFIX,
|
46
|
+
to: PHLEX_COMPONENT_DEFINITION_PREFIX
|
47
|
+
)
|
48
|
+
component_file = DESTINATION_DIR.join("#{component_name}.rb")
|
49
|
+
return unless File.exist?(component_file)
|
50
|
+
|
51
|
+
replaced_content = File.read(component_file).gsub(from, to)
|
52
|
+
File.write(component_file, replaced_content)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.rename_component_file(from:, to:)
|
56
|
+
return if from.nil? || to.nil?
|
57
|
+
return unless File.exist?(from)
|
58
|
+
|
59
|
+
FileUtils.mv(from, to)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Essence::Button < Essence::
|
3
|
+
class Essence::Button < Essence::Essence
|
4
4
|
BASE = "inline-flex items-center rounded-xs border border-transparent font-medium transition duration-150 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed hover:opacity-90"
|
5
5
|
|
6
6
|
SIZES = {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class Essence::Link < Essence::
|
3
|
+
class Essence::Link < Essence::Essence
|
4
4
|
CLASS = "inline-flex items-center gap-1 font-medium text-gray-900 border-b-2 hover:border-gray-900 transition-colors"
|
5
5
|
KINDS = {
|
6
6
|
regular: "border-transparent",
|
data/lib/essence/version.rb
CHANGED
data/lib/essence.rb
CHANGED
@@ -1,11 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "tailwind_merge"
|
2
4
|
|
3
5
|
module Essence
|
4
6
|
# Autoloading
|
5
|
-
autoload :Component, "essence/component"
|
7
|
+
autoload :Component, "essence/components/component"
|
6
8
|
|
7
9
|
autoload :Button, "essence/components/button"
|
8
10
|
autoload :Link, "essence/components/link"
|
9
11
|
autoload :Skeleton, "essence/components/skeleton"
|
10
12
|
autoload :Row, "essence/components/row"
|
13
|
+
|
14
|
+
autoload :CLI, "essence/cli"
|
15
|
+
|
16
|
+
# Components
|
17
|
+
# Class names and classes are separated to avoid loading in Phlex into the CLI tooling
|
18
|
+
|
19
|
+
def self.component_class_names
|
20
|
+
@component_class_names ||= {
|
21
|
+
essence: "Essence::Essence",
|
22
|
+
button: "Essence::Button",
|
23
|
+
link: "Essence::Link",
|
24
|
+
skeleton: "Essence::Skeleton",
|
25
|
+
row: "Essence::Row",
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.component_classes
|
30
|
+
@components_classes ||= {
|
31
|
+
essence: ::Essence::Essence,
|
32
|
+
button: ::Essence::Button,
|
33
|
+
link: ::Essence::Link,
|
34
|
+
skeleton: ::Essence::Skeleton,
|
35
|
+
row: ::Essence::Row,
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.component_names
|
40
|
+
@component_names ||= component_class_names.keys
|
41
|
+
end
|
11
42
|
end
|
metadata
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: essence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elvinas Predkelis
|
8
8
|
- Primevise
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-12-
|
12
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: dry-cli
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.7'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '2'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.7'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
14
34
|
- !ruby/object:Gem::Dependency
|
15
35
|
name: phlex
|
16
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,13 +62,20 @@ dependencies:
|
|
42
62
|
description: Component library for Ruby applications using Phlex
|
43
63
|
email:
|
44
64
|
- info@primevise.com
|
45
|
-
executables:
|
65
|
+
executables:
|
66
|
+
- essence
|
46
67
|
extensions: []
|
47
68
|
extra_rdoc_files: []
|
48
69
|
files:
|
70
|
+
- README.md
|
71
|
+
- exe/essence
|
49
72
|
- lib/essence.rb
|
50
|
-
- lib/essence/
|
73
|
+
- lib/essence/cli.rb
|
74
|
+
- lib/essence/cli/add.rb
|
75
|
+
- lib/essence/cli/install.rb
|
76
|
+
- lib/essence/cli/version.rb
|
51
77
|
- lib/essence/components/button.rb
|
78
|
+
- lib/essence/components/essence.rb
|
52
79
|
- lib/essence/components/link.rb
|
53
80
|
- lib/essence/components/row.rb
|
54
81
|
- lib/essence/components/skeleton.rb
|