jun 0.3.0 → 0.3.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 +4 -4
- data/lib/jun/action_dispatch/routing/welcome.html.erb +18 -0
- data/lib/jun/active_support/core_ext/array/access.rb +6 -0
- data/lib/jun/active_support/core_ext/array/conversion.rb +8 -0
- data/lib/jun/active_support/core_ext/hash/transformation.rb +10 -0
- data/lib/jun/active_support/core_ext/string/access.rb +24 -0
- data/lib/jun/active_support/core_ext/string/inflector.rb +18 -0
- data/lib/jun/active_support/dependencies.rb +2 -0
- data/lib/jun/application.rb +4 -0
- data/lib/jun/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: febb60185e9d61a52eb783ec6052f39a35b7a41afca6bf27cf8db4bea718536f
|
4
|
+
data.tar.gz: 8c4068f3c9093bc6b9184d1e9eeda93e06ff4ba11bf826c4dec93feb218efc73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0957dea84721aec8cbb82eeef95d7516c5862960683086686ee6b1ee2e0fae69ff4dbf72d145530d174f9220cd8e384206160a1264a9eba5eeaf334d51bd8674'
|
7
|
+
data.tar.gz: 5e90b858218ba802b04d5d7752f227947493b0c65243437faf8757147c726815794dd6f921521ce438b03ffc66883152379988b4b05058ad70276879c6d26e0d
|
@@ -21,6 +21,19 @@
|
|
21
21
|
text-align: center;
|
22
22
|
}
|
23
23
|
|
24
|
+
.button {
|
25
|
+
background-color: #fc7e70;
|
26
|
+
color: #fff;
|
27
|
+
margin: 0 0.2rem;
|
28
|
+
padding: 0.5rem 0.75rem;
|
29
|
+
border-radius: 3px;
|
30
|
+
text-decoration: none;
|
31
|
+
}
|
32
|
+
|
33
|
+
.docs-links {
|
34
|
+
margin: 1.5rem 0;
|
35
|
+
}
|
36
|
+
|
24
37
|
.sunspot {
|
25
38
|
width: 100px;
|
26
39
|
height: 100px;
|
@@ -35,6 +48,11 @@
|
|
35
48
|
<div class="root">
|
36
49
|
<div class="sunspot"></div>
|
37
50
|
<h1>Welcome to Jun!</h1>
|
51
|
+
<p>Get started by checking out the guide or reading up on the docs.</p>
|
52
|
+
<div class="docs-links">
|
53
|
+
<a class="button" href="https://www.rubydoc.info/gems/jun/<%= Jun::VERSION %>#getting-started">Getting Started</a>
|
54
|
+
<a class="button" href="https://www.rubydoc.info/gems/jun/<%= Jun::VERSION %>">Documentation</a>
|
55
|
+
</div>
|
38
56
|
<small>Jun v<%= Jun::VERSION %> | Ruby v<%= RUBY_VERSION %> (<%= RUBY_PLATFORM %>)</small>
|
39
57
|
</div>
|
40
58
|
</body>
|
@@ -1,26 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Array
|
4
|
+
# Returns the second element in the array.
|
4
5
|
def second
|
5
6
|
self[1]
|
6
7
|
end
|
7
8
|
|
9
|
+
# Returns the third element in the array.
|
8
10
|
def third
|
9
11
|
self[2]
|
10
12
|
end
|
11
13
|
|
14
|
+
# Returns the fourth element in the array.
|
12
15
|
def fourth
|
13
16
|
self[3]
|
14
17
|
end
|
15
18
|
|
19
|
+
# Returns the fifth element in the array.
|
16
20
|
def fifth
|
17
21
|
self[4]
|
18
22
|
end
|
19
23
|
|
24
|
+
# Returns the third-to-last element in the array.
|
20
25
|
def third_to_last
|
21
26
|
self[-3]
|
22
27
|
end
|
23
28
|
|
29
|
+
# Returns the second-to-last element in the array.
|
24
30
|
def second_to_last
|
25
31
|
self[-2]
|
26
32
|
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Array
|
4
|
+
# Converts the array to a comma-separated sentence.
|
5
|
+
#
|
6
|
+
# ["one", "two", "three"].to_sentence #=> "one, two and three"
|
7
|
+
# ["left", "right"].to_sentence(last_delimiter: "or") #=> "left or right"
|
8
|
+
# [].to_sentence #=> ""
|
9
|
+
#
|
10
|
+
# @param delimiter [String] the delimiter value for connecting array elements.
|
11
|
+
# @param last_delimiter [String] the connecting word for the last array element.
|
4
12
|
def to_sentence(delimiter: ", ", last_delimiter: "and")
|
5
13
|
return "" if none?
|
6
14
|
return self.first if one?
|
@@ -1,18 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Hash
|
4
|
+
# Returns a new hash with all keys converted to strings.
|
5
|
+
#
|
6
|
+
# { name: "Tom", age: 50 }.stringify_keys #=> {"name"=>"Tom", "age"=>50}
|
4
7
|
def stringify_keys
|
5
8
|
transform_keys(&:to_s)
|
6
9
|
end
|
7
10
|
|
11
|
+
# Modifies the hash in place to convert all keys to strings.
|
12
|
+
# Same as +stringify_keys+ but modifies +self+.
|
8
13
|
def stringify_keys!
|
9
14
|
transform_keys!(&:to_s)
|
10
15
|
end
|
11
16
|
|
17
|
+
# Returns a new hash with all keys converted to symbols.
|
18
|
+
#
|
19
|
+
# { "name" => "Tom", "age" => 50 }.symbolize_keys #=> {:name=>"Tom", :age=>50 }
|
12
20
|
def symbolize_keys
|
13
21
|
transform_keys { |key| key.to_sym rescue key }
|
14
22
|
end
|
15
23
|
|
24
|
+
# Modifies the hash in place to convert all keys to symbols.
|
25
|
+
# Same as +symbolize_keys+ but modifies +self+.
|
16
26
|
def symbolize_keys!
|
17
27
|
transform_keys! { |key| key.to_sym rescue key }
|
18
28
|
end
|
@@ -1,14 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class String
|
4
|
+
# Returns a character at the given integer of the string. The first character
|
5
|
+
# would be returned for index 0, the second at index 1, and onward. If a range
|
6
|
+
# is given, a substring conaining the characters within the range of the given
|
7
|
+
# indicies is returned. If a Regex is provided, the matching substring is returned.
|
8
|
+
#
|
9
|
+
# string = "smoki"
|
10
|
+
# string.at(0) # => "s"
|
11
|
+
# string.at(1..3) # => "mok"
|
12
|
+
# string.at(-2) # => "k"
|
13
|
+
# string.at(/oki/) # => "oki"
|
4
14
|
def at(position)
|
5
15
|
self[position]
|
6
16
|
end
|
7
17
|
|
18
|
+
# Returns a substring from the given position (index) to the end of the string.
|
19
|
+
# If the position is negative, the starting point is counted from the end of the string.
|
20
|
+
#
|
21
|
+
# string = "smoki"
|
22
|
+
# string.from(0) # => "smoki"
|
23
|
+
# string.from(3) # => "ki"
|
24
|
+
# string.from(-2) # => "ki"
|
8
25
|
def from(position)
|
9
26
|
self[position, length]
|
10
27
|
end
|
11
28
|
|
29
|
+
# Returns a substring from the beginning of the string to the given position (index).
|
30
|
+
# If the position is negative, the ending point is counted from the end of the string.
|
31
|
+
#
|
32
|
+
# string = "smoki"
|
33
|
+
# string.to(0) # => "s"
|
34
|
+
# string.to(3) # => "smok"
|
35
|
+
# string.to(-2) # => "smok"
|
12
36
|
def to(position)
|
13
37
|
position += size if position.negative?
|
14
38
|
position = -1 if position.negative?
|
@@ -68,6 +68,11 @@ module Inflector
|
|
68
68
|
'equipment'
|
69
69
|
]
|
70
70
|
|
71
|
+
# Returns the plural form of the string.
|
72
|
+
#
|
73
|
+
# "task".pluralize #=> "tasks"
|
74
|
+
# "octopus".pluralize #=> "octopi"
|
75
|
+
# "fish".singularize #=> "fish"
|
71
76
|
def pluralize
|
72
77
|
return self if UNCHANGEABLE.include? self
|
73
78
|
|
@@ -82,6 +87,11 @@ module Inflector
|
|
82
87
|
self.sub(pattern, replacement)
|
83
88
|
end
|
84
89
|
|
90
|
+
# Returns the singular form of the string.
|
91
|
+
#
|
92
|
+
# "tasks".singularize #=> "task"
|
93
|
+
# "octopi".singularize #=> "octopus"
|
94
|
+
# "fish".singularize #=> "fish"
|
85
95
|
def singularize
|
86
96
|
return self if UNCHANGEABLE.include? self
|
87
97
|
|
@@ -96,6 +106,10 @@ module Inflector
|
|
96
106
|
self.sub(pattern, replacement)
|
97
107
|
end
|
98
108
|
|
109
|
+
# Converts a string to under_score format.
|
110
|
+
#
|
111
|
+
# "HelloThere".underscore #=> "hello_there"
|
112
|
+
# "Foo::BarBaz".underscore #=> "foo/bar_baz"
|
99
113
|
def underscore
|
100
114
|
gsub(/::/, '/').
|
101
115
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
@@ -104,6 +118,10 @@ module Inflector
|
|
104
118
|
downcase
|
105
119
|
end
|
106
120
|
|
121
|
+
# Converts a string to CamelCase format.
|
122
|
+
#
|
123
|
+
# "hello_there".camelize #=> "HelloThere"
|
124
|
+
# "foo/bar_baz".camelize #=> "Foo::BarBaz"
|
107
125
|
def camelize
|
108
126
|
sub(/^[a-z\d]*/) { |match| match.capitalize }.
|
109
127
|
gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.
|
@@ -8,6 +8,8 @@ module Jun
|
|
8
8
|
attr_accessor :autoload_paths
|
9
9
|
self.autoload_paths = []
|
10
10
|
|
11
|
+
# Returns the filepath for a given filename if the file exists
|
12
|
+
# in one of the directories specified in +autoload_paths+.
|
11
13
|
def find_file(filename)
|
12
14
|
autoload_paths.each do |path|
|
13
15
|
filepath = File.join(path, "#{filename}.rb")
|
data/lib/jun/application.rb
CHANGED
@@ -15,6 +15,8 @@ module Jun
|
|
15
15
|
@routes ||= Jun::ActionDispatch::Routing::RouteSet.new
|
16
16
|
end
|
17
17
|
|
18
|
+
# Initializes the Jun application.
|
19
|
+
# @return [Boolean] +true+ if successful, +false+ if already initialized.
|
18
20
|
def initialize!
|
19
21
|
return false if initialized? || Jun.application.nil?
|
20
22
|
|
@@ -38,6 +40,8 @@ module Jun
|
|
38
40
|
@initialized = true
|
39
41
|
end
|
40
42
|
|
43
|
+
# Checks whether the Jun application has been initialized.
|
44
|
+
# @return [Boolean] +true+ if initialized, +false+ if not initialized.
|
41
45
|
def initialized?
|
42
46
|
!!@initialized
|
43
47
|
end
|
data/lib/jun/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoran
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|