bamboo_legals 0.0.1 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5015b767af2696eed60d7c0514ee76cac12c6dd7
4
- data.tar.gz: c07162bdf608efd53491092d2683676b1ef5d1d0
3
+ metadata.gz: 928113bb4a58d8824f2148c11de321a9d082a448
4
+ data.tar.gz: 497357ac00a05c577aaacaef87bf68b5e25d33e5
5
5
  SHA512:
6
- metadata.gz: fd76731d2f4e973a8dfadf3832401b52eda70e8a192586496bfa24b2ecfc26d14d8df5459dcd6266464d25855b31adbddedbe2841770d9f944c696d3e0ca9c2f
7
- data.tar.gz: 97400f3511dc8c7c2f1bbf34cc92b8acea2b45ec27cf774d6ca8c896ba13297858a956bcf8952a99c01f1aad8b79d0f5fe02b98aed3c9140a63b44b345af69ab
6
+ metadata.gz: a8c9cab594bacc8b84a46a69be08c77becd15fc9011de37e796a37e826ccbed3eb6b69e55a3ef078be64d1246a0f15ffe600711c67811cdb91f59480f8d46d2c
7
+ data.tar.gz: fd7f450405a6ecbbed3a853bf9f794265bd4f8f19d9cfe3e015fd914a7f5d9620e1f72e7d839b349115683a8b0ffd89fd4d357c3cbdf3236ae38ce728b084c15
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ unless File.exist?('./Rakefile') || File.exist?('./Gemfile')
4
+ abort 'Please run annotate from the root of the project.'
5
+ end
6
+
7
+ require 'rubygems'
8
+ begin
9
+ require 'bundler'
10
+ Bundler.setup
11
+ rescue StandardError
12
+ end
13
+
14
+ here = File.expand_path(File.dirname __FILE__)
15
+ $LOAD_PATH << "#{here}/../bamboo_legals_lib"
16
+
17
+ require_relative '../bamboo_legals_lib/bamboo_legals'
18
+
19
+ get_type = ARGV[0] || "monolingual"
20
+ run_generator(get_type)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboo_legals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mislav Kvesić
@@ -12,16 +12,12 @@ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: It should generate monolingual and multilingual legals for big_bamboom
14
14
  email: kvesic.mislav@gmail.com
15
- executables: []
15
+ executables:
16
+ - add_bamboo_legals
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
19
- - bamboo_legals_lib/generators/controller.rb
20
- - bamboo_legals_lib/generators/manual.rb
21
- - bamboo_legals_lib/generators/migration.rb
22
- - bamboo_legals_lib/generators/model.rb
23
- - bamboo_legals_lib/generators/routes.rb
24
- - bamboo_legals_lib/generators/views.rb
20
+ - bin/add_bamboo_legals
25
21
  homepage: https://rubygems.org/gems/bamboo_legals
26
22
  licenses:
27
23
  - MIT
@@ -29,7 +25,7 @@ metadata: {}
29
25
  post_install_message:
30
26
  rdoc_options: []
31
27
  require_paths:
32
- - lib
28
+ - bamboo_legals_lib
33
29
  required_ruby_version: !ruby/object:Gem::Requirement
34
30
  requirements:
35
31
  - - ">="
@@ -1,21 +0,0 @@
1
- def create_admin_controller(type)
2
- # find the legal controller
3
- controller_path = "app/controllers/admin/legals_controller.rb"
4
- template_controller_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/admin_legals_controller.txt"
5
-
6
- new_controller_text = File.open(template_controller_path).read
7
- File.write(controller_path, new_controller_text)
8
-
9
- puts "++ Created -> #{controller_path}"
10
- end
11
-
12
- def create_controller(type)
13
- # find the legal controller
14
- controller_path = "app/controllers/legals_controller.rb"
15
- template_controller_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legals_controller.txt"
16
-
17
- new_controller_text = File.open(template_controller_path).read
18
- File.write(controller_path, new_controller_text)
19
-
20
- puts "++ Created -> #{controller_path}"
21
- end
@@ -1,39 +0,0 @@
1
- def print_manual
2
- puts ""
3
- puts "++ Add locales"
4
- puts """
5
- admin_nav:
6
- legals: \"Legal Pages\"
7
-
8
- activerecord:
9
- attributes:
10
- legal:
11
- is_visible: \"Page is visible?\"
12
- title: \"Title\"
13
- content: \"Content\"
14
- created_at: \"Created at\"
15
- errors:
16
- models:
17
- legal:
18
- attributes:
19
- title:
20
- blank: \"Title can't be blank!\"
21
- content:
22
- blank: \"Content can't be blank!\"
23
- """
24
- puts ""
25
- puts "++ Add to app/views/layouts/admin/_navigation.html.erb"
26
- puts """
27
- <% if current_admin.permitted?(:legals) %>
28
- <%= active_link_to admin_legals_path, class: 'sidebar__link', active: :inclusive, class_active: 'active-link' do %>
29
- <%= inline_svg \"icons/nav/court.svg\", class: 'sidebar__icon', width: 16, height: 16 %>
30
- <%= t(\"admin_nav.legals\") %>
31
- <% end %>
32
- <% end %>
33
- """
34
- puts ""
35
- puts "++ Run"
36
- puts """
37
- rake db:migrate
38
- """
39
- end
@@ -1,21 +0,0 @@
1
- def overwrite_migration
2
- # find the legal migration
3
- migrations_path = "db/migrate/"
4
- migration_path = "#{migrations_path}#{Dir.entries(migrations_path).grep(/_create_legals.rb$/).first}"
5
-
6
- new_migration_text = ""
7
- migration = File.open(migration_path).read
8
- migration.each_line do |line|
9
- # add detault: true to migration
10
- if line.include?("t.boolean :is_visible")
11
- new_migration_text += " t.boolean :is_visible, default: true \n"
12
- else
13
- new_migration_text += line
14
- end
15
- end
16
-
17
- # rewrite the migration file
18
- File.write(migration_path, new_migration_text)
19
-
20
- puts "++ Changed -> #{migration_path}"
21
- end
@@ -1,20 +0,0 @@
1
- def overwrite_model(type)
2
- # find the legal model
3
- model_path = "app/models/legal.rb"
4
- template_model_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legal.txt"
5
-
6
- new_model_text = File.open(template_model_path).read
7
- File.write(model_path, new_model_text)
8
-
9
- puts "++ Changed -> #{model_path}"
10
-
11
- if type == "multilingual"
12
- model_translation_path = "app/models/legal_translation.rb"
13
- template_model_translation_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/legal_translation.txt"
14
-
15
- new_model_translation_text = File.open(template_model_translation_path).read
16
- File.write(model_translation_path, new_model_translation_text)
17
-
18
- puts "++ Changed -> #{model_translation_path}"
19
- end
20
- end
@@ -1,28 +0,0 @@
1
- def overwrite_routes
2
- # find the routes
3
- route_path = "config/routes.rb"
4
-
5
- # text that will overwrite namespace :admin do
6
- to_add = """ resources :legals, only: [:show]
7
- namespace :admin do
8
- resources :legals, except: [:show] do
9
- collection { patch :sort }
10
- end
11
- """
12
-
13
- new_routes_text = ""
14
- routes = File.open(route_path).read
15
- routes.each_line do |line|
16
- # add routes for legal
17
- if line.include?("namespace :admin do")
18
- new_routes_text += to_add
19
- else
20
- new_routes_text += line
21
- end
22
- end
23
-
24
- # rewrite the routes file
25
- File.write(route_path, new_routes_text)
26
-
27
- puts "++ Changed -> #{route_path}"
28
- end
@@ -1,37 +0,0 @@
1
- def create_admin_views(type)
2
- admin_view_dir_path = 'app/views/admin/legals/'
3
-
4
- # create directory for legal views in admin
5
- Dir.mkdir admin_view_dir_path
6
-
7
- # find all template views
8
- template_views_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/admin_views/"
9
- Dir.entries(template_views_path).each do |template|
10
- next if template == "." or template == ".."
11
-
12
- new_text = File.open("#{template_views_path}#{template}").read
13
- new_file_name = "#{admin_view_dir_path}#{template.split(".")[0]}.html.erb"
14
- File.write(new_file_name, new_text)
15
-
16
- puts "++ Created -> #{new_file_name}"
17
- end
18
- end
19
-
20
- def create_views(type)
21
- view_dir_path = 'app/views/legals/'
22
-
23
- # create directory for legal views
24
- Dir.mkdir view_dir_path
25
-
26
- # find all template views
27
- template_views_path = "bamboo_legals/bamboo_legals_lib/templates/#{type}/views/"
28
- Dir.entries(template_views_path).each do |template|
29
- next if template == "." or template == ".."
30
-
31
- new_text = File.open("#{template_views_path}#{template}").read
32
- new_file_name = "#{view_dir_path}#{template.split(".")[0]}.html.erb"
33
- File.write(new_file_name, new_text)
34
-
35
- puts "++ Created -> #{new_file_name}"
36
- end
37
- end