shortcode 1.2.1 → 2.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop +1 -0
  3. data/.rubocop.yml +72 -0
  4. data/.travis.yml +7 -6
  5. data/Appraisals +3 -7
  6. data/Gemfile +2 -2
  7. data/Gemfile.lock +136 -18
  8. data/bin/appraisal +17 -0
  9. data/bin/rspec +17 -0
  10. data/bin/rubocop +17 -0
  11. data/gemfiles/rails_4.2.gemfile +1 -1
  12. data/gemfiles/rails_5.0.gemfile +1 -1
  13. data/gemfiles/rails_5.1.gemfile +1 -1
  14. data/lib/shortcode.rb +17 -41
  15. data/lib/shortcode/configuration.rb +3 -1
  16. data/lib/shortcode/parser.rb +21 -17
  17. data/lib/shortcode/presenter.rb +18 -15
  18. data/lib/shortcode/processor.rb +3 -1
  19. data/lib/shortcode/railtie.rb +2 -0
  20. data/lib/shortcode/tag.rb +11 -4
  21. data/lib/shortcode/template_binding.rb +12 -7
  22. data/lib/shortcode/transformer.rb +8 -4
  23. data/lib/shortcode/version.rb +3 -1
  24. data/shortcode.gemspec +10 -7
  25. data/spec/.rubocop.yml +17 -0
  26. data/spec/performance_spec.rb +4 -5
  27. data/spec/rails_helpers_spec.rb +25 -31
  28. data/spec/shortcode/parser_spec.rb +313 -0
  29. data/spec/shortcode/presenter_spec.rb +118 -0
  30. data/spec/shortcode/tag_spec.rb +73 -0
  31. data/spec/shortcode_spec.rb +40 -37
  32. data/spec/spec_helper.rb +6 -20
  33. data/spec/support/fixtures.rb +4 -6
  34. data/spec/support/presenters/missing_attributes_presenter.rb +3 -6
  35. data/spec/support/presenters/missing_content_presenter.rb +3 -6
  36. data/spec/support/presenters/missing_for_presenter.rb +3 -6
  37. data/spec/support/presenters/missing_initialize_presenter.rb +3 -6
  38. data/spec/support/presenters/multiple_presenter.rb +4 -5
  39. data/spec/support/presenters/my_presenter.rb +3 -4
  40. data/spec/support/presenters/other_presenter.rb +3 -4
  41. data/spec/template_parsers_spec.rb +21 -22
  42. data/spec/transformer_spec.rb +26 -36
  43. metadata +75 -24
  44. data/gemfiles/rails_4.1.gemfile +0 -8
  45. data/spec/parser_spec.rb +0 -307
  46. data/spec/presenter_spec.rb +0 -126
  47. data/spec/tag_spec.rb +0 -86
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11f134f87bfa70439f00a60c1b424648357cbbe4
4
- data.tar.gz: 99a050c747acb9dfedc1f3f9e035d4eb9b496dc4
3
+ metadata.gz: 67c526cf7e4b188fc7d99cf8b41617e9276b4152
4
+ data.tar.gz: de1db6a4b8749558967a4bfa59db55f6520af4c4
5
5
  SHA512:
6
- metadata.gz: a021bdbe0979e2266972703969c0c01030a45138de2e1e99e36ba77845020b7f787056d3a13afd6337fdaef3c1b39e3b1004f4727d454a0d648d86f64953891b
7
- data.tar.gz: 44ddde6b96b26707107ee0ba028de4404d965ed5453d9e1be587c09040f54d9c258d0d3b411162311ccdd57d3b7b2b5940109a40fe8af4a6f43952f0730e6d3a
6
+ metadata.gz: 8c2cbbf8f3d9bb15e080ee37d658a58efcdeb63b0c3e583133c1352e1ac50d9f7e01bdbfd546b85560551b03b55e919e8ec8334a1d0db9468dd9a66d9afaa765
7
+ data.tar.gz: cc71f73c661b952f3dea16a1a7b28c691d315f2a301ff0db4b3bfc9dc5ef05339f39c962e86e92f5de72453c69ef1ca768e603adf36d250dd6462386c831e9bb
data/.rubocop ADDED
@@ -0,0 +1 @@
1
+ -D
data/.rubocop.yml ADDED
@@ -0,0 +1,72 @@
1
+ ###########################
2
+ # Configuration for rubocop
3
+ # in .rubocop.yml
4
+ # Most of these are disabling existing cops, primarily
5
+ # due to a smattering of different styles and loose
6
+ # guidlines for contributions.
7
+ #
8
+ # Any of these may be changed.
9
+
10
+ require: rubocop-rspec
11
+
12
+ AllCops:
13
+ Exclude:
14
+ - 'bin/*'
15
+
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ Style/StringLiterals:
20
+ EnforcedStyle: double_quotes
21
+
22
+ # START Ruby 2.4 editions (these are disabled for the upgrade, reenable after
23
+ # if you wish)
24
+ Style/FrozenStringLiteralComment:
25
+ Enabled: false
26
+
27
+ Style/SafeNavigation:
28
+ Enabled: false
29
+
30
+ Style/NumericPredicate:
31
+ Enabled: false
32
+
33
+ Performance/RegexpMatch:
34
+ Enabled: false
35
+ # END Ruby 2.4 editions
36
+
37
+ Layout/SpaceAroundEqualsInParameterDefault:
38
+ EnforcedStyle: no_space
39
+
40
+ Layout/MultilineMethodCallIndentation:
41
+ EnforcedStyle: indented
42
+
43
+ EmptyLinesAroundClassBody:
44
+ EnforcedStyle: empty_lines
45
+
46
+ Layout/EmptyLinesAroundModuleBody:
47
+ EnforcedStyle: empty_lines
48
+
49
+ Style/Lambda:
50
+ EnforcedStyle: literal
51
+ # SupportedStyles:
52
+ # - line_count_dependent
53
+ # - lambda
54
+ # - literal
55
+
56
+ Style/ClassAndModuleChildren:
57
+ Enabled: false
58
+
59
+ Performance/Casecmp:
60
+ Enabled: false
61
+
62
+ Style/Alias:
63
+ Enabled: false
64
+
65
+ Style/BlockDelimiters:
66
+ Enabled: false
67
+
68
+ LineLength:
69
+ Max: 110
70
+
71
+ Metrics/MethodLength:
72
+ Max: 14
data/.travis.yml CHANGED
@@ -1,25 +1,26 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.2.7
5
- - 2.3.4
6
- - 2.4.1
4
+ - 2.2.8
5
+ - 2.3.5
6
+ - 2.4.2
7
7
  - ruby-head
8
8
  - jruby-9.1.9.0
9
9
 
10
10
  sudo: false
11
11
 
12
- script: bundle exec rspec
12
+ script:
13
+ - bin/rspec
14
+ - bin/rubocop
13
15
 
14
16
  before_install:
15
- - gem install bundler -v 1.15.0
17
+ - gem install bundler -v 1.16.0
16
18
 
17
19
  matrix:
18
20
  allow_failures:
19
21
  - rvm: ruby-head
20
22
 
21
23
  gemfile:
22
- - gemfiles/rails_4.1.gemfile
23
24
  - gemfiles/rails_4.2.gemfile
24
25
  - gemfiles/rails_5.0.gemfile
25
26
  - gemfiles/rails_5.1.gemfile
data/Appraisals CHANGED
@@ -1,15 +1,11 @@
1
- appraise "rails-4.1" do
2
- gem "rails", "~> 4.1.16"
3
- end
4
-
5
1
  appraise "rails-4.2" do
6
- gem "rails", "4.2.8"
2
+ gem "rails", "4.2.10"
7
3
  end
8
4
 
9
5
  appraise "rails-5.0" do
10
- gem "rails", "5.0.3"
6
+ gem "rails", "5.0.6"
11
7
  end
12
8
 
13
9
  appraise "rails-5.1" do
14
- gem "rails", "5.1.1"
10
+ gem "rails", "5.1.4"
15
11
  end
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in shortcode.gemspec
4
4
  gemspec
5
5
 
6
- gem 'appraisal', '2.2.0'
6
+ gem "appraisal", "2.2.0"
data/Gemfile.lock CHANGED
@@ -7,51 +7,166 @@ PATH
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ actioncable (5.1.4)
11
+ actionpack (= 5.1.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (~> 0.6.1)
14
+ actionmailer (5.1.4)
15
+ actionpack (= 5.1.4)
16
+ actionview (= 5.1.4)
17
+ activejob (= 5.1.4)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.1.4)
21
+ actionview (= 5.1.4)
22
+ activesupport (= 5.1.4)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.1.4)
28
+ activesupport (= 5.1.4)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.1.4)
34
+ activesupport (= 5.1.4)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.1.4)
37
+ activesupport (= 5.1.4)
38
+ activerecord (5.1.4)
39
+ activemodel (= 5.1.4)
40
+ activesupport (= 5.1.4)
41
+ arel (~> 8.0)
42
+ activesupport (5.1.4)
43
+ concurrent-ruby (~> 1.0, >= 1.0.2)
44
+ i18n (~> 0.7)
45
+ minitest (~> 5.1)
46
+ tzinfo (~> 1.1)
10
47
  appraisal (2.2.0)
11
48
  bundler
12
49
  rake
13
50
  thor (>= 0.14.0)
51
+ arel (8.0.0)
52
+ ast (2.3.0)
53
+ builder (3.2.3)
54
+ concurrent-ruby (1.0.5)
14
55
  coveralls (0.8.21)
15
56
  json (>= 1.8, < 3)
16
57
  simplecov (~> 0.14.1)
17
58
  term-ansicolor (~> 1.3)
18
59
  thor (~> 0.19.4)
19
60
  tins (~> 1.6)
61
+ crass (1.0.2)
20
62
  diff-lcs (1.3)
21
63
  docile (1.1.5)
22
- haml (5.0.1)
64
+ erubi (1.6.1)
65
+ globalid (0.4.1)
66
+ activesupport (>= 4.2.0)
67
+ haml (5.0.4)
23
68
  temple (>= 0.8.0)
24
69
  tilt
70
+ i18n (0.9.0)
71
+ concurrent-ruby (~> 1.0)
25
72
  json (2.1.0)
73
+ loofah (2.1.1)
74
+ crass (~> 1.0.2)
75
+ nokogiri (>= 1.5.9)
76
+ mail (2.7.0)
77
+ mini_mime (>= 0.1.1)
78
+ method_source (0.9.0)
79
+ mini_mime (0.1.4)
80
+ mini_portile2 (2.3.0)
81
+ minitest (5.10.3)
82
+ nio4r (2.1.0)
83
+ nokogiri (1.8.1)
84
+ mini_portile2 (~> 2.3.0)
85
+ parallel (1.12.0)
86
+ parser (2.4.0.0)
87
+ ast (~> 2.2)
26
88
  parslet (1.8.0)
27
- rake (12.0.0)
28
- rspec (3.6.0)
29
- rspec-core (~> 3.6.0)
30
- rspec-expectations (~> 3.6.0)
31
- rspec-mocks (~> 3.6.0)
32
- rspec-core (3.6.0)
33
- rspec-support (~> 3.6.0)
34
- rspec-expectations (3.6.0)
89
+ powerpack (0.1.1)
90
+ rack (2.0.3)
91
+ rack-test (0.7.0)
92
+ rack (>= 1.0, < 3)
93
+ rails (5.1.4)
94
+ actioncable (= 5.1.4)
95
+ actionmailer (= 5.1.4)
96
+ actionpack (= 5.1.4)
97
+ actionview (= 5.1.4)
98
+ activejob (= 5.1.4)
99
+ activemodel (= 5.1.4)
100
+ activerecord (= 5.1.4)
101
+ activesupport (= 5.1.4)
102
+ bundler (>= 1.3.0)
103
+ railties (= 5.1.4)
104
+ sprockets-rails (>= 2.0.0)
105
+ rails-dom-testing (2.0.3)
106
+ activesupport (>= 4.2.0)
107
+ nokogiri (>= 1.6)
108
+ rails-html-sanitizer (1.0.3)
109
+ loofah (~> 2.0)
110
+ railties (5.1.4)
111
+ actionpack (= 5.1.4)
112
+ activesupport (= 5.1.4)
113
+ method_source
114
+ rake (>= 0.8.7)
115
+ thor (>= 0.18.1, < 2.0)
116
+ rainbow (2.2.2)
117
+ rake
118
+ rake (12.2.1)
119
+ rspec (3.7.0)
120
+ rspec-core (~> 3.7.0)
121
+ rspec-expectations (~> 3.7.0)
122
+ rspec-mocks (~> 3.7.0)
123
+ rspec-core (3.7.0)
124
+ rspec-support (~> 3.7.0)
125
+ rspec-expectations (3.7.0)
35
126
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.6.0)
37
- rspec-mocks (3.6.0)
127
+ rspec-support (~> 3.7.0)
128
+ rspec-mocks (3.7.0)
38
129
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.6.0)
40
- rspec-support (3.6.0)
130
+ rspec-support (~> 3.7.0)
131
+ rspec-support (3.7.0)
132
+ rubocop (0.51.0)
133
+ parallel (~> 1.10)
134
+ parser (>= 2.3.3.1, < 3.0)
135
+ powerpack (~> 0.1)
136
+ rainbow (>= 2.2.2, < 3.0)
137
+ ruby-progressbar (~> 1.7)
138
+ unicode-display_width (~> 1.0, >= 1.0.1)
139
+ rubocop-rspec (1.19.0)
140
+ rubocop (>= 0.51.0)
141
+ ruby-progressbar (1.9.0)
41
142
  simplecov (0.14.1)
42
143
  docile (~> 1.1.0)
43
144
  json (>= 1.8, < 3)
44
145
  simplecov-html (~> 0.10.0)
45
- simplecov-html (0.10.1)
146
+ simplecov-html (0.10.2)
46
147
  slim (3.0.8)
47
148
  temple (>= 0.7.6, < 0.9)
48
149
  tilt (>= 1.3.3, < 2.1)
150
+ sprockets (3.7.1)
151
+ concurrent-ruby (~> 1.0)
152
+ rack (> 1, < 3)
153
+ sprockets-rails (3.2.1)
154
+ actionpack (>= 4.0)
155
+ activesupport (>= 4.0)
156
+ sprockets (>= 3.0.0)
49
157
  temple (0.8.0)
50
158
  term-ansicolor (1.6.0)
51
159
  tins (~> 1.0)
52
160
  thor (0.19.4)
53
- tilt (2.0.7)
54
- tins (1.14.0)
161
+ thread_safe (0.3.6)
162
+ tilt (2.0.8)
163
+ tins (1.15.0)
164
+ tzinfo (1.2.4)
165
+ thread_safe (~> 0.1)
166
+ unicode-display_width (1.3.0)
167
+ websocket-driver (0.6.5)
168
+ websocket-extensions (>= 0.1.0)
169
+ websocket-extensions (0.1.2)
55
170
 
56
171
  PLATFORMS
57
172
  ruby
@@ -61,10 +176,13 @@ DEPENDENCIES
61
176
  bundler (~> 1.15)
62
177
  coveralls (~> 0.8)
63
178
  haml (~> 5.0)
179
+ rails (= 5.1.4)
64
180
  rake (~> 12.0)
65
- rspec (~> 3.6)
181
+ rspec (~> 3.7)
182
+ rubocop (~> 0.51)
183
+ rubocop-rspec (~> 1.19)
66
184
  shortcode!
67
185
  slim (~> 3.0)
68
186
 
69
187
  BUNDLED WITH
70
- 1.15.0
188
+ 1.15.4
data/bin/appraisal ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'appraisal' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("appraisal", "appraisal")
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/rubocop ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rubocop' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rubocop", "rubocop")
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "2.2.0"
6
- gem "rails", "4.2.8"
6
+ gem "rails", "4.2.10"
7
7
 
8
8
  gemspec path: "../"
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "2.2.0"
6
- gem "rails", "5.0.3"
6
+ gem "rails", "5.0.6"
7
7
 
8
8
  gemspec path: "../"
@@ -3,6 +3,6 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "appraisal", "2.2.0"
6
- gem "rails", "5.1.1"
6
+ gem "rails", "5.1.4"
7
7
 
8
8
  gemspec path: "../"
data/lib/shortcode.rb CHANGED
@@ -1,37 +1,16 @@
1
- require 'parslet'
2
- require 'erb'
1
+ require "parslet"
2
+ require "erb"
3
3
 
4
+ # rubocop:disable Lint/HandleExceptions
4
5
  begin
5
- require 'haml'
6
+ require "haml"
6
7
  rescue LoadError; end
7
-
8
8
  begin
9
- require 'slim'
9
+ require "slim"
10
10
  rescue LoadError; end
11
+ # rubocop:enable Lint/HandleExceptions
11
12
 
12
13
  class Shortcode
13
- # This is providedc for backwards compatibility
14
- def self.process(string, additional_attributes=nil)
15
- warn "[DEPRECATION] singleton `Shortcode.process` is deprecated and will be removed in version 2.0. Please create a new instance `Shortcode.new` and call `process` on the instance."
16
- singleton.process(string, additional_attributes)
17
- end
18
-
19
- # This is provided for backwards compatibility
20
- def self.singleton
21
- @instance ||= new
22
- end
23
-
24
- # This is providedc for backwards compatibility
25
- def self.setup(&prc)
26
- warn "[DEPRECATION] singleton `Shortcode.setup` is deprecated and will be removed in version 2.0. Please create a new instance `Shortcode.new` and call `setup` on the instance."
27
- singleton.setup(&prc)
28
- end
29
-
30
- # This is providedc for backwards compatibility
31
- def self.register_presenter(*presenters)
32
- warn "[DEPRECATION] singleton `Shortcode.register_presenter` is deprecated and will be removed in version 2.0. Please create a new instance `Shortcode.new` and call `register_presenter` on the instance."
33
- singleton.register_presenter(*presenters)
34
- end
35
14
 
36
15
  def process(string, additional_attributes=nil)
37
16
  Shortcode::Processor.new.process(string, configuration, additional_attributes)
@@ -47,22 +26,19 @@ class Shortcode
47
26
  end
48
27
  end
49
28
 
50
- private
51
-
52
29
  def configuration
53
30
  @configuration ||= Configuration.new
54
31
  end
55
- end
56
32
 
57
- require 'shortcode/version'
58
- require 'shortcode/configuration'
59
- require 'shortcode/parser'
60
- require 'shortcode/presenter'
61
- require 'shortcode/processor'
62
- require 'shortcode/template_binding'
63
- require 'shortcode/transformer'
64
- require 'shortcode/tag'
65
- require 'shortcode/exceptions'
66
- require 'shortcode/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3
33
+ end
67
34
 
68
- Shortcode.setup {}
35
+ require "shortcode/version"
36
+ require "shortcode/configuration"
37
+ require "shortcode/parser"
38
+ require "shortcode/presenter"
39
+ require "shortcode/processor"
40
+ require "shortcode/template_binding"
41
+ require "shortcode/transformer"
42
+ require "shortcode/tag"
43
+ require "shortcode/exceptions"
44
+ require "shortcode/railtie" if defined?(Rails) && Rails::VERSION::MAJOR >= 3