jun 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ab6ae7fad2bb74ce92d8ef4a6c0b44c5016b04f02f6721d372694cb3b86c9a5
4
- data.tar.gz: 5da3c8f0d65029c88022c5b8d37e00e3f92f20ed0cb7592975118eb2608bd11f
3
+ metadata.gz: 70a404db6997b3aa8f1a682cfaac1d401e5a78aa2c6344645aed5819f9a7c617
4
+ data.tar.gz: 6ef4729b48e1f780a2004515c00a2ee6efbea77cade3522d942d05f602b509b8
5
5
  SHA512:
6
- metadata.gz: e99d2117bacaf90fd4400bf68725545ce2fd00f9a0292b22ba321cf3af195c1cb6900fcb0f2e66a98277351d7653c13e097270de1b85f8e2050b126e6c5c316b
7
- data.tar.gz: e81734bc3e01a3682537a928f050c243c2ecb5ee90f15ba10262b872bc8a618d87ba4b4da9d34d108efa2c6d3b33e2230e4a9eed26f685c5d20bb5fcc287a7b8
6
+ metadata.gz: fa512bde19df4fb617e5d49f6336433cff2ed31ba3dcfba942ed4473b8136a943ff92afcf0fb0a9dcf3f9ebc795f796393e0340a23bbfec183f7987cab90b841
7
+ data.tar.gz: 5bf62a8d2e2cfaedfce5435b44bc54388f2792b48459b028436c4baf40c8971a9bb6a53c3e63eda0126087142da5742cee470cb69890c50c2d23af228f883cad
data/jun.gemspec CHANGED
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_runtime_dependency "rack"
28
- spec.add_runtime_dependency "tilt"
29
- spec.add_runtime_dependency "sqlite3"
27
+ spec.add_runtime_dependency "rack", "~> 2.2"
28
+ spec.add_runtime_dependency "tilt", "~> 2.0"
29
+ spec.add_runtime_dependency "sqlite3", "~> 1.4"
30
30
 
31
31
  spec.add_development_dependency "rake", "~> 13.0"
32
32
  spec.add_development_dependency "minitest", "~> 5.0"
@@ -25,7 +25,7 @@ module Jun
25
25
 
26
26
  def path_regex
27
27
  path_string_for_regex = path.gsub(/:\w+/) { |match| "(?<#{match.delete(":")}>\\w+)" }
28
- Regexp.new("^#{path_string_for_regex}$")
28
+ Regexp.new("^#{path_string_for_regex}\/?$")
29
29
  end
30
30
  end
31
31
 
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <title>Welcome to Jun</title>
4
+ <title>Welcome to Jun!</title>
5
5
  <meta charset="utf-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1">
7
7
 
@@ -20,12 +20,21 @@
20
20
  margin-top: 4rem;
21
21
  text-align: center;
22
22
  }
23
+
24
+ .sunspot {
25
+ width: 100px;
26
+ height: 100px;
27
+ border-radius: 50%;
28
+ background-color: #fc7e70;
29
+ margin: 2rem auto;
30
+ }
23
31
  </style>
24
32
  </head>
25
33
 
26
34
  <body>
27
35
  <div class="root">
28
- <h1>Welcome to Jun</h1>
36
+ <div class="sunspot"></div>
37
+ <h1>Welcome to Jun!</h1>
29
38
  <small>Jun v<%= Jun::VERSION %> | Ruby v<%= RUBY_VERSION %> (<%= RUBY_PLATFORM %>)</small>
30
39
  </div>
31
40
  </body>
@@ -25,11 +25,25 @@ module ActiveRecord
25
25
 
26
26
  def save
27
27
  if new_record?
28
- result = self.class.connection.execute("INSERT INTO #{self.class.table_name} (#{@attributes.keys.join(",")}) VALUES (#{@attributes.values.map { |v| "'#{v}'" }.join(",")}) RETURNING *;")
28
+ result = self.class.connection.execute(
29
+ <<~SQL
30
+ INSERT INTO #{self.class.table_name}
31
+ (#{@attributes.keys.join(",")})
32
+ VALUES (#{@attributes.values.map { |v| "'#{v}'" }.join(",")})
33
+ RETURNING *;
34
+ SQL
35
+ )
36
+
29
37
  @attributes[self.class.primary_key] = result.first[self.class.primary_key]
30
38
  @new_record = false
31
39
  else
32
- self.class.connection.execute("UPDATE #{self.class.table_name} SET #{@attributes.map { |k, v| "#{k} = #{v}" }.join(",")} WHERE id = #{id};")
40
+ self.class.connection.execute(
41
+ <<~SQL
42
+ UPDATE #{self.class.table_name}
43
+ SET #{@attributes.map { |k, v| "#{k} = #{v.nil? ? 'NULL' : "'#{v}'"}" }.join(",")}
44
+ WHERE id = #{id};
45
+ SQL
46
+ )
33
47
  end
34
48
 
35
49
  true
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Array
4
+ def second
5
+ self[1]
6
+ end
7
+
8
+ def third
9
+ self[2]
10
+ end
11
+
12
+ def fourth
13
+ self[3]
14
+ end
15
+
16
+ def fifth
17
+ self[4]
18
+ end
19
+
20
+ def third_to_last
21
+ self[-3]
22
+ end
23
+
24
+ def second_to_last
25
+ self[-2]
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Hash
4
+ def stringify_keys
5
+ transform_keys(&:to_s)
6
+ end
7
+
8
+ def stringify_keys!
9
+ transform_keys!(&:to_s)
10
+ end
11
+
12
+ def symbolize_keys
13
+ transform_keys { |key| key.to_sym rescue key }
14
+ end
15
+
16
+ def symbolize_keys!
17
+ transform_keys! { |key| key.to_sym rescue key }
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class String
4
+ def at(position)
5
+ self[position]
6
+ end
7
+
8
+ def from(position)
9
+ self[position, length]
10
+ end
11
+
12
+ def to(position)
13
+ position += size if position.negative?
14
+ position = -1 if position.negative?
15
+
16
+ self[0, position + 1]
17
+ end
18
+ end
data/lib/jun/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jun
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-28 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tilt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2.0'
34
34
  type: :runtime
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: '0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.4'
48
48
  type: :runtime
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: '0'
54
+ version: '1.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +143,10 @@ files:
143
143
  - lib/jun/active_record/persistence.rb
144
144
  - lib/jun/active_record/relation.rb
145
145
  - lib/jun/active_support/core_ext.rb
146
+ - lib/jun/active_support/core_ext/array/access.rb
146
147
  - lib/jun/active_support/core_ext/array/conversion.rb
148
+ - lib/jun/active_support/core_ext/hash/transformation.rb
149
+ - lib/jun/active_support/core_ext/string/access.rb
147
150
  - lib/jun/active_support/core_ext/string/inflector.rb
148
151
  - lib/jun/active_support/dependencies.rb
149
152
  - lib/jun/application.rb