middleman_mynewsdesk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17fd1e4f744f452cef72c0434394330251a3751c
4
+ data.tar.gz: 72c2e3ac8c8849d5293db6a19cd0c2afee36ea4a
5
+ SHA512:
6
+ metadata.gz: 69c2b45791a18342d049b91aecb50298eb413899bdce3a193ce366661630f6373b3591168c1b4939c297ad895a52ef0d834e400d1c5b8f4c558badfcca3194de
7
+ data.tar.gz: c2280b1ff7fb325dd268f3715b470e091c659a0b4b464057ad33097e6cc6b9774ea2686e8c1276f4d1c8315e7412e6c816752ad634a427dad4c49f88c777bb52
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ # Ignore bundler lock file
2
+ /Gemfile.lock
3
+
4
+ # Ignore pkg folder
5
+ /pkg
data/.rubocop.yml ADDED
@@ -0,0 +1,362 @@
1
+ # See https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+ Rails:
3
+ Enabled: true
4
+
5
+ Documentation:
6
+ Enabled: false
7
+
8
+ Metrics/ClassLength:
9
+ Max: 300
10
+
11
+ Metrics/ModuleLength:
12
+ Max: 300
13
+
14
+ Metrics/MethodLength:
15
+ Max: 25
16
+
17
+ Style/StringLiterals:
18
+ EnforcedStyle: double_quotes
19
+
20
+ Layout/AccessModifierIndentation:
21
+ EnforcedStyle: indent
22
+
23
+ Style/Alias:
24
+ EnforcedStyle: prefer_alias_method
25
+
26
+ Layout/AlignHash:
27
+ EnforcedHashRocketStyle: key
28
+ EnforcedColonStyle: key
29
+ EnforcedLastArgumentHashStyle: always_inspect
30
+
31
+ Layout/AlignParameters:
32
+ EnforcedStyle: with_fixed_indentation
33
+
34
+ Style/AndOr:
35
+ EnforcedStyle: conditionals
36
+
37
+ Style/BlockDelimiters:
38
+ EnforcedStyle: line_count_based
39
+
40
+ Style/BracesAroundHashParameters:
41
+ EnforcedStyle: no_braces
42
+
43
+ Layout/CaseIndentation:
44
+ EnforcedStyle: end
45
+
46
+ Layout/BlockAlignment:
47
+ EnforcedStyleAlignWith: start_of_line
48
+
49
+ Layout/DefEndAlignment:
50
+ EnforcedStyleAlignWith: start_of_line
51
+
52
+ Layout/EndAlignment:
53
+ EnforcedStyleAlignWith: start_of_line
54
+
55
+ Style/ClassAndModuleChildren:
56
+ EnforcedStyle: nested
57
+
58
+ Style/ClassCheck:
59
+ EnforcedStyle: is_a?
60
+
61
+ Style/CollectionMethods:
62
+ PreferredMethods:
63
+ collect: "map"
64
+ collect!: "map!"
65
+ inject: "reduce"
66
+ detect: "find"
67
+ find_all: "select"
68
+
69
+ Style/CommandLiteral:
70
+ EnforcedStyle: percent_x
71
+ AllowInnerBackticks: false
72
+
73
+ Style/CommentAnnotation:
74
+ Keywords:
75
+ - TODO
76
+ - FIXME
77
+ - OPTIMIZE
78
+ - HACK
79
+ - REVIEW
80
+
81
+ Layout/DotPosition:
82
+ EnforcedStyle: leading
83
+
84
+ Style/EmptyElse:
85
+ EnforcedStyle: both
86
+
87
+ Layout/EmptyLinesAroundBlockBody:
88
+ EnforcedStyle: no_empty_lines
89
+
90
+ Layout/EmptyLinesAroundClassBody:
91
+ EnforcedStyle: no_empty_lines
92
+
93
+ Layout/EmptyLinesAroundModuleBody:
94
+ EnforcedStyle: no_empty_lines
95
+
96
+ Style/EmptyMethod:
97
+ EnforcedStyle: expanded
98
+
99
+ Layout/ExtraSpacing:
100
+ AllowForAlignment: true
101
+
102
+ Style/For:
103
+ EnforcedStyle: each
104
+
105
+ Style/FormatString:
106
+ EnforcedStyle: format
107
+
108
+ Style/GlobalVars:
109
+ AllowedVariables:
110
+ - autogen_filepath
111
+ - autogen_buffer
112
+
113
+ Style/HashSyntax:
114
+ EnforcedStyle: ruby19_no_mixed_keys
115
+
116
+ Layout/IndentationConsistency:
117
+ EnforcedStyle: normal
118
+
119
+ Layout/IndentationWidth:
120
+ Width: 2
121
+
122
+ Style/Lambda:
123
+ EnforcedStyle: line_count_dependent
124
+
125
+ Layout/SpaceInLambdaLiteral:
126
+ EnforcedStyle: require_space
127
+
128
+ Style/LambdaCall:
129
+ EnforcedStyle: braces
130
+
131
+ Style/MethodDefParentheses:
132
+ EnforcedStyle: require_parentheses
133
+
134
+ Naming/MethodName:
135
+ EnforcedStyle: snake_case
136
+
137
+ Style/ModuleFunction:
138
+ EnforcedStyle: module_function
139
+
140
+ Layout/MultilineArrayBraceLayout:
141
+ EnforcedStyle: symmetrical
142
+
143
+ Layout/MultilineHashBraceLayout:
144
+ EnforcedStyle: new_line
145
+
146
+ Layout/MultilineMethodCallBraceLayout:
147
+ EnforcedStyle: symmetrical
148
+
149
+ Layout/MultilineMethodDefinitionBraceLayout:
150
+ EnforcedStyle: new_line
151
+
152
+ Style/NonNilCheck:
153
+ IncludeSemanticChanges: true
154
+
155
+ Style/ParenthesesAroundCondition:
156
+ AllowSafeAssignment: true
157
+
158
+ Style/PercentLiteralDelimiters:
159
+ PreferredDelimiters:
160
+ default: ()
161
+ "%i": "[]"
162
+ "%I": "[]"
163
+ "%r": "{}"
164
+ "%w": "[]"
165
+ "%W": "[]"
166
+ "%Q": "{}"
167
+
168
+ Style/PercentQLiterals:
169
+ EnforcedStyle: upper_case_q
170
+
171
+ Style/RaiseArgs:
172
+ EnforcedStyle: exploded
173
+
174
+ Style/RedundantReturn:
175
+ AllowMultipleReturnValues: false
176
+
177
+ Style/RegexpLiteral:
178
+ EnforcedStyle: slashes
179
+ AllowInnerSlashes: false
180
+
181
+ Style/Semicolon:
182
+ AllowAsExpressionSeparator: false
183
+
184
+ Style/SingleLineBlockParams:
185
+ Methods:
186
+ - reduce:
187
+ - acc
188
+ - elem
189
+ - inject:
190
+ - acc
191
+ - elem
192
+
193
+ Style/FrozenStringLiteralComment:
194
+ EnforcedStyle: when_needed
195
+
196
+ Style/SingleLineMethods:
197
+ AllowIfMethodIsEmpty: false
198
+
199
+ Layout/SpaceAroundBlockParameters:
200
+ EnforcedStyleInsidePipes: no_space
201
+
202
+ Layout/SpaceAroundEqualsInParameterDefault:
203
+ EnforcedStyle: space
204
+
205
+ Layout/SpaceBeforeBlockBraces:
206
+ EnforcedStyle: space
207
+
208
+ Layout/SpaceInsideBlockBraces:
209
+ EnforcedStyle: space
210
+
211
+ Layout/SpaceInsideHashLiteralBraces:
212
+ EnforcedStyle: space
213
+ EnforcedStyleForEmptyBraces: no_space
214
+
215
+ Layout/SpaceInsideStringInterpolation:
216
+ EnforcedStyle: no_space
217
+
218
+ Style/SpecialGlobalVars:
219
+ EnforcedStyle: use_english_names
220
+
221
+ Style/StabbyLambdaParentheses:
222
+ EnforcedStyle: require_parentheses
223
+
224
+ Style/StringLiterals:
225
+ EnforcedStyle: double_quotes
226
+
227
+ Style/StringLiteralsInInterpolation:
228
+ EnforcedStyle: double_quotes
229
+
230
+ Style/StringMethods:
231
+ PreferredMethods:
232
+ intern: to_sym
233
+
234
+ Style/BarePercentLiterals:
235
+ EnforcedStyle: percent_q
236
+
237
+ Style/SymbolArray:
238
+ EnforcedStyle: percent
239
+
240
+ Style/TernaryParentheses:
241
+ EnforcedStyle: require_no_parentheses
242
+
243
+ Layout/TrailingBlankLines:
244
+ EnforcedStyle: final_newline
245
+
246
+ Style/TrailingCommaInArguments:
247
+ EnforcedStyleForMultiline: no_comma
248
+
249
+ Style/TrailingCommaInArrayLiteral:
250
+ EnforcedStyleForMultiline: no_comma
251
+
252
+ Style/TrailingCommaInHashLiteral:
253
+ EnforcedStyleForMultiline: no_comma
254
+
255
+ Naming/VariableName:
256
+ EnforcedStyle: snake_case
257
+
258
+ Naming/VariableNumber:
259
+ EnforcedStyle: snake_case
260
+
261
+ Style/WordArray:
262
+ EnforcedStyle: percent
263
+
264
+ Style/GuardClause:
265
+ Enabled: false
266
+
267
+ Layout/MultilineMethodCallIndentation:
268
+ EnforcedStyle: indented
269
+
270
+ Metrics/LineLength:
271
+ Max: 120
272
+ AllowHeredoc: true
273
+ AllowURI: true
274
+ URISchemes:
275
+ - http
276
+ - https
277
+
278
+ Lint/AssignmentInCondition:
279
+ AllowSafeAssignment: true
280
+
281
+ Lint/UnusedBlockArgument:
282
+ AllowUnusedKeywordArguments: false
283
+
284
+ Lint/UnusedMethodArgument:
285
+ AllowUnusedKeywordArguments: false
286
+
287
+ Rails/Date:
288
+ EnforcedStyle: strict
289
+
290
+ Rails/TimeZone:
291
+ EnforcedStyle: flexible
292
+
293
+ Rails/NotNullColumn:
294
+ Include:
295
+ - db/migrate/*.rb
296
+
297
+ Rails/ReversibleMigration:
298
+ Include:
299
+ - db/migrate/*.rb
300
+
301
+ Rails/FindBy:
302
+ Include:
303
+ - app/models/**/*.rb
304
+
305
+ Rails/FindEach:
306
+ Include:
307
+ - app/models/**/*.rb
308
+
309
+ Rails/HasAndBelongsToMany:
310
+ Include:
311
+ - app/models/**/*.rb
312
+
313
+ Rails/RequestReferer:
314
+ EnforcedStyle: referer
315
+
316
+ Rails/UniqBeforePluck:
317
+ EnforcedStyle: conservative
318
+
319
+ Rails/OutputSafety:
320
+ Enabled: false
321
+
322
+ Naming/AsciiIdentifiers:
323
+ Enabled: true
324
+
325
+ Style/MultilineBlockChain:
326
+ Enabled: false
327
+
328
+ Style/DoubleNegation:
329
+ Enabled: false
330
+
331
+ Style/UnneededPercentQ:
332
+ Enabled: false
333
+
334
+ Lint/Debugger:
335
+ Enabled: true
336
+
337
+ Naming/FileName:
338
+ Enabled: true
339
+
340
+ Style/InverseMethods:
341
+ Enabled: true
342
+
343
+ Layout/IndentArray:
344
+ EnforcedStyle: consistent
345
+
346
+ Layout/IndentHash:
347
+ EnforcedStyle: consistent
348
+
349
+ Metrics/BlockLength:
350
+ Enabled: true
351
+
352
+ Rails/SkipsModelValidations:
353
+ Enabled: true
354
+
355
+ AllCops:
356
+ TargetRubyVersion: 2.3
357
+ Exclude:
358
+ - db/schema.rb
359
+ - tmp/**/*
360
+ - vendor/**/*
361
+ - .rubocop.yml
362
+ - node_modules/**/*
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # If you do not have OpenSSL installed, update
4
+ # the following line to use "http://" instead
5
+ source "https://rubygems.org"
6
+
7
+ # Specify your gem's dependencies in middleman_mynewsdesk.gemspec
8
+ gemspec
9
+
10
+ group :development do
11
+ gem "rake"
12
+ gem "rdoc"
13
+ gem "yard"
14
+ end
15
+
16
+ group :test do
17
+ gem "aruba"
18
+ gem "cucumber"
19
+ gem "rspec"
20
+ end
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler"
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require "cucumber/rake/task"
7
+
8
+ Cucumber::Rake::Task.new(:cucumber, "Run features that should pass") do |t|
9
+ t.cucumber_opts = "--color --tags ~@wip --strict"
10
+ end
11
+
12
+ require "rake/clean"
13
+
14
+ task test: ["cucumber"]
15
+
16
+ task default: :test
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
4
+ require "middleman-core"
5
+ require "middleman-core/step_definitions"
6
+ require File.join(PROJECT_ROOT_PATH, "lib", "middleman_mynewsdesk")
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Require core library
4
+ require "middleman-core"
5
+
6
+ # Extension namespace
7
+ class Mynewsdesk < ::Middleman::Extension
8
+ option :api_key, "api_key", "Mynewsdesk API key"
9
+ expose_to_config mynewsdesk_items: :mynewsdesk_items
10
+ expose_to_template mynewsdesk_items: :mynewsdesk_items
11
+
12
+ def initialize(app, options_hash = {}, &block)
13
+ # Call super to build options from the options_hash
14
+ super
15
+
16
+ # Require libraries only when activated
17
+ require "http"
18
+ require "json"
19
+ require "middleman_mynewsdesk/mynewsdesk_item.rb"
20
+
21
+ @base_url = "https://www.mynewsdesk.com/services/pressroom/list/#{options.api_key}?format=json"
22
+ end
23
+
24
+ def mynewsdesk_items
25
+ @items ||= JSON.parse(HTTP.get(@base_url).to_s, object_class: OpenStruct).items.item.map do |item|
26
+ MynewsdeskItem.new item
27
+ end
28
+ @items
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+
5
+ class MynewsdeskItem < SimpleDelegator
6
+ def title
7
+ header
8
+ end
9
+
10
+ def slug
11
+ URI.parse(url).path.split("/").last
12
+ end
13
+
14
+ def date
15
+ DateTime.strptime(published_at, "%Y-%m-%d %H:%M:%S")
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "middleman-core"
4
+
5
+ Middleman::Extensions.register :middleman_mynewsdesk do
6
+ require "middleman_mynewsdesk/extension"
7
+ Mynewsdesk
8
+ end
@@ -0,0 +1,25 @@
1
+
2
+ $:.push File.expand_path('lib', __dir__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman_mynewsdesk"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Johan Halse"]
9
+ s.email = ["johan.halse@varvet.com"]
10
+ s.homepage = "https://www.varvet.se"
11
+ s.summary = %q(An integration with Mynewsdesk for fetching data)
12
+ s.description = %q(Supply this extension with an API key and it will do your dirty work)
13
+ s.licenses = ["MIT"]
14
+
15
+ s.files = %x(git ls-files).split("\n")
16
+ s.test_files = %x(git ls-files -- {test,spec,features}/*).split("\n")
17
+ s.executables = %x(git ls-files -- bin/*).split("\n").map { |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # The version of middleman-core your extension depends on
21
+ s.add_runtime_dependency("middleman-core", ["~> 4.2"])
22
+
23
+ # Additional dependencies
24
+ s.add_runtime_dependency("http", "~> 3.3")
25
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman_mynewsdesk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Johan Halse
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: http
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.3'
41
+ description: Supply this extension with an API key and it will do your dirty work
42
+ email:
43
+ - johan.halse@varvet.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rubocop.yml"
50
+ - Gemfile
51
+ - Rakefile
52
+ - features/support/env.rb
53
+ - lib/middleman_mynewsdesk.rb
54
+ - lib/middleman_mynewsdesk/extension.rb
55
+ - lib/middleman_mynewsdesk/mynewsdesk_item.rb
56
+ - middleman_mynewsdesk.gemspec
57
+ homepage: https://www.varvet.se
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.5.2.1
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: An integration with Mynewsdesk for fetching data
81
+ test_files:
82
+ - features/support/env.rb