view_component_storybook 0.3.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -11
  3. data/app/controllers/view_component/storybook/stories_controller.rb +3 -2
  4. data/app/views/view_component/storybook/stories/show.html.erb +3 -1
  5. data/config/locales/en.yml +32 -0
  6. data/lib/view_component/storybook.rb +2 -1
  7. data/lib/view_component/storybook/controls.rb +5 -1
  8. data/lib/view_component/storybook/controls/array_config.rb +9 -8
  9. data/lib/view_component/storybook/controls/boolean_config.rb +31 -0
  10. data/lib/view_component/storybook/controls/color_config.rb +26 -0
  11. data/lib/view_component/storybook/controls/control_config.rb +22 -26
  12. data/lib/view_component/storybook/controls/custom_config.rb +54 -0
  13. data/lib/view_component/storybook/controls/date_config.rb +14 -13
  14. data/lib/view_component/storybook/controls/number_config.rb +17 -16
  15. data/lib/view_component/storybook/controls/object_config.rb +11 -7
  16. data/lib/view_component/storybook/controls/options_config.rb +29 -7
  17. data/lib/view_component/storybook/controls/simple_control_config.rb +48 -0
  18. data/lib/view_component/storybook/controls/text_config.rb +13 -0
  19. data/lib/view_component/storybook/dsl.rb +1 -0
  20. data/lib/view_component/storybook/dsl/controls_dsl.rb +36 -46
  21. data/lib/view_component/storybook/dsl/legacy_controls_dsl.rb +98 -0
  22. data/lib/view_component/storybook/dsl/story_dsl.rb +17 -5
  23. data/lib/view_component/storybook/method_args.rb +16 -0
  24. data/lib/view_component/storybook/method_args/control_method_args.rb +88 -0
  25. data/lib/view_component/storybook/method_args/method_args.rb +19 -0
  26. data/lib/view_component/storybook/method_args/method_parameters_names.rb +97 -0
  27. data/lib/view_component/storybook/method_args/validatable_method_args.rb +50 -0
  28. data/lib/view_component/storybook/stories.rb +44 -7
  29. data/lib/view_component/storybook/story_config.rb +43 -9
  30. data/lib/view_component/storybook/tasks/write_stories_json.rake +6 -0
  31. data/lib/view_component/storybook/version.rb +1 -1
  32. metadata +43 -18
  33. data/lib/view_component/storybook/controls/simple_config.rb +0 -38
@@ -4,10 +4,16 @@ namespace :view_component_storybook do
4
4
  desc "Write CSF JSON stories for all Stories"
5
5
  task write_stories_json: :environment do
6
6
  puts "Writing Stories JSON"
7
+ exceptions = []
7
8
  ViewComponent::Storybook::Stories.all.each do |stories|
8
9
  json_path = stories.write_csf_json
9
10
  puts "#{stories.name} => #{json_path}"
11
+ rescue StandardError => e
12
+ exceptions << e
10
13
  end
14
+
15
+ raise StandardError, exceptions.map(:message).join(", ") if exceptions.present?
16
+
11
17
  puts "Done"
12
18
  end
13
19
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ViewComponent
4
4
  module Storybook
5
- VERSION = "0.3.0"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_storybook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-25 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: view_component
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '2.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '2.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -72,84 +72,98 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.9'
75
+ version: '3.10'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.9'
82
+ version: '3.10'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.9'
89
+ version: '5.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.9'
96
+ version: '5.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.81'
103
+ version: '1.18'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.81'
110
+ version: '1.18'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-rails
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 2.4.2
117
+ version: '2.11'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 2.4.2
124
+ version: '2.11'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop-rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.38'
131
+ version: '2.1'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.38'
138
+ version: '2.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.18.5
145
+ version: 0.21.2
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.21.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov-console
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.9'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 0.18.5
166
+ version: '0.9'
153
167
  description: Generate Storybook CSF JSON for rendering Rails View Components in Storybook
154
168
  email:
155
169
  - 328224+jonspalmer@users.noreply.github.com
@@ -161,19 +175,30 @@ files:
161
175
  - README.md
162
176
  - app/controllers/view_component/storybook/stories_controller.rb
163
177
  - app/views/view_component/storybook/stories/show.html.erb
178
+ - config/locales/en.yml
164
179
  - lib/view_component/storybook.rb
165
180
  - lib/view_component/storybook/controls.rb
166
181
  - lib/view_component/storybook/controls/array_config.rb
182
+ - lib/view_component/storybook/controls/boolean_config.rb
183
+ - lib/view_component/storybook/controls/color_config.rb
167
184
  - lib/view_component/storybook/controls/control_config.rb
185
+ - lib/view_component/storybook/controls/custom_config.rb
168
186
  - lib/view_component/storybook/controls/date_config.rb
169
187
  - lib/view_component/storybook/controls/number_config.rb
170
188
  - lib/view_component/storybook/controls/object_config.rb
171
189
  - lib/view_component/storybook/controls/options_config.rb
172
- - lib/view_component/storybook/controls/simple_config.rb
190
+ - lib/view_component/storybook/controls/simple_control_config.rb
191
+ - lib/view_component/storybook/controls/text_config.rb
173
192
  - lib/view_component/storybook/dsl.rb
174
193
  - lib/view_component/storybook/dsl/controls_dsl.rb
194
+ - lib/view_component/storybook/dsl/legacy_controls_dsl.rb
175
195
  - lib/view_component/storybook/dsl/story_dsl.rb
176
196
  - lib/view_component/storybook/engine.rb
197
+ - lib/view_component/storybook/method_args.rb
198
+ - lib/view_component/storybook/method_args/control_method_args.rb
199
+ - lib/view_component/storybook/method_args/method_args.rb
200
+ - lib/view_component/storybook/method_args/method_parameters_names.rb
201
+ - lib/view_component/storybook/method_args/validatable_method_args.rb
177
202
  - lib/view_component/storybook/stories.rb
178
203
  - lib/view_component/storybook/story_config.rb
179
204
  - lib/view_component/storybook/tasks/write_stories_json.rake
@@ -193,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
218
  requirements:
194
219
  - - ">="
195
220
  - !ruby/object:Gem::Version
196
- version: 2.3.0
221
+ version: 2.5.0
197
222
  required_rubygems_version: !ruby/object:Gem::Requirement
198
223
  requirements:
199
224
  - - ">="
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ViewComponent
4
- module Storybook
5
- module Controls
6
- class SimpleConfig < ControlConfig
7
- TYPES = %i[text boolean color].freeze
8
- BOOLEAN_VALUES = [true, false].freeze
9
-
10
- attr_reader :type
11
-
12
- validates :value, presence: true, unless: -> { type == :boolean }
13
- validates :value, inclusion: { in: BOOLEAN_VALUES }, if: -> { type == :boolean }
14
-
15
- validates :type, presence: true
16
- validates :type, inclusion: { in: TYPES }, unless: -> { type.nil? }
17
-
18
- def initialize(type, component, param, value, name: nil)
19
- super(component, param, value, name: name)
20
- @type = type
21
- end
22
-
23
- def value_from_param(param)
24
- if type == :boolean && param.is_a?(String) && param.present?
25
- case param
26
- when "true"
27
- true
28
- when "false"
29
- false
30
- end
31
- else
32
- super(param)
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end