thecore_print_with_template 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f5425a69882e40d77258e551ee30cebe70248c64
4
+ data.tar.gz: 8a7909f77bf1b5a8f81ac2d87616d9c38428eb48
5
+ SHA512:
6
+ metadata.gz: 70aa597f3c8705bfa8c5616d6dda299884a63153ae6e30a5ea6baa2e4f410411e8d9660fc1662e35c70184cce3ce72228d6c0a6e3cdc8008aaf503fcdcf00e88
7
+ data.tar.gz: 453ba8d4bbdde8020e4054ad9567492cfdd18192af709a4302217b7b8b50a5b795ffeaf20af226d6771289b375a69deb23d368df6a191ab12fb4ea15fc566360
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Gabriele Tassoni
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # ThecorePrintWithTemplate
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'thecore_print_with_template'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install thecore_print_with_template
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ThecorePrintWithTemplate'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ load 'rails/tasks/statistics.rake'
18
+
19
+ require 'bundler/gem_tasks'
@@ -0,0 +1,51 @@
1
+ class PrintTemplate < ApplicationRecord
2
+ has_many :printers, inverse_of: :print_template
3
+
4
+ validates :name, presence: true
5
+ validates :template, presence: true
6
+
7
+ # def translate args
8
+ # # Rails.logger.info("COME CAZZO SEI FATTO? #{args.inspect}")
9
+ # temp = template.clone
10
+ # temp.gsub!("TEMPERATURE", args[:temperature].to_s)
11
+ # number_of_barcodes.times.with_index do |i|
12
+ # #Rails.logger.debug "MAMAMAMA! #{args[:items][i]}"
13
+ # item = (ChosenItem.find(args[:items][i]) rescue false)
14
+ # HashWithIndifferentAccess.new(YAML.load(translation_matrix)).each_pair do |k, v|
15
+ # Rails.logger.debug "ITEM: #{item.inspect} AND THE STRING: #{v}"
16
+ # temp.gsub!(k, item.is_a?(FalseClass) ? "" : v.split(".").inject(item, :send))
17
+ # end
18
+ # # Rails.logger.debug "MAMAMAMA! #{item.inspect}"
19
+ # # Se item è stringa vuota (quindi non ha .barcode), allora ritorna il campo FD remmato
20
+ # temp.gsub!("BARCODE#{i.to_s.rjust(2, '0')}", (item.barcode rescue "BARCODE#{i.to_s.rjust(2, '0')}"))
21
+ # end
22
+ # # Deleting the lines with BARCODE\d\d in them
23
+ # pivot = ""
24
+ # temp.each_line do |el|
25
+ # pivot += el if /BARCODE\d\d/.match(el).blank?
26
+ # end
27
+ # Rails.logger.info pivot
28
+ # pivot
29
+ # end
30
+
31
+ RailsAdmin.config do |config|
32
+ config.model 'PrintTemplate' do
33
+ navigation_label I18n.t("admin.settings.label")
34
+ navigation_icon 'fa fa-file-text'
35
+ parent Printer
36
+
37
+ field :name
38
+ field :description
39
+
40
+ edit do
41
+ field :template
42
+ field :translation_matrix
43
+ end
44
+
45
+ show do
46
+ field :template
47
+ field :translation_matrix
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,23 @@
1
+
2
+ require 'active_support/concern'
3
+
4
+ module ThecorePrintWithTemplateAbilitiesConcern
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ def thecore_print_with_template_abilities user
8
+ if user
9
+ # if the user is logged in, it can do certain tasks regardless his role
10
+ if user.admin?
11
+ # if the user is an admin, it can do a lot of things, usually
12
+ end
13
+
14
+ if user.has_role? :role
15
+ # a specific role, brings specific powers
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ # include the extension
23
+ TheCoreAbilities.send(:include, ThecorePrintWithTemplateAbilitiesConcern)
@@ -0,0 +1,6 @@
1
+
2
+ Rails.application.configure do
3
+ config.after_initialize do
4
+ Printer.send(:include, ThecorePrintWithTemplatePrinterConcern)
5
+ end
6
+ end
@@ -0,0 +1,14 @@
1
+ require 'active_support/concern'
2
+
3
+ module ThecorePrintWithTemplatePrinterConcern
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ belongs_to :print_template, inverse_of: :printers
7
+
8
+ RailsAdmin.config do |config|
9
+ config.model Printer do
10
+ field :print_template
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePrintTemplates < ActiveRecord::Migration[4.2]
2
+ def change
3
+ create_table :print_templates do |t|
4
+ t.string :name
5
+ t.text :description
6
+ t.text :template
7
+ t.text :translation_matrix
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddPrintTemplateIdToPrinter < ActiveRecord::Migration[4.2]
2
+ def change
3
+ add_reference :printers, :print_template, index: true, foreign_key: true
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :thecore_print_with_template do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require "thecore_print_with_template/engine"
2
+
3
+ require 'thecore'
4
+ require 'thecore_print_commons'
5
+ module ThecorePrintWithTemplate
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,14 @@
1
+ module ThecorePrintWithTemplate
2
+ class Engine < ::Rails::Engine
3
+
4
+ initializer 'thecore_print_with_template.add_to_migrations' do |app|
5
+ unless app.root.to_s == root.to_s
6
+ # APPEND TO MAIN APP MIGRATIONS FROM THIS GEM
7
+ config.paths['db/migrate'].expanded.each do |expanded_path|
8
+ app.config.paths['db/migrate'] << expanded_path
9
+ end
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module ThecorePrintWithTemplate
2
+ VERSION = '0.1.1'
3
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thecore_print_with_template
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Gabriele Tassoni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thecore
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thecore_print_commons
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ description: Thecorized thecore_print_with_template full description.
42
+ email:
43
+ - gabriele.tassoni@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/assets/config/thecore_print_with_template_manifest.js
52
+ - app/models/print_template.rb
53
+ - config/initializers/abilities_thecore_print_with_template_concern.rb
54
+ - config/initializers/after_initialize_for_thecore_print_with_template.rb
55
+ - config/initializers/thecore_print_with_template_printer_concern.rb
56
+ - config/locales/thecore_print_with_template.en.yml
57
+ - config/locales/thecore_print_with_template.it.yml
58
+ - config/routes.rb
59
+ - db/migrate/20160519093702_create_print_templates.rb
60
+ - db/migrate/20160519124051_add_print_template_id_to_printer.rb
61
+ - lib/tasks/thecore_print_with_template_tasks.rake
62
+ - lib/thecore_print_with_template.rb
63
+ - lib/thecore_print_with_template/engine.rb
64
+ - lib/thecore_print_with_template/version.rb
65
+ homepage: https://github.com/gabrieletassoni/thecore
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 2.6.14
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Thecorized thecore_print_with_template
89
+ test_files: []