super_tools 0.0.5 → 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 +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +114 -19
- data/lib/super_formatter/ecan/row.rb +8 -0
- data/lib/super_tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e21771994fe2ec1175d5bcdc7c5b62b43d40efd
|
4
|
+
data.tar.gz: 536caa01f8d3315ff7479269cb286a92d279782c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9542660e093624d703c1e6b43c5d02870a0f3d3e6e3c75def353c9603511d3c6604db9061708475d96d867cd762847839f9c18e819a519b954c033229ad7e9cd
|
7
|
+
data.tar.gz: 163cc2df600e87ba9d26724bee3e7d3c4d00e9a20640275c6c36146ae42b10fc52e33fd392abb7840e7cda48294d266eb4856a51d91e076ee9578213636d5c52
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
super_tools (0.0.
|
4
|
+
super_tools (0.0.5)
|
5
5
|
dry-logic (~> 0.4.2)
|
6
6
|
dry-types (~> 0.13.2)
|
7
7
|
fast_excel
|
@@ -16,7 +16,7 @@ PATH
|
|
16
16
|
searchkick
|
17
17
|
spreadsheet
|
18
18
|
virtus (~> 1.0.5)
|
19
|
-
warehouse_items (~> 0.
|
19
|
+
warehouse_items (~> 0.3.0)
|
20
20
|
|
21
21
|
GEM
|
22
22
|
remote: https://rubygems.org/
|
@@ -207,7 +207,7 @@ GEM
|
|
207
207
|
coercible (~> 1.0)
|
208
208
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
209
209
|
equalizer (~> 0.0, >= 0.0.9)
|
210
|
-
warehouse_items (0.
|
210
|
+
warehouse_items (0.3.0)
|
211
211
|
activesupport
|
212
212
|
websocket-driver (0.6.5)
|
213
213
|
websocket-extensions (>= 0.1.0)
|
data/README.md
CHANGED
@@ -1,39 +1,134 @@
|
|
1
|
-
#
|
1
|
+
# SuperForm::Reform
|
2
2
|
|
3
|
-
|
3
|
+
```ruby
|
4
|
+
class MerchantForm::Edit < SuperForm::Reform
|
5
|
+
model :merchant
|
6
|
+
|
7
|
+
property :title, default: ''
|
8
|
+
property :contact, default: ''
|
9
|
+
end
|
10
|
+
|
11
|
+
```
|
4
12
|
|
5
|
-
|
13
|
+
# SuperLogger::Formatter
|
6
14
|
|
7
|
-
|
15
|
+
就是之前的 `LoggerFormatter`
|
8
16
|
|
9
|
-
|
17
|
+
# SuperProcess::Core
|
10
18
|
|
11
19
|
```ruby
|
12
|
-
|
20
|
+
class BillingCalculate < SuperProcess::Core
|
21
|
+
init :billing do
|
22
|
+
attribute :total_orders_amount, Integer
|
23
|
+
end
|
24
|
+
|
25
|
+
callable do
|
26
|
+
"RESULT_OBJECT"
|
27
|
+
end
|
28
|
+
|
29
|
+
def valid_amount
|
30
|
+
if total_orders_amount > 1000
|
31
|
+
errors.add(:total_orders_amount, "金額必須小於 1000 元")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
@service = BillingCalculate.new(@billing)
|
37
|
+
@service.call(total_orders_amount: "100")
|
38
|
+
#=> true
|
39
|
+
@service.total_orders_amount
|
40
|
+
#=> 100
|
41
|
+
@service.result
|
42
|
+
#=> "RESULT_OBJECT"
|
43
|
+
@service.error_messages
|
44
|
+
#=> ""
|
13
45
|
```
|
14
46
|
|
15
|
-
|
47
|
+
# SuperZipcode::Taiwan
|
16
48
|
|
17
|
-
|
49
|
+
```ruby
|
50
|
+
SuperZipcode::Taiwan.find_zip_code("高雄市鳳山區鳳甲一街129號")
|
51
|
+
#=> 830
|
52
|
+
```
|
18
53
|
|
19
|
-
|
54
|
+
# SuperTable
|
20
55
|
|
21
|
-
|
56
|
+
如需要 Rails URL helper 請於 initializers/suepr_table.rb 自行混入
|
22
57
|
|
23
|
-
|
58
|
+
```ruby
|
59
|
+
SuperTable::Builder.send(:include, ::Rails.application.routes.url_helpers)
|
60
|
+
SuperTable::Record.send(:include, ::Rails.application.routes.url_helpers)
|
61
|
+
SuperTable::Tableable.send(:include, ::Rails.application.routes.url_helpers)
|
62
|
+
```
|
24
63
|
|
25
|
-
|
64
|
+
# SuperSpreadsheet::Loader
|
26
65
|
|
27
|
-
|
66
|
+
```ruby
|
67
|
+
@spreadsheet = SuperSpreadsheet::Loader.new("/tmp/xxx.csv").tap { |s| s.call }
|
68
|
+
@spreadsheet = SuperSpreadsheet::Loader.new("/tmp/xxx.xls").tap { |s| s.call }
|
69
|
+
@spreadsheet = SuperSpreadsheet::Loader.new("/tmp/xxx.xlsx").tap { |s| s.call }
|
28
70
|
|
29
|
-
|
71
|
+
@spreadsheet.result
|
72
|
+
#=> [ [ '欄位1', '欄位2', '欄位3' ], [ '資料1', '資料2', '資料3'] ]
|
73
|
+
```
|
30
74
|
|
31
|
-
|
75
|
+
# SuperSearch::Scroll
|
32
76
|
|
33
|
-
|
77
|
+
```ruby
|
78
|
+
::SuperSearch::Scroll.new(Member, options: { where: { age: 20 } })
|
79
|
+
```
|
80
|
+
|
81
|
+
# SuperInteraction
|
82
|
+
|
83
|
+
### app/controllers/application_controller.rb
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
class ApplicationController < ActionController::Base
|
87
|
+
include SuperInteraction::ControllerHelper
|
88
|
+
end
|
89
|
+
```
|
34
90
|
|
35
|
-
|
91
|
+
### app/controllers/members_controller.rb
|
36
92
|
|
37
|
-
|
93
|
+
```ruby
|
94
|
+
class MembersController < ApplicationController
|
95
|
+
# GET /
|
96
|
+
def index
|
97
|
+
js.alert("Helloworld").reload.run
|
98
|
+
end
|
99
|
+
|
100
|
+
# GET /
|
101
|
+
def new
|
102
|
+
@member = Member.new
|
103
|
+
# View: app/views/members/edit.html.haml
|
104
|
+
# Layout: app/views/layouts/modal.html.haml
|
105
|
+
js.modal(partial: :edit).run
|
106
|
+
end
|
107
|
+
end
|
108
|
+
```
|
38
109
|
|
39
|
-
|
110
|
+
### app/views/layouts/modal.html.haml
|
111
|
+
|
112
|
+
```haml
|
113
|
+
.modal
|
114
|
+
= yield :wrapper
|
115
|
+
.modal-dialog{ class: "modal-#{bs_modal_size}" }
|
116
|
+
.modal-content
|
117
|
+
.modal-header
|
118
|
+
%button.close{"aria-label" => "Close", "data-dismiss" => "modal", :type => "button"}
|
119
|
+
= fa_icon('times')
|
120
|
+
= yield :header
|
121
|
+
- if title.present?
|
122
|
+
%h4.modal-title= title
|
123
|
+
= yield
|
124
|
+
= yield :before_body
|
125
|
+
- body_html = capture { yield :body }
|
126
|
+
- if body_html.present?
|
127
|
+
.modal-body= body_html
|
128
|
+
= yield :after_body
|
129
|
+
|
130
|
+
- footer_html = capture { yield :footer }
|
131
|
+
- if footer_html.present?
|
132
|
+
.modal-footer= footer_html
|
133
|
+
|
134
|
+
```
|
data/lib/super_tools/version.rb
CHANGED