ant-design-rails 0.0.1 → 0.2.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: 2439845d459b04b101663a12394c4b0478e97c5d5d3d173fbcd9611a73b6b682
4
- data.tar.gz: 01dc6b29ab80d667af27a245e799b599af8f2bb2bd8cf2a02b72046a0e24ffab
3
+ metadata.gz: 492764161c93c55fcbf998e1dd443b9fb72913081cceb84c8bf4035ef4dce334
4
+ data.tar.gz: be5aa10e0e4d934f2c59fc195ef6fa923189cb6ea13e10445dd2bdfc83a72f55
5
5
  SHA512:
6
- metadata.gz: 5f2bc22a19971e08cfaaded469537e6ee0a5deb4f42559634170d3050e32ee370f750e0fa91fd984453acd83c210cde8aa027da33861832b1714a826a3200301
7
- data.tar.gz: f7fd108207d3efbb45df905d6fdffb756f89950e8a3e41a6194a105189eaf6056e40ce45c4039f33a6883f3e49863566862e4a43e8292baddb7dc11c307227fc
6
+ metadata.gz: 20e11fae568977b104d22c477662ca88d195d1a83d410d2d2c6907798ca10473d6fbd8128e894f36d2c3c48e62b02fb46e69aa7e6a656f78d759a480226ee2fd
7
+ data.tar.gz: 23f6dd8da460561376ceb923acde1745942cf5c5d298a7ba1db35d7de764aeeb82a1147fbcdd7003f5910f195aee0e78acc4a3ce742dbeb5ebed2222185643b3
data/Gemfile.lock CHANGED
@@ -1,12 +1,156 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ant-design-rails (0.0.1)
4
+ ant-design-rails (0.2.0)
5
+ execjs (~> 2.8, >= 2.8.1)
6
+ olive_branch (~> 4.0, >= 4.0.1)
7
+ railties (~> 7.0.4, >= 7.0.4.2)
5
8
 
6
9
  GEM
7
10
  remote: https://rubygems.org/
8
11
  specs:
12
+ actioncable (7.0.4.2)
13
+ actionpack (= 7.0.4.2)
14
+ activesupport (= 7.0.4.2)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (7.0.4.2)
18
+ actionpack (= 7.0.4.2)
19
+ activejob (= 7.0.4.2)
20
+ activerecord (= 7.0.4.2)
21
+ activestorage (= 7.0.4.2)
22
+ activesupport (= 7.0.4.2)
23
+ mail (>= 2.7.1)
24
+ net-imap
25
+ net-pop
26
+ net-smtp
27
+ actionmailer (7.0.4.2)
28
+ actionpack (= 7.0.4.2)
29
+ actionview (= 7.0.4.2)
30
+ activejob (= 7.0.4.2)
31
+ activesupport (= 7.0.4.2)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ net-imap
34
+ net-pop
35
+ net-smtp
36
+ rails-dom-testing (~> 2.0)
37
+ actionpack (7.0.4.2)
38
+ actionview (= 7.0.4.2)
39
+ activesupport (= 7.0.4.2)
40
+ rack (~> 2.0, >= 2.2.0)
41
+ rack-test (>= 0.6.3)
42
+ rails-dom-testing (~> 2.0)
43
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
+ actiontext (7.0.4.2)
45
+ actionpack (= 7.0.4.2)
46
+ activerecord (= 7.0.4.2)
47
+ activestorage (= 7.0.4.2)
48
+ activesupport (= 7.0.4.2)
49
+ globalid (>= 0.6.0)
50
+ nokogiri (>= 1.8.5)
51
+ actionview (7.0.4.2)
52
+ activesupport (= 7.0.4.2)
53
+ builder (~> 3.1)
54
+ erubi (~> 1.4)
55
+ rails-dom-testing (~> 2.0)
56
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
+ activejob (7.0.4.2)
58
+ activesupport (= 7.0.4.2)
59
+ globalid (>= 0.3.6)
60
+ activemodel (7.0.4.2)
61
+ activesupport (= 7.0.4.2)
62
+ activerecord (7.0.4.2)
63
+ activemodel (= 7.0.4.2)
64
+ activesupport (= 7.0.4.2)
65
+ activestorage (7.0.4.2)
66
+ actionpack (= 7.0.4.2)
67
+ activejob (= 7.0.4.2)
68
+ activerecord (= 7.0.4.2)
69
+ activesupport (= 7.0.4.2)
70
+ marcel (~> 1.0)
71
+ mini_mime (>= 1.1.0)
72
+ activesupport (7.0.4.2)
73
+ concurrent-ruby (~> 1.0, >= 1.0.2)
74
+ i18n (>= 1.6, < 2)
75
+ minitest (>= 5.1)
76
+ tzinfo (~> 2.0)
77
+ builder (3.2.4)
78
+ concurrent-ruby (1.2.0)
79
+ crass (1.0.6)
80
+ date (3.3.3)
81
+ erubi (1.12.0)
82
+ execjs (2.8.1)
83
+ globalid (1.1.0)
84
+ activesupport (>= 5.0)
85
+ i18n (1.12.0)
86
+ concurrent-ruby (~> 1.0)
87
+ loofah (2.19.1)
88
+ crass (~> 1.0.2)
89
+ nokogiri (>= 1.5.9)
90
+ mail (2.8.0.1)
91
+ mini_mime (>= 0.1.1)
92
+ net-imap
93
+ net-pop
94
+ net-smtp
95
+ marcel (1.0.2)
96
+ method_source (1.0.0)
97
+ mini_mime (1.1.2)
98
+ minitest (5.17.0)
99
+ multi_json (1.15.0)
100
+ net-imap (0.3.4)
101
+ date
102
+ net-protocol
103
+ net-pop (0.1.2)
104
+ net-protocol
105
+ net-protocol (0.2.1)
106
+ timeout
107
+ net-smtp (0.3.3)
108
+ net-protocol
109
+ nio4r (2.5.8)
110
+ nokogiri (1.14.0-arm64-darwin)
111
+ racc (~> 1.4)
112
+ olive_branch (4.0.1)
113
+ multi_json
114
+ rails (>= 4.0)
115
+ racc (1.6.2)
116
+ rack (2.2.6.2)
117
+ rack-test (2.0.2)
118
+ rack (>= 1.3)
119
+ rails (7.0.4.2)
120
+ actioncable (= 7.0.4.2)
121
+ actionmailbox (= 7.0.4.2)
122
+ actionmailer (= 7.0.4.2)
123
+ actionpack (= 7.0.4.2)
124
+ actiontext (= 7.0.4.2)
125
+ actionview (= 7.0.4.2)
126
+ activejob (= 7.0.4.2)
127
+ activemodel (= 7.0.4.2)
128
+ activerecord (= 7.0.4.2)
129
+ activestorage (= 7.0.4.2)
130
+ activesupport (= 7.0.4.2)
131
+ bundler (>= 1.15.0)
132
+ railties (= 7.0.4.2)
133
+ rails-dom-testing (2.0.3)
134
+ activesupport (>= 4.2.0)
135
+ nokogiri (>= 1.6)
136
+ rails-html-sanitizer (1.5.0)
137
+ loofah (~> 2.19, >= 2.19.1)
138
+ railties (7.0.4.2)
139
+ actionpack (= 7.0.4.2)
140
+ activesupport (= 7.0.4.2)
141
+ method_source
142
+ rake (>= 12.2)
143
+ thor (~> 1.0)
144
+ zeitwerk (~> 2.5)
9
145
  rake (13.0.6)
146
+ thor (1.2.1)
147
+ timeout (0.3.1)
148
+ tzinfo (2.0.5)
149
+ concurrent-ruby (~> 1.0)
150
+ websocket-driver (0.7.5)
151
+ websocket-extensions (>= 0.1.0)
152
+ websocket-extensions (0.1.5)
153
+ zeitwerk (2.6.6)
10
154
 
11
155
  PLATFORMS
12
156
  arm64-darwin-21
@@ -26,10 +26,7 @@ Gem::Specification.new do |spec|
26
26
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
27
27
  end
28
28
  end
29
-
30
- # Uncomment to register a new dependency of your gem
31
- # spec.add_dependency "example-gem", "~> 1.0"
32
-
33
- # For more information and examples about making a new gem, check out our
34
- # guide at: https://bundler.io/guides/creating_gem.html
35
- end
29
+ spec.add_dependency 'railties', '~> 7.0.4', '>= 7.0.4.2'
30
+ spec.add_dependency 'execjs', '~> 2.8', '>= 2.8.1'
31
+ spec.add_dependency 'olive_branch', '~> 4.0', '>= 4.0.1'
32
+ end
data/exe/antd CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $LOAD_PATH.unshift("#{__dir__}/../lib")
4
-
5
4
  require 'ant/design/rails'
6
- puts Ant::Design::Rails.hi(ARGV[0])
5
+
6
+ # Todo: placeholder for project generation based on the template of https://github.com/pmq20/ant-design-rails
7
+ puts ::Ant::Design::Rails.hi(ARGV[0])
@@ -0,0 +1,17 @@
1
+ require 'olive_branch'
2
+
3
+ module Ant
4
+ module Design
5
+ module Rails
6
+ class Railtie < ::Rails::Railtie
7
+ initializer "ant_design_rails.configure_rails_initialization" do
8
+ ::Rails.application.middleware.use UmiDevProxy if ::Rails.env.development?
9
+ ::Rails.application.middleware.use OliveBranch::Middleware,
10
+ inflection: 'camel',
11
+ exclude_params: ->(env) { !env['PATH_INFO'].match(%r{^/api}) },
12
+ exclude_response: ->(env) { !env['PATH_INFO'].match(%r{^/api}) }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+ require 'execjs'
5
+
6
+ module Ant
7
+ module Design
8
+ module Rails
9
+ class Routes
10
+ include Enumerable
11
+ extend Forwardable
12
+ def_delegators :@result_array, :each, :<<
13
+
14
+ def initialize(routes_ts_path)
15
+ @body = File.read(routes_ts_path)
16
+ @result_array = ExecJS.eval(@body[start_of_json..end_of_json])
17
+ end
18
+
19
+ def start_of_json
20
+ @body.index('[')
21
+ end
22
+
23
+ def end_of_json
24
+ @body.rindex(']')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module ActionDispatch::Routing
32
+ class Mapper
33
+ def antd_pages(routes_ts_path)
34
+ antd_routes_reader = ::Ant::Design::Rails::Routes.new(routes_ts_path)
35
+ antd_api = {}
36
+ antd_routes_reader.each do |antd_route|
37
+ next if antd_route["path"] == "*"
38
+ antd_route_parse(antd_api, antd_route)
39
+ end
40
+ scope :api do
41
+ antd_api.each_value.map(&:call)
42
+ end
43
+ end
44
+
45
+ def antd_route_parse(antd_api, antd_route)
46
+ if antd_route["path"] == "/" && antd_route["redirect"].present?
47
+ root to: redirect(antd_route["redirect"])
48
+ elsif (antd_route["path"][0..4]) == "/api/" && (antd_route["path"][5..-1]).present?
49
+ antd_route_without_api = antd_route["path"][5..-1]
50
+ antd_api[antd_route_without_api] = antd_lambda(antd_route_without_api, antd_route)
51
+ end
52
+ # Recurse
53
+ antd_route['routes']&.each do |sub_antd_route|
54
+ antd_route_parse(antd_api, sub_antd_route)
55
+ end
56
+ end
57
+
58
+ def antd_lambda(antd_route_without_api, antd_route)
59
+ antd_route_parts = antd_route_without_api.split("/")
60
+ if antd_route["redirect"].present?
61
+ lambda { get antd_route_without_api, to: redirect(antd_route["redirect"]) }
62
+ elsif antd_route_parts.length == 1
63
+ lambda { get antd_route_without_api => "#{antd_route_parts.first.underscore}#index" }
64
+ else
65
+ lambda { get antd_route_without_api => "#{antd_route_parts.first.underscore}##{antd_route_parts[1..-1].join("_").underscore}" }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -3,7 +3,7 @@
3
3
  module Ant
4
4
  module Design
5
5
  module Rails
6
- VERSION = "0.0.1".freeze
6
+ VERSION = "0.2.0".freeze
7
7
  end
8
8
  end
9
9
  end
@@ -1,16 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "rails/version"
4
+ require_relative "rails/routes"
5
+ require_relative "rails/railties"
4
6
 
7
+ # Todo: placeholder methods for project generation based on the template of https://github.com/pmq20/ant-design-rails
5
8
  module Ant
6
9
  module Design
7
10
  module Rails
8
11
  class Error < StandardError; end
9
12
 
10
13
  def self.hi(language)
11
- puts "Hi #{language}"
14
+ puts "Todo: Hi #{language}"
12
15
  end
13
16
  end
14
17
  end
15
18
  end
16
-
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ant/design/rails"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ant-design-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minqi Pan
@@ -9,7 +9,67 @@ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
11
  date: 2023-01-27 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 7.0.4
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.0.4.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 7.0.4
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.0.4.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: execjs
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.8.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.8.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: olive_branch
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 4.0.1
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '4.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 4.0.1
13
73
  description: 'Ant Design on Rails: pairing world''s best backend framework with the
14
74
  best frontend framework, without wrapping everything in API!'
15
75
  email: pmq2001@gmail.com
@@ -20,9 +80,12 @@ files:
20
80
  - Gemfile
21
81
  - Gemfile.lock
22
82
  - Rakefile
83
+ - ant-design-rails.gemspec
23
84
  - exe/antd
24
- - hola.gemspec
85
+ - lib/ant-design-rails.rb
25
86
  - lib/ant/design/rails.rb
87
+ - lib/ant/design/rails/railties.rb
88
+ - lib/ant/design/rails/routes.rb
26
89
  - lib/ant/design/rails/version.rb
27
90
  homepage: https://github.com/pmq20/ant-design-rails
28
91
  licenses: