hot-glue 0.4.1 → 0.4.2

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: d49dfdd41bc05a338dea0a64271e490d8eba74367c288d9a63083e670d170f8c
4
- data.tar.gz: 6d9f6b0a85c4b9e9445351872d0da7619c0321d769e7f92555bf0743aafbc475
3
+ metadata.gz: ea01452aae7ac4063616c9d520839fcec9b652ed8175aa458688d345b13084d5
4
+ data.tar.gz: d4a13d7de5bbca528115f0d206e084a6398e39e3fa18c543b56dce657c31e94f
5
5
  SHA512:
6
- metadata.gz: 7561e146c38b1d58c08f1ef8662224124177749ee23740d4422fc88027f1a2ad903a4c812919a960144ba9e1439834fcad1037648e0baec001a312b4765a90c3
7
- data.tar.gz: 77727cf6fb916de0cc487753dbbde345f3c1ab9263040575c41725f26ac13f6c75e0f26c016d5d5ac5a85d15378fa4b3f9fa893b9ad517a435a6fd60b3da3694
6
+ metadata.gz: 7484282af3627e8e8fdb519b90a56fee40db2a0cab7677c5b3429bd36e64307ce4fb96481c40d04c3aa03960c6113a5ab69e567a1eca9e50ee628fa0450d437d
7
+ data.tar.gz: 49b764d7f47a86c595c75859af621eb69abd1796b1041e6e8e331203e7228f4510c9595584eab1577c2e7267d1cb6c75d7216d391ad9e2b70a6e6baaa3c7b76a
data/Gemfile CHANGED
@@ -4,13 +4,13 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
4
  gemspec
5
5
 
6
6
  # not required for your app
7
- gem 'sqlite3'
7
+ gem 'pg'
8
8
  gem 'byebug'
9
- gem 'rails', '6.1'
9
+ gem 'rails'
10
10
  gem 'devise', require: true
11
11
 
12
-
13
12
  # for testing
14
13
  gem "rails-controller-testing", group: [:test]
15
14
  gem "database_cleaner", group: [:test]
16
- gem "rspec-rails", group: [:test]
15
+ gem "rspec-rails", group: [:test]
16
+ gem "factory_bot", group: [:test]
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.3.9)
4
+ hot-glue (0.4.1)
5
5
  ffaker (~> 2.16)
6
6
  kaminari (~> 1.2)
7
- rails (> 5.1, <= 7.0.0)
7
+ rails (> 5.1, <= 7)
8
8
  sass-rails
9
- turbo-rails (> 0.5)
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
@@ -89,24 +88,26 @@ GEM
89
88
  warden (~> 1.2.3)
90
89
  diff-lcs (1.4.4)
91
90
  erubi (1.10.0)
91
+ factory_bot (6.2.0)
92
+ activesupport (>= 5.0.0)
92
93
  ffaker (2.20.0)
93
94
  ffi (1.15.4)
94
95
  globalid (0.4.2)
95
96
  activesupport (>= 4.2.0)
96
97
  i18n (1.8.10)
97
98
  concurrent-ruby (~> 1.0)
98
- kaminari (1.2.1)
99
+ kaminari (1.2.2)
99
100
  activesupport (>= 4.1.0)
100
- kaminari-actionview (= 1.2.1)
101
- kaminari-activerecord (= 1.2.1)
102
- kaminari-core (= 1.2.1)
103
- kaminari-actionview (1.2.1)
101
+ kaminari-actionview (= 1.2.2)
102
+ kaminari-activerecord (= 1.2.2)
103
+ kaminari-core (= 1.2.2)
104
+ kaminari-actionview (1.2.2)
104
105
  actionview
105
- kaminari-core (= 1.2.1)
106
- kaminari-activerecord (1.2.1)
106
+ kaminari-core (= 1.2.2)
107
+ kaminari-activerecord (1.2.2)
107
108
  activerecord
108
- kaminari-core (= 1.2.1)
109
- kaminari-core (1.2.1)
109
+ kaminari-core (= 1.2.2)
110
+ kaminari-core (1.2.2)
110
111
  loofah (2.10.0)
111
112
  crass (~> 1.0.2)
112
113
  nokogiri (>= 1.5.9)
@@ -126,6 +127,7 @@ GEM
126
127
  mini_portile2 (~> 2.5.0)
127
128
  racc (~> 1.4)
128
129
  orm_adapter (0.5.0)
130
+ pg (1.2.3)
129
131
  racc (1.5.2)
130
132
  rack (2.2.3)
131
133
  rack-test (1.1.0)
@@ -198,11 +200,8 @@ GEM
198
200
  actionpack (>= 4.0)
199
201
  activesupport (>= 4.0)
200
202
  sprockets (>= 3.0.0)
201
- sqlite3 (1.4.2)
202
203
  thor (1.1.0)
203
204
  tilt (2.0.10)
204
- turbo-rails (7.1.1)
205
- rails (>= 6.0.0)
206
205
  tzinfo (2.0.4)
207
206
  concurrent-ruby (~> 1.0)
208
207
  warden (1.2.9)
@@ -220,11 +219,12 @@ DEPENDENCIES
220
219
  byebug
221
220
  database_cleaner
222
221
  devise
222
+ factory_bot
223
223
  hot-glue!
224
- rails (= 6.1)
224
+ pg
225
+ rails
225
226
  rails-controller-testing
226
227
  rspec-rails
227
- sqlite3
228
228
 
229
229
  BUNDLED WITH
230
230
  2.1.4
data/README.md CHANGED
@@ -0,0 +1,30 @@
1
+ # HOW THIS GEM IS TESTED
2
+
3
+ SETUP:
4
+ • Run bundle install
5
+ • if you can't get through see https://stackoverflow.com/questions/68050807/gem-install-mimemagic-v-0-3-10-fails-to-install-on-big-sur/68170982#68170982
6
+
7
+
8
+ The dummy sandbox is found at `spec/dummy`
9
+
10
+ The dummy sandbox lives as mostly checked- into the repository, **except** the folders where the generated code goes (`spec/dummy/app/views/`, `spec/dummy/app/controllers/`, `spec/dummy/specs/` are excluded from Git)
11
+
12
+ When you run the **internal specs**, which you can do **at the root of this repo** using the command `rspec`, a set of specs will run to assert the generators are erroring when they are supposed to and producing code when they are supposed to.
13
+
14
+ The DUMMY testing DOES NOT test the actual functionality of the output code (it just tests the functionality of the generation process).
15
+
16
+
17
+ # DATABASE
18
+
19
+ `cd spec/dummy`
20
+ `rails db:drop`
21
+ `rails db:create`
22
+ `rails db:migrate`
23
+ `RAILS_ENV=test rails db:migrate`
24
+
25
+ `cd ../..`
26
+
27
+ take note that when running the spec at the root of the repo you are initializing the Dummy app, which will use the
28
+ SQLite database in spec/dummy/database/
29
+
30
+
data/config/database.yml CHANGED
@@ -1,11 +1,86 @@
1
+ # PostgreSQL. Versions 9.3 and up are supported.
2
+ #
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On macOS with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On macOS with MacPorts:
8
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
+ # On Windows:
10
+ # gem install pg
11
+ # Choose the win32 build.
12
+ # Install PostgreSQL and put its /bin directory on your path.
13
+ #
14
+ # Configure Using Gemfile
15
+ # gem 'pg'
16
+ #
17
+ default: &default
18
+ adapter: postgresql
19
+ encoding: unicode
20
+ # For details on connection pooling, see Rails configuration guide
21
+ # https://guides.rubyonrails.org/configuring.html#database-pooling
22
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23
+
1
24
  development:
2
- adapter: sqlite3
3
- database: ../spec/dummy/db/development.sqlite3
4
- pool: 5
5
- timeout: 5000
25
+ <<: *default
26
+ database: Dummy_development
27
+
28
+ # The specified database role being used to connect to postgres.
29
+ # To create additional roles in postgres see `$ createuser --help`.
30
+ # When left blank, postgres will use the default role. This is
31
+ # the same name as the operating system user running Rails.
32
+ #username: Dummy
33
+
34
+ # The password associated with the postgres role (username).
35
+ #password:
36
+
37
+ # Connect on a TCP socket. Omitted by default since the client uses a
38
+ # domain socket that doesn't need configuration. Windows does not have
39
+ # domain sockets, so uncomment these lines.
40
+ #host: localhost
6
41
 
42
+ # The TCP port the server listens on. Defaults to 5432.
43
+ # If your server runs on a different port number, change accordingly.
44
+ #port: 5432
45
+
46
+ # Schema search path. The server defaults to $user,public
47
+ #schema_search_path: myapp,sharedapp,public
48
+
49
+ # Minimum log levels, in increasing order:
50
+ # debug5, debug4, debug3, debug2, debug1,
51
+ # log, notice, warning, error, fatal, and panic
52
+ # Defaults to warning.
53
+ #min_messages: notice
54
+
55
+ # Warning: The database defined as "test" will be erased and
56
+ # re-generated from your development database when you run "rake".
57
+ # Do not set this db to the same as development or production.
7
58
  test:
8
- adapter: sqlite3
9
- database: ../spec/dummy/db/test.sqlite3
10
- pool: 5
11
- timeout: 5000
59
+ <<: *default
60
+ database: Dummy_test
61
+
62
+ # As with config/credentials.yml, you never want to store sensitive information,
63
+ # like your database password, in your source code. If your source code is
64
+ # ever seen by anyone, they now have access to your database.
65
+ #
66
+ # Instead, provide the password or a full connection URL as an environment
67
+ # variable when you boot the app. For example:
68
+ #
69
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
70
+ #
71
+ # If the connection URL is provided in the special DATABASE_URL environment
72
+ # variable, Rails will automatically merge its configuration values on top of
73
+ # the values provided in this file. Alternatively, you can specify a connection
74
+ # URL environment variable explicitly:
75
+ #
76
+ # production:
77
+ # url: <%= ENV['MY_APP_DATABASE_URL'] %>
78
+ #
79
+ # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
80
+ # for a full overview on how database connection configuration can be specified.
81
+ #
82
+ production:
83
+ <<: *default
84
+ database: Dummy_production
85
+ username: Dummy
86
+ password: <%= ENV['DUMMY_DATABASE_PASSWORD'] %>
@@ -0,0 +1,3 @@
1
+ ---
2
+ :layout: hotglue
3
+ :markup: erb
data/db/schema.rb CHANGED
@@ -15,12 +15,12 @@ ActiveRecord::Schema.define(version: 2021_03_06_225506) do
15
15
  create_table "abcs", force: :cascade do |t|
16
16
  t.integer "xxx"
17
17
  t.string "yyy"
18
- t.integer "def_id"
18
+ t.integer "dfg_id"
19
19
  t.datetime "created_at", precision: 6, null: false
20
20
  t.datetime "updated_at", precision: 6, null: false
21
21
  end
22
22
 
23
- create_table "defs", force: :cascade do |t|
23
+ create_table "dfg", force: :cascade do |t|
24
24
  t.integer "user_id"
25
25
  t.string "name"
26
26
  t.datetime "created_at", precision: 6, null: false
@@ -28,7 +28,7 @@ ActiveRecord::Schema.define(version: 2021_03_06_225506) do
28
28
  end
29
29
 
30
30
  create_table "ghis", force: :cascade do |t|
31
- t.integer "def_id"
31
+ t.integer "dfg_id"
32
32
  t.datetime "created_at", precision: 6, null: false
33
33
  t.datetime "updated_at", precision: 6, null: false
34
34
  end
@@ -17,7 +17,7 @@ module HotGlue
17
17
 
18
18
  if @layout == "hotglue" && options['theme'].nil?
19
19
  puts "You have selected to install Hot Glue without a theme. You can either use the --layout=bootstrap to install NO HOT GLUE THEME, or to use a Hot Glue theme please choose: like_boostrap, like_menlo_park, like_cupertino, like_mountain_view, dark_knight"
20
- exit
20
+ return
21
21
  end
22
22
 
23
23
  if @layout == 'boostrap'
@@ -40,7 +40,7 @@ module HotGlue
40
40
 
41
41
  if (license_should_be != license_activation_key)
42
42
  puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
43
- exit
43
+ return
44
44
  end
45
45
  end
46
46
 
@@ -0,0 +1,115 @@
1
+
2
+
3
+ module HotGlue
4
+ module Layout
5
+ class Builder
6
+ attr_reader :include_setting, :downnest_children, :no_edit, :no_delete, :columns, :smart_layout
7
+
8
+ def initialize(params)
9
+ @include_setting = params[:include_setting]
10
+ @downnest_children = params[:downnest_children]
11
+ @no_edit = params[:no_edit]
12
+ @no_delete = params[:no_delete]
13
+ @columns = params[:columns]
14
+ @smart_layout = params[:smart_layout]
15
+ end
16
+
17
+ def construct
18
+ layout_object = {
19
+ columns: {
20
+ size_each: nil,
21
+ container: [] # array of arrays
22
+ },
23
+ portals: {
24
+
25
+ },
26
+ buttons: { size: ''}
27
+ }
28
+
29
+ downnest_children.each do |child|
30
+ layout_object[:portals][child] = {size: 4}
31
+ end
32
+
33
+ # smart layout: 2 columns per field; 4 column for EACH downnested portals, 2 column for buttons
34
+ how_many_downnest = downnest_children.size
35
+ button_column_size = (no_edit && no_delete) ? 0 : 2
36
+
37
+ bootstrap_columns = (12-button_column_size)
38
+ bootstrap_columns = bootstrap_columns - (how_many_downnest*4)
39
+ available_columns = (bootstrap_columns / 2).floor # bascially turns the 12-column grid into a 6-column grid
40
+
41
+ if available_columns < 0
42
+ raise "Cannot build layout with #{how_many_downnest} downnested portals"
43
+ end
44
+
45
+ @downnest_children_width = []
46
+ @downnest_children.each_with_index{ |child, i| @downnest_children_width[i] = 4}
47
+
48
+ if include_setting.nil?
49
+
50
+ end
51
+
52
+ if smart_layout
53
+ # automatic control
54
+ #
55
+
56
+ if columns.size > available_columns
57
+ each_col_can_have = (columns.size.to_f / available_columns.to_f).round
58
+ # byebug
59
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
60
+ columns.slice(0+(x*each_col_can_have),each_col_can_have)
61
+ }
62
+ layout_object[:columns][:container].last.append *columns.slice(0+(available_columns*each_col_can_have),each_col_can_have)
63
+
64
+ else
65
+ layout_object[:columns][:container] = (0..available_columns-1).collect { |x|
66
+ [ columns[x]]
67
+ }
68
+ layout_object[:columns][:container].reject!{|x| x == [nil]}
69
+ end
70
+ elsif !include_setting.include?(":")
71
+ layout_object[:columns][:container] = columns.collect{|col| [col]}
72
+
73
+ else
74
+ (0..available_columns-1).each do |int|
75
+ layout_object[:columns][:container][int] = []
76
+ end
77
+
78
+ # input control
79
+ user_layout_columns = options['include'].split(":")
80
+
81
+ if user_layout_columns.size > available_columns
82
+ raise "Your include statement #{options['include']} has #{user_layout_columns.size} columns, but I can only construct up to #{available_columns}"
83
+ end
84
+ user_layout_columns.each_with_index do |column,i|
85
+ layout_object[:columns][:container][i] = column.split(",")
86
+ end
87
+
88
+ if user_layout_columns.size < layout_object[:columns][:container].size
89
+ layout_object[:columns][:container].reject!{|x| x == []}
90
+ end
91
+ end
92
+
93
+ if layout_object[:columns][:container].size < available_columns
94
+ available = available_columns - layout_object[:columns][:container].size
95
+ downnest_child_count = 0
96
+
97
+ while(available > 0)
98
+ if (downnest_child_count <= downnest_children.size-1)
99
+ layout_object[:portals][downnest_children[downnest_child_count]][:size] = layout_object[:portals][downnest_children[downnest_child_count]][:size] + 2
100
+ else
101
+ # leave as-is
102
+ end
103
+ downnest_child_count = downnest_child_count + 1
104
+ available = available - 1
105
+ end
106
+ # give some space back to the downnest
107
+ end
108
+
109
+ puts "*** constructed layout columns #{layout_object.inspect}"
110
+ layout_object
111
+ end
112
+
113
+ end
114
+ end
115
+ end