virgo 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/virgo/install/install_generator.rb +20 -0
  3. data/lib/generators/virgo/migrations/migrations_generator.rb +19 -0
  4. data/lib/generators/virgo/schedule/schedule_generator.rb +15 -0
  5. data/lib/generators/virgo/views/views_generator.rb +22 -0
  6. data/lib/tasks/virgo_tasks.rake +7 -0
  7. data/lib/virgo.rb +4 -0
  8. data/lib/virgo/development_mail_interceptor.rb +6 -0
  9. data/lib/virgo/email_validator.rb +6 -0
  10. data/lib/virgo/engine.rb +64 -0
  11. data/lib/virgo/reduce_validator.rb +6 -0
  12. data/lib/virgo/upload_helpers.rb +89 -0
  13. data/lib/virgo/version.rb +3 -0
  14. data/lib/virgo/view_help.rb +3 -0
  15. data/vendor/gems/shortcode/Appraisals +15 -0
  16. data/vendor/gems/shortcode/CHANGELOG.md +162 -0
  17. data/vendor/gems/shortcode/Gemfile +6 -0
  18. data/vendor/gems/shortcode/Gemfile.lock +168 -0
  19. data/vendor/gems/shortcode/LICENSE.txt +22 -0
  20. data/vendor/gems/shortcode/README.md +268 -0
  21. data/vendor/gems/shortcode/Rakefile +3 -0
  22. data/vendor/gems/shortcode/gemfiles/rails_3.2.gemfile +8 -0
  23. data/vendor/gems/shortcode/gemfiles/rails_4.0.gemfile +8 -0
  24. data/vendor/gems/shortcode/gemfiles/rails_4.1.gemfile +8 -0
  25. data/vendor/gems/shortcode/gemfiles/rails_4.2.gemfile +8 -0
  26. data/vendor/gems/shortcode/lib/shortcode.rb +53 -0
  27. data/vendor/gems/shortcode/lib/shortcode/configuration.rb +36 -0
  28. data/vendor/gems/shortcode/lib/shortcode/exceptions.rb +9 -0
  29. data/vendor/gems/shortcode/lib/shortcode/parser.rb +43 -0
  30. data/vendor/gems/shortcode/lib/shortcode/presenter.rb +49 -0
  31. data/vendor/gems/shortcode/lib/shortcode/processor.rb +17 -0
  32. data/vendor/gems/shortcode/lib/shortcode/railtie.rb +3 -0
  33. data/vendor/gems/shortcode/lib/shortcode/tag.rb +54 -0
  34. data/vendor/gems/shortcode/lib/shortcode/template_binding.rb +33 -0
  35. data/vendor/gems/shortcode/lib/shortcode/transformer.rb +17 -0
  36. data/vendor/gems/shortcode/lib/shortcode/version.rb +3 -0
  37. data/vendor/gems/shortcode/shortcode.gemspec +30 -0
  38. data/vendor/gems/shortcode/spec/parser_spec.rb +267 -0
  39. data/vendor/gems/shortcode/spec/performance_spec.rb +41 -0
  40. data/vendor/gems/shortcode/spec/presenter_spec.rb +126 -0
  41. data/vendor/gems/shortcode/spec/rails_helpers_spec.rb +72 -0
  42. data/vendor/gems/shortcode/spec/shortcode_spec.rb +57 -0
  43. data/vendor/gems/shortcode/spec/spec_helper.rb +32 -0
  44. data/vendor/gems/shortcode/spec/support/fixtures.rb +9 -0
  45. data/vendor/gems/shortcode/spec/support/fixtures/block_with_whitespace.txt +2 -0
  46. data/vendor/gems/shortcode/spec/support/fixtures/block_with_whitespace_output.html +2 -0
  47. data/vendor/gems/shortcode/spec/support/fixtures/complex_snippet.txt +13 -0
  48. data/vendor/gems/shortcode/spec/support/fixtures/complex_snippet_output.html +33 -0
  49. data/vendor/gems/shortcode/spec/support/fixtures/custom_helper.txt +1 -0
  50. data/vendor/gems/shortcode/spec/support/fixtures/custom_helper_output.html +1 -0
  51. data/vendor/gems/shortcode/spec/support/fixtures/full_quote.txt +1 -0
  52. data/vendor/gems/shortcode/spec/support/fixtures/full_quote_output.html +7 -0
  53. data/vendor/gems/shortcode/spec/support/fixtures/item.txt +1 -0
  54. data/vendor/gems/shortcode/spec/support/fixtures/item_presenter_attributes_output.html +4 -0
  55. data/vendor/gems/shortcode/spec/support/fixtures/item_presenter_output.html +4 -0
  56. data/vendor/gems/shortcode/spec/support/fixtures/long_text.txt +39 -0
  57. data/vendor/gems/shortcode/spec/support/fixtures/quote_with_extras.txt +1 -0
  58. data/vendor/gems/shortcode/spec/support/fixtures/quote_with_extras_output.html +7 -0
  59. data/vendor/gems/shortcode/spec/support/fixtures/rails_helper.txt +1 -0
  60. data/vendor/gems/shortcode/spec/support/fixtures/rails_helper_output_erb.html +1 -0
  61. data/vendor/gems/shortcode/spec/support/fixtures/rails_helper_output_haml.html +1 -0
  62. data/vendor/gems/shortcode/spec/support/fixtures/rails_helper_output_slim.html +1 -0
  63. data/vendor/gems/shortcode/spec/support/fixtures/simple_list.txt +5 -0
  64. data/vendor/gems/shortcode/spec/support/fixtures/simple_list_output.html +15 -0
  65. data/vendor/gems/shortcode/spec/support/fixtures/simple_quote.txt +1 -0
  66. data/vendor/gems/shortcode/spec/support/fixtures/simple_quote_output.html +3 -0
  67. data/vendor/gems/shortcode/spec/support/fixtures/simple_quote_presenter_attributes_output.html +6 -0
  68. data/vendor/gems/shortcode/spec/support/fixtures/simple_quote_presenter_output.html +6 -0
  69. data/vendor/gems/shortcode/spec/support/fixtures/timeline_event.txt +1 -0
  70. data/vendor/gems/shortcode/spec/support/fixtures/timeline_event_output.html +15 -0
  71. data/vendor/gems/shortcode/spec/support/fixtures/timeline_info.txt +1 -0
  72. data/vendor/gems/shortcode/spec/support/fixtures/timeline_info_output.html +14 -0
  73. data/vendor/gems/shortcode/spec/support/fixtures/timeline_person.txt +4 -0
  74. data/vendor/gems/shortcode/spec/support/fixtures/timeline_person_output.html +23 -0
  75. data/vendor/gems/shortcode/spec/support/fixtures/without_quotes.txt +1 -0
  76. data/vendor/gems/shortcode/spec/support/presenters/missing_attributes_presenter.rb +12 -0
  77. data/vendor/gems/shortcode/spec/support/presenters/missing_content_presenter.rb +12 -0
  78. data/vendor/gems/shortcode/spec/support/presenters/missing_for_presenter.rb +12 -0
  79. data/vendor/gems/shortcode/spec/support/presenters/missing_initialize_presenter.rb +12 -0
  80. data/vendor/gems/shortcode/spec/support/presenters/multiple_presenter.rb +19 -0
  81. data/vendor/gems/shortcode/spec/support/presenters/my_presenter.rb +19 -0
  82. data/vendor/gems/shortcode/spec/support/presenters/other_presenter.rb +19 -0
  83. data/vendor/gems/shortcode/spec/support/templates/erb/collapsible_list.html.erb +3 -0
  84. data/vendor/gems/shortcode/spec/support/templates/erb/custom_helper.html.erb +1 -0
  85. data/vendor/gems/shortcode/spec/support/templates/erb/item.html.erb +4 -0
  86. data/vendor/gems/shortcode/spec/support/templates/erb/quote.html.erb +13 -0
  87. data/vendor/gems/shortcode/spec/support/templates/erb/rails_helper.html.erb +1 -0
  88. data/vendor/gems/shortcode/spec/support/templates/erb/timeline_event.html.erb +17 -0
  89. data/vendor/gems/shortcode/spec/support/templates/erb/timeline_info.html.erb +15 -0
  90. data/vendor/gems/shortcode/spec/support/templates/erb/timeline_person.html.erb +23 -0
  91. data/vendor/gems/shortcode/spec/support/templates/haml/quote.html.haml +8 -0
  92. data/vendor/gems/shortcode/spec/support/templates/haml/rails_helper.html.haml +1 -0
  93. data/vendor/gems/shortcode/spec/support/templates/slim/quote.html.slim +8 -0
  94. data/vendor/gems/shortcode/spec/support/templates/slim/rails_helper.html.slim +1 -0
  95. data/vendor/gems/shortcode/spec/tag_spec.rb +67 -0
  96. data/vendor/gems/shortcode/spec/template_parsers_spec.rb +46 -0
  97. data/vendor/gems/shortcode/spec/transformer_spec.rb +122 -0
  98. metadata +97 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6065e134a44f4d05ec90cdbdc6820d8e03f9029
4
- data.tar.gz: 7a877b8c3b77f8039c6a14750f82342c75057d3a
3
+ metadata.gz: a9bef2d8e9a70c95e9376f0ec9bc718a37de834e
4
+ data.tar.gz: b56fe5cb3550a83da2fb2e92d729968509a629c1
5
5
  SHA512:
6
- metadata.gz: e07d45b1b931d81fe66d260743cd897c85fda21911e89f12402c470129ee50a6337ade708dd83b886801eb4253c05379725eca44fb8aada78b6815461b16be6c
7
- data.tar.gz: ae2b2a750b04a30e059b29846a07745ee85d1760956b259e37f907419dd30b0cf40f4e9017447e58a0dc65db5a56feaa0cc67e9682ac681755fd095e01aebd09
6
+ metadata.gz: 8162ba5cfd24d5a7538df52e7c8675a11e8b3639b3474c5f0d17a9b17a6522bcd475eeabd325e58a760fd27cc3500ccc5c46f7fa9fd449cc01961c550232d304
7
+ data.tar.gz: 11f2daad0818a3832b667cef04d14981fc2a99e7a3b234ec6445d53d33afd71b543891b06cecec56612c08a2456bf408e20973a97b66074ba687ba37ecf0d2ed
@@ -0,0 +1,20 @@
1
+ module Virgo
2
+ class InstallGenerator < Rails::Generators::Base
3
+ def run_install
4
+ unless app_has_engine_route?
5
+ in_root do
6
+ inject_into_file 'config/routes.rb',"\n mount Virgo::Engine => \"/\"\n", { before: /^end/, verbose: false, force: true }
7
+ end
8
+ end
9
+
10
+ generate "virgo:views"
11
+ generate "virgo:migrations"
12
+ generate "virgo:schedule"
13
+ end
14
+
15
+ def app_has_engine_route?
16
+ route_contents = File.read("#{Rails.root}/config/routes.rb")
17
+ route_contents.include?("Virgo::Engine")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ module Virgo
2
+ class MigrationsGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../..', __FILE__)
4
+
5
+ def copy_migrations
6
+ Dir["#{engine_root}/db/migrate/*.rb"].each do |abs_path|
7
+ relative_path = abs_path.gsub("#{engine_root}/", '')
8
+
9
+ unless File.directory?(abs_path)
10
+ copy_file relative_path, relative_path
11
+ end
12
+ end
13
+ end
14
+
15
+ def engine_root
16
+ File.expand_path('../../../../..', __FILE__)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Virgo
2
+ class ScheduleGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../..', __FILE__)
4
+
5
+ def copy_schedule
6
+ abs_path = "#{engine_root}/config/schedule.rb"
7
+ relative_path = abs_path.gsub("#{engine_root}/", '')
8
+ copy_file relative_path, relative_path
9
+ end
10
+
11
+ def engine_root
12
+ File.expand_path('../../../../..', __FILE__)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module Virgo
2
+ class ViewsGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../../../../..', __FILE__)
4
+
5
+ def copy_views
6
+ Dir["#{engine_root}/app/views/**/*"].reject { |f|
7
+ f.include?('admin') ||
8
+ f.include?('shortcode_templates')
9
+ }.each do |abs_path|
10
+ relative_path = abs_path.gsub("#{engine_root}/", '')
11
+
12
+ unless File.directory?(abs_path)
13
+ copy_file relative_path, relative_path
14
+ end
15
+ end
16
+ end
17
+
18
+ def engine_root
19
+ File.expand_path('../../../../..', __FILE__)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ namespace :virgo do
2
+ namespace :posts do
3
+ task publish_scheduled: :environment do
4
+ Virgo::Post.publish_scheduled!
5
+ end
6
+ end
7
+ end
data/lib/virgo.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "virgo/engine"
2
+
3
+ module Virgo
4
+ end
@@ -0,0 +1,6 @@
1
+ class DevelopmentMailInterceptor
2
+ def self.delivering_email(message)
3
+ message.subject = "#{message.to} #{message.subject}"
4
+ message.to = Rails.application.secrets.mail_intercept_address
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class EmailValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ record.errors.add(attribute, options[:message] || "has an invalid format") unless
4
+ value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
5
+ end
6
+ end
@@ -0,0 +1,64 @@
1
+ module Virgo
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Virgo
4
+
5
+ config.autoload_paths << File.expand_path("..", __FILE__)
6
+
7
+ config.caching = :aggressive
8
+
9
+ config.require_posts_to_have_category = false
10
+
11
+ config.domain = 'localhost'
12
+
13
+ config.edit_lock_timeout = 8.seconds
14
+
15
+ config.edit_lock_grace = 10.seconds
16
+
17
+ config.post_locking_enabled = true
18
+
19
+ config.deploy_key = Digest::MD5.hexdigest(Dir["#{Rails.root}/public/assets/**/*"].join(':'))
20
+
21
+ # some dependencies must be explicitly required if used in an engine...
22
+ require 'devise'
23
+ require 'kaminari-bootstrap'
24
+ require 'friendly_id'
25
+ require 'kaminari'
26
+ require 'kaminari-bootstrap'
27
+ require 'carrierwave'
28
+ require 'cancan'
29
+ require 'handles_sortable_columns'
30
+ require 'action_controller/action_caching.rb'
31
+ require 'htmlentities'
32
+ require 'jquery-rails'
33
+ require 'jquery-ui-rails'
34
+ require 'jquery-fileupload-rails'
35
+ require 'bootstrap-sass'
36
+ require 'font-awesome-sass'
37
+ require 'bootstrap3-datetimepicker-rails'
38
+ require 'select2-rails'
39
+ require 'momentjs-rails'
40
+ require 'local_time'
41
+ require 'tinymce-rails'
42
+ require 'chronic'
43
+
44
+ require File.expand_path("../../../vendor/gems/shortcode/lib/shortcode", __FILE__)
45
+
46
+
47
+ spec = Gem::Specification.find_by_name("local_time")
48
+ gem_root = spec.gem_dir
49
+ require "#{gem_root}/app/helpers/local_time_helper"
50
+
51
+ ActionView::Base.send :include, ::LocalTimeHelper
52
+
53
+ config.to_prepare do
54
+ # Load application's model / class decorators
55
+ Dir["#{Rails.root}/app/**/*_decorator*.rb"].each do |c|
56
+ Rails.configuration.cache_classes ? require(c) : load(c)
57
+ end
58
+ end
59
+
60
+ config.generators do |g|
61
+ g.test_framework :rspec
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,6 @@
1
+ class ReduceValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ return until record.errors.has_key?(attribute)
4
+ record.errors[attribute].slice!(-1) until record.errors[attribute].size <= 1
5
+ end
6
+ end
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+ require 'digest/sha1'
3
+ require 'mime/types'
4
+
5
+ module UploadHelpers
6
+ module Http
7
+ # Create tempfile from hash
8
+ class UploadedFile
9
+ attr_accessor :original_filename, :content_type, :tempfile, :headers
10
+
11
+ def initialize(hash)
12
+ @original_filename = hash[:filename]
13
+ @content_type = hash[:type]
14
+ @headers = hash[:head]
15
+ @tempfile = hash[:tempfile]
16
+ raise(ArgumentError, ':tempfile is required') unless @tempfile
17
+ end
18
+
19
+ def open
20
+ @tempfile.open
21
+ end
22
+
23
+ def path
24
+ @tempfile.path
25
+ end
26
+
27
+ def read(*args)
28
+ @tempfile.read(*args)
29
+ end
30
+
31
+ def rewind
32
+ @tempfile.rewind
33
+ end
34
+
35
+ def size
36
+ @tempfile.size
37
+ end
38
+ end
39
+
40
+ # Usage (paperclip example)
41
+ # @asset.data = QqFile.new(params[:qqfile], request)
42
+ class QqFile < ::Tempfile
43
+
44
+ def initialize(filename, request, tmpdir = Dir::tmpdir)
45
+ @original_filename = filename
46
+ @request = request
47
+
48
+ super Digest::SHA1.hexdigest(filename), tmpdir
49
+ fetch
50
+ end
51
+
52
+ def fetch
53
+ self.write(body)
54
+ self.rewind
55
+ self
56
+ end
57
+
58
+ def original_filename
59
+ @original_filename
60
+ end
61
+
62
+ def content_type
63
+ types = MIME::Types.type_for(original_filename)
64
+ types.empty? ? @request.content_type : types.first.to_s
65
+ end
66
+
67
+ def body
68
+ if @request.raw_post.respond_to?(:force_encoding)
69
+ @request.raw_post.force_encoding("UTF-8")
70
+ else
71
+ @request.raw_post
72
+ end
73
+ end
74
+ end
75
+
76
+ # Convert nested Hash to HashWithIndifferentAccess and replace
77
+ # file upload hash with UploadedFile objects
78
+ def self.normalize_param(*args)
79
+ value = args.first
80
+ if Hash === value && value.has_key?(:tempfile)
81
+ UploadedFile.new(value)
82
+ elsif value.is_a?(String)
83
+ QqFile.new(*args)
84
+ else
85
+ value
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,3 @@
1
+ module Virgo
2
+ VERSION = "0.1.4"
3
+ end
@@ -0,0 +1,3 @@
1
+ class ViewHelp
2
+ include ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TextHelper
3
+ end
@@ -0,0 +1,15 @@
1
+ appraise "rails-3.2" do
2
+ gem "rails", "~> 3.2.21"
3
+ end
4
+
5
+ appraise "rails-4.0" do
6
+ gem "rails", "~> 4.0.13"
7
+ end
8
+
9
+ appraise "rails-4.1" do
10
+ gem "rails", "~> 4.1.10"
11
+ end
12
+
13
+ appraise "rails-4.2" do
14
+ gem "rails", "4.2.1"
15
+ end
@@ -0,0 +1,162 @@
1
+ ## 1.1.0 (May 15, 2015)
2
+
3
+ Features:
4
+
5
+ - Support for registering multiple presenters with a single call
6
+
7
+ ## 1.0.2 (March 4, 2015)
8
+
9
+ Fixes:
10
+
11
+ - Whitespace after tags is now preserved
12
+
13
+ ## 1.0.1 (January 21, 2015)
14
+
15
+ Features:
16
+
17
+ - Implemented a TemplateBinding class as the binding to templates to provide a clean interface
18
+ - Updated to parslet 1.6.2
19
+ - Updated to rspec 3.1
20
+
21
+ Misc:
22
+
23
+ - Testing against the latest versions of Rails 3.1, 3.2, 4.0, 4.1 & 4.2
24
+ - Testing against the latest versions of Ruby 1.9.3-p551, 2.0.0-p598, 2.1.5 & 2.2.0
25
+ - Dropped test support for Rails 3.0
26
+ - Dropped test support for run 1.9.2
27
+ - README improvements
28
+
29
+ ## 1.0.0 (July 29, 2014)
30
+
31
+ Features:
32
+
33
+ - Adds support for attributes without quotations around them
34
+
35
+ Breaking Changes:
36
+
37
+ - Renamed configuration options so they are more clear
38
+
39
+
40
+ ## 0.4.3 (July 16, 2014)
41
+
42
+ Features:
43
+
44
+ - Adds support for custom helpers in templates
45
+
46
+
47
+ ## 0.4.2 (July 1, 2014)
48
+
49
+ Features:
50
+
51
+ - Adds presenter class method validation
52
+
53
+
54
+ ## 0.4.1 (June 18, 2014)
55
+
56
+ Features:
57
+
58
+ - Adds support to apply a single presenter to multiple short code snippets
59
+
60
+ Misc:
61
+
62
+ - Prevent coveralls from running locally
63
+ - Updated to rspec 3
64
+
65
+
66
+ ## 0.4.0 (June 16, 2014)
67
+
68
+ Features:
69
+
70
+ - Switched to erb as the default template language and removed dependency on haml
71
+
72
+
73
+ ## 0.3.3 (June 3, 2014)
74
+
75
+ Misc:
76
+
77
+ - Added haml default template parser deprecation message
78
+
79
+
80
+ ## 0.3.1 (May 30, 2014)
81
+
82
+ Features:
83
+
84
+ - Added support for slim templates (@keichan34)
85
+ - Updated rails versions to test against and updated read me with tested versions of ruby/rails
86
+
87
+
88
+ ## 0.3.0 (May 13, 2014)
89
+
90
+ Features:
91
+
92
+ - Added config option to support loading templates from strings
93
+
94
+
95
+ ## 0.2.0 (May 9, 2014)
96
+
97
+ Features:
98
+
99
+ - Presenters now support additional attributes
100
+ - Updated parslet gem to 1.6.0 for performance improvements
101
+ - Add config option for quotation sign (@lenart)
102
+
103
+
104
+ ## 0.1.2 (March 18, 2014)
105
+
106
+ Features:
107
+
108
+ - Test suite runs against multiple version of ruby and rails
109
+
110
+ Bugfixes:
111
+
112
+ - Presenters are now initialised correctly, allow gem to be used without needing to call Shortcode.setup (fixes #6)
113
+ - Only include rails helpers in rails version 3 or higher
114
+
115
+ Misc:
116
+
117
+ - Simplify presenter image lookup in README (@chrsgrrtt)
118
+
119
+
120
+ ## 0.1.1 (February 23, 2014)
121
+
122
+ Features:
123
+
124
+ - Support rails helpers in templates when used within a rails project
125
+
126
+
127
+ ## 0.1.0 (February 23, 2014)
128
+
129
+ Features:
130
+
131
+ - Presenters added
132
+
133
+
134
+ ## 0.0.4 (February 23, 2014)
135
+
136
+ Bugfixes:
137
+
138
+ - Support configurations with empty tag arrays (fixes #1)
139
+
140
+
141
+ ## 0.0.3 (August 23, 2013)
142
+
143
+ Misc:
144
+
145
+ - Relaxed haml version requirement
146
+ - Removed dependency on the facets gem
147
+
148
+
149
+ ## 0.0.2 (August 7, 2013)
150
+
151
+ Features:
152
+
153
+ - Added a convenience method to parse and transform at the same time
154
+ - Added examples to README
155
+ - Changed default tags in config
156
+ - Changed @options variable to @attributes in templates to better describe what it is
157
+ - Change the @text variable to @content in templates
158
+
159
+
160
+ ## 0.0.1 (August 5, 2013)
161
+
162
+ Initial Release