c80_yax 0.1.0.2 → 0.1.0.3

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: 74f206b661d9c2327e4e9f26b94b7d787593230a
4
- data.tar.gz: 0b70a2734ea7e66e2ce0fcc72b52bbba1a1dffa7
3
+ metadata.gz: 7c1babe3e4c6239617ef6d4318770105186fb00c
4
+ data.tar.gz: 83a06df3d5a039cba4b75bb733fb4cdc610ba99c
5
5
  SHA512:
6
- metadata.gz: 8106e294dc7c8a9175cde3c26cbe0fc79d0d0f7a4f95ee4f2141270df3b0a476e201b15f58582026b44aa27ef6f3f00923ef4cbc373fc25dddd90801b9a380aa
7
- data.tar.gz: 7fa219ce73051ce3e0431feacbcffb0629d1cf9d45565d88deba6f75ebc88a280aa149b5699bfc41fe9d1dd3dfe33baf7c5c6c311c5a9635ee692675ac0d9a98
6
+ metadata.gz: 1daca052cdc67e37d9e18b4bef01eedd23d5c03b683386fd10006a7b06b3655c6f89a4dd40417e87cb4f0aca2a098f1652f0d886d210af49c95ff504e77d9d8a
7
+ data.tar.gz: 8221ce3523da4216eac3fd792e260a61a719682d4f133186e182465692f100f41f5eb4da70be1da3e05c91ea2a95a6d8067ea59f611cc7944d9955b61481db3b
@@ -15,6 +15,7 @@ module C80Yax
15
15
  # +item_as_hash+ это результат запроса к runtime таблице
16
16
 
17
17
  def get_props_parsed(strsubcat_id, item_as_hash)
18
+ Rails.logger.debug "[TRACE] <Parsable.get_props_parsed> self.name = #{self.name}, item_as_hash: #{item_as_hash}"
18
19
  rows = self.select_props_sql(strsubcat_id)
19
20
  meth = (self.name == 'C80Yax::PriceProp') ? '__parse_sql_price_props' : '__parse_sql_props'
20
21
  self.send(meth, rows, item_as_hash)
@@ -41,12 +42,15 @@ module C80Yax
41
42
  uoms: []
42
43
  }
43
44
 
44
- rows.each(:as => :hash) do |row|
45
+ if item_as_hash.size.zero?
46
+ Rails.logger.debug '[ERROR] <Parsable.__parse_sql_props> item_as_hash пуст.'
47
+ return result
48
+ end
45
49
 
50
+ rows.each(:as => :hash) do |row|
46
51
  result[:titles] << row['title']
47
- result[:values] << item_as_hash['prop_'+row['prop_name_id'].to_s]
52
+ result[:values] << item_as_hash["prop_#{row['prop_name_id']}"]
48
53
  result[:uoms] << row['uom_title']
49
-
50
54
  end
51
55
 
52
56
  result
@@ -66,7 +70,7 @@ module C80Yax
66
70
  # }
67
71
 
68
72
  def __parse_sql_price_props(rows, item_as_hash)
69
-
73
+ Rails.logger.debug '[TRACE] <Parsable.__parse_sql_price_props>'
70
74
  result = {
71
75
  titles: [],
72
76
  values: [],
@@ -74,6 +78,11 @@ module C80Yax
74
78
  uoms: []
75
79
  }
76
80
 
81
+ if item_as_hash.size.zero?
82
+ Rails.logger.debug '[ERROR] <Parsable.__parse_sql_props> item_as_hash пуст.'
83
+ return result
84
+ end
85
+
77
86
  rows.each(:as => :hash) do |row|
78
87
 
79
88
  if item_as_hash['prop_'+row['prop_name_id'].to_s].to_i != 0
@@ -4,8 +4,8 @@ module C80Yax
4
4
 
5
5
  # Админ создаёт вещь:
6
6
  # • в таблице типа str_111_items должна появиться строка, описывающая эту вещь
7
- def after_create(item)
8
- Rails.logger.debug "[TRACE] <ItemObserver.after_create> Создан предмет '#{item.title}'."
7
+ def after_commit(item)
8
+ Rails.logger.debug "[TRACE] <ItemObserver.after_commit> Создан предмет '#{item.title}'."
9
9
  StrsubcatRuntimeTables.table_check_and_build(item.strsubcat)
10
10
  StrsubcatRuntimeTables.table_fill(item.strsubcat.id) # TODO-5:: оптимизировать: не надо совершать операцию "заполнить таблицу", надо совершить операцию "вставлять в таблицу строку"
11
11
  end
@@ -16,6 +16,7 @@ module C80Yax
16
16
  # +--------------+--------------+--------------+---------------------------+-----------+
17
17
 
18
18
  def self.select_props_sql(strsubcat_id)
19
+ Rails.logger.debug "[TRACE] <MainProp.select_props_sql> strsubcat_id = #{strsubcat_id}"
19
20
  sql = "
20
21
  SELECT
21
22
  c80_yax_main_props.strsubcat_id,
@@ -16,6 +16,7 @@ module C80Yax
16
16
 
17
17
  # сформировать список main свойств предмета
18
18
  def main_props
19
+ Rails.logger.debug '[TRACE] <Item::Database.main_props>'
19
20
  C80Yax::MainProp.get_props_parsed(self.strsubcat_id, item_as_hash)
20
21
  end
21
22
 
@@ -5,6 +5,9 @@ module C80Yax
5
5
 
6
6
  process :resize_to_limit => [1024,768]
7
7
 
8
+ # накладываем watermark
9
+ process :watermark => [Rails.root.join('public/watermark.png')]
10
+
8
11
  version :thumb_sm do
9
12
  begin
10
13
  p = C80Yax::Prop.first
@@ -32,6 +35,11 @@ module C80Yax
32
35
  end
33
36
  end
34
37
 
38
+ def watermark(watermark_image, options={})
39
+ cache_stored_file! unless cached?
40
+ C80Yax::Watermarker.new(current_path, watermark_image).watermark!(options)
41
+ end
42
+
35
43
  def store_dir
36
44
  'uploads/items'
37
45
  end
data/c80_yax.gemspec CHANGED
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "byebug"
26
26
  spec.add_dependency 'activesupport', ['>= 3.0.0']
27
27
  spec.add_dependency 'rails-observers'
28
+ spec.add_dependency 'mini_magick'
28
29
 
29
30
  end
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.2'
2
+ VERSION = '0.1.0.3'
3
3
  end
@@ -0,0 +1,24 @@
1
+ module C80Yax
2
+ class Watermarker
3
+
4
+ def initialize(original_path, watermark_path)
5
+ @original_path = original_path.to_s
6
+ @watermark_path = watermark_path.to_s
7
+ end
8
+
9
+ def watermark!(options={})
10
+ options[:gravity] ||= 'center'
11
+
12
+ image = MiniMagick::Image.open(@original_path)
13
+ watermark_image = MiniMagick::Image.open(@watermark_path)
14
+
15
+ result = image.composite(watermark_image) do |c|
16
+ c.gravity options[:gravity]
17
+ end
18
+
19
+ result.write @original_path
20
+
21
+ end
22
+
23
+ end
24
+ end
data/lib/c80_yax.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'c80_yax/version'
2
2
  require 'c80_yax/engine'
3
3
  require 'c80_yax/strsubcat_runtime_tables'
4
+ require 'c80_yax/watermarker'
4
5
  require 'rails-observers'
6
+ require 'mini_magick'
5
7
 
6
8
  module C80Yax
7
9
  def self.table_name_prefix
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_yax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.2
4
+ version: 0.1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mini_magick
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Gem adds yax to site
98
112
  email:
99
113
  - c080609a@gmail.com
@@ -200,6 +214,7 @@ files:
200
214
  - lib/c80_yax/engine.rb
201
215
  - lib/c80_yax/strsubcat_runtime_tables.rb
202
216
  - lib/c80_yax/version.rb
217
+ - lib/c80_yax/watermarker.rb
203
218
  - lib/generators/c80_yax/install_generator.rb
204
219
  - lib/generators/c80_yax/templates/app/helpers/c80_yax/items/show_item_helper.rb
205
220
  homepage: https://github.com/c080609a/c80_yax