parcels 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec-local +4 -0
- data/.travis.yml +54 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/lib/parcels/dependency_parcel_list.rb +50 -0
- data/lib/parcels/environment.rb +60 -0
- data/lib/parcels/fortitude/alongside_engine.rb +37 -0
- data/lib/parcels/fortitude/assets.rb +212 -0
- data/lib/parcels/fortitude/enabling.rb +72 -0
- data/lib/parcels/fortitude/fortitude_engine.rb +35 -0
- data/lib/parcels/fortitude/fortitude_loader.rb +27 -0
- data/lib/parcels/fortitude/widget_engine.rb +31 -0
- data/lib/parcels/fortitude_alongside_parcel.rb +38 -0
- data/lib/parcels/fortitude_inline_parcel.rb +31 -0
- data/lib/parcels/fortitude_parcel.rb +102 -0
- data/lib/parcels/fragments/css_fragment.rb +107 -0
- data/lib/parcels/index.rb +16 -0
- data/lib/parcels/rails/rails_loader.rb +23 -0
- data/lib/parcels/rails/railtie.rb +16 -0
- data/lib/parcels/sprockets.rb +153 -0
- data/lib/parcels/utils/path_utils.rb +32 -0
- data/lib/parcels/version.rb +3 -0
- data/lib/parcels/widget_tree.rb +158 -0
- data/lib/parcels.rb +21 -0
- data/parcels.gemspec +48 -0
- data/spec/helpers/content_in_helpers.rb +21 -0
- data/spec/helpers/file_structure_helpers.rb +79 -0
- data/spec/helpers/global_helper.rb +34 -0
- data/spec/helpers/new_asset_helpers.rb +31 -0
- data/spec/helpers/new_rails_helpers.rb +31 -0
- data/spec/helpers/parcels_rails_helpers.rb +20 -0
- data/spec/helpers/per_example_helpers.rb +15 -0
- data/spec/helpers/sprockets_helpers.rb +23 -0
- data/spec/lib/spec/expected/base_expected_asset.rb +35 -0
- data/spec/lib/spec/expected/expected_asset.rb +135 -0
- data/spec/lib/spec/expected/expected_asset_set.rb +45 -0
- data/spec/lib/spec/expected/must_not_be_present_asset.rb +17 -0
- data/spec/lib/spec/fixtures/file_set.rb +80 -0
- data/spec/lib/spec/fixtures/widget_base.rb +13 -0
- data/spec/lib/spec/fixtures/widget_file.rb +108 -0
- data/spec/lib/spec/parsing/compiled_asset.rb +94 -0
- data/spec/lib/spec/parsing/compiled_asset_fragment.rb +38 -0
- data/spec/lib/spec/parsing/parsed_css_asset.rb +34 -0
- data/spec/lib/spec/parsing/precompiled_rails_asset.rb +52 -0
- data/spec/lib/spec/parsing/rails_asset.rb +30 -0
- data/spec/lib/spec/parsing/sprockets_asset.rb +40 -0
- data/spec/rails/basic_rails_spec.rb +102 -0
- data/spec/rails/compression_rails_spec.rb +11 -0
- data/spec/rails/development_mode_rails_spec.rb +321 -0
- data/spec/rails/sass_rails_spec.rb +125 -0
- data/spec/rails/sets_rails_spec.rb +85 -0
- data/spec/rails/templates/base/app/assets/stylesheets/application.css +16 -0
- data/spec/rails/templates/base/app/views/widgets/base.rb +4 -0
- data/spec/rails/templates/base/config/environments/production.rb +92 -0
- data/spec/rails/templates/base/lib/null_compressor.rb +5 -0
- data/spec/rails/templates/basic_rails_spec/app/controllers/basic_rails_spec_controller.rb +21 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline.pcss +1 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline.rb +9 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline_html.html.pcss +1 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_and_inline_html.html.rb +9 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_erb.pcss +1 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/alongside_erb.rb +7 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/inline_erb.rb +9 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/multiple_engines.pcss +1 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/multiple_engines.rb +9 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/no_corresponding_widget.pcss +1 -0
- data/spec/rails/templates/basic_rails_spec/app/views/basic_rails_spec/simple_css.rb +9 -0
- data/spec/rails/templates/compression_rails_spec/app/controllers/compression_rails_spec_controller.rb +5 -0
- data/spec/rails/templates/compression_rails_spec/app/views/compression_rails_spec/inline_and_alongside_css.pcss +1 -0
- data/spec/rails/templates/compression_rails_spec/app/views/compression_rails_spec/inline_and_alongside_css.rb +9 -0
- data/spec/rails/templates/compression_rails_spec/config/environments/production.rb +91 -0
- data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/changingone.scss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/changingtwo.scss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/assets/stylesheets/import_dir/import_dir_ss_1.scss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/controllers/development_mode_rails_spec_controller.rb +45 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_alongside_css.rb +5 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_inline_css.rb +7 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/adding_widget.rb +5 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/basic_widget_with_inline_and_alongside_parcels.pcss +3 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/basic_widget_with_inline_and_alongside_parcels.rb +9 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_alongside_css.pcss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_alongside_css.rb +5 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_import_file.pcss +2 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_import_file.rb +10 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_inline_css.rb +9 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_prefix_imported_file.pcss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/changing_prefix_imported_file.rb +7 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_alongside_css.pcss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_alongside_css.rb +5 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_inline_css.rb +7 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_widget.pcss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/development_mode_rails_spec/removing_widget.rb +9 -0
- data/spec/rails/templates/development_mode_rails_spec/app/views/import_base.rb +5 -0
- data/spec/rails/templates/development_mode_rails_spec/config/environments/development.rb +37 -0
- data/spec/rails/templates/development_mode_rails_spec/vendor/assets/stylesheets/one.scss +1 -0
- data/spec/rails/templates/development_mode_rails_spec/vendor/assets/stylesheets/two.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/foobar/the_import_dir_2/id2ss1.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/foobar/the_import_dir_2/id2ss2.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/foobar/twelve.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/foobar/two.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/images/quux/foo.png +0 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/eleven.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/one.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/shared_import_dir/sid1ss1.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/shared_import_dir/sid1ss2.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/the_import_dir_1/id1ss1.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/assets/stylesheets/the_import_dir_1/id1ss2.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/controllers/sass_rails_spec_controller.rb +29 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/added_asset_path.pcss +2 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/added_asset_path.rb +10 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/asset_url.pcss +2 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/asset_url.rb +17 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/default_sass_import.pcss +6 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/default_sass_import.rb +14 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_directory.pcss +3 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_directory.rb +11 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_view_relative_directory.pcss +3 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/import_view_relative_directory.rb +11 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/other_features.pcss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/other_features.rb +9 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/shared_imports.rb +10 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_1/vr1ss1.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_1/vr1ss2.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_2/vr2ss1.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/views/sass_rails_spec/vr_import_dir_2/vr2ss2.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/app/views/widgets/import_base.rb +5 -0
- data/spec/rails/templates/sass_rails_spec/config/application.rb +25 -0
- data/spec/rails/templates/sass_rails_spec/lib/more_assets/twenty.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/vendor/assets/stylesheets/thirteen.scss +1 -0
- data/spec/rails/templates/sass_rails_spec/vendor/assets/stylesheets/three.scss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/admin.css.scss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/all.css.scss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/assets/stylesheets/normal.css.scss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/controllers/sets_rails_spec_controller.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_one.pcss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_one.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_two.pcss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/views/admin/admin_two.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/admin/base.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/root.rb +9 -0
- data/spec/rails/templates/sets_rails_spec/app/views/sets_base.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_one.pcss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_one.rb +3 -0
- data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_two.pcss +1 -0
- data/spec/rails/templates/sets_rails_spec/app/views/sets_rails_spec/normal_two.rb +3 -0
- data/spec/system/alongside_file_spec.rb +193 -0
- data/spec/system/autogenerated_class_application_spec.rb +240 -0
- data/spec/system/basic_system_spec.rb +75 -0
- data/spec/system/dependency_sorting_spec.rb +48 -0
- data/spec/system/engines_spec.rb +245 -0
- data/spec/system/prefix_spec.rb +108 -0
- data/spec/system/sass_features_spec.rb +109 -0
- data/spec/system/sets_spec.rb +405 -0
- metadata +477 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 658277fafd37674b7c9be8026a325a2cb907f89c
|
4
|
+
data.tar.gz: a1f74856053841ef8fb0573d246b64a712544c49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a589bcc70801b68c35d4d3b16e2a07e7863a199e211a96ca50f171dac1ea623215ed034084f8efcd7845b827565275eb51d832bd6a8a00bcf8f17f90d6606fcb
|
7
|
+
data.tar.gz: 3005a5072e9d47179a0946ce166626cf6db502f9c99fe1f74b87014b57b2776369c1d04427a7f85be903a3d309d7002ca8a7abdad50d3327f8373343d90d8dd8
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec-local
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- "1.8.7"
|
4
|
+
- "1.9.3"
|
5
|
+
- "2.0.0"
|
6
|
+
- "2.1.5"
|
7
|
+
- "jruby-1.7.17"
|
8
|
+
env:
|
9
|
+
- PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.1.7
|
10
|
+
- PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.0.11
|
11
|
+
- PARCELS_SPECS_SPROCKETS_VERSION=2.2.3 PARCELS_SPECS_RAILS_VERSION=3.2.21
|
12
|
+
- PARCELS_SPECS_SPROCKETS_VERSION=2.0.5 PARCELS_SPECS_RAILS_VERSION=3.1.12
|
13
|
+
before_script:
|
14
|
+
- export JRUBY_OPTS="$JRUBY_OPTS -J-Xmx384m -J-Xms384m -J-Xss2048k"
|
15
|
+
matrix:
|
16
|
+
exclude:
|
17
|
+
# Rails 4.x doesn't support Ruby 1.8.7
|
18
|
+
- rvm: 1.8.7
|
19
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.1.7
|
20
|
+
- rvm: 1.8.7
|
21
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.0.11
|
22
|
+
allow_failures:
|
23
|
+
# 2014-12-14 ageweke -- Unfortunately, there appears to be a bug in Ruby 1.8.7 that conflicts with Sass and
|
24
|
+
# is biting us here. The symptom is that our out-of-process Rails server suddenly crashes, causing various
|
25
|
+
# Rails specs to fail with 'connection refused' or 'end of file' (when reading from the socket) kinds of
|
26
|
+
# errors. If you look in log/rails-server.log in the Rails server directory, you'll see something like
|
27
|
+
# this:
|
28
|
+
#
|
29
|
+
# : [BUG] gc_sweep(): unknown data type 0x0(0x109cd5fa0)
|
30
|
+
# ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin14.0.0]
|
31
|
+
#
|
32
|
+
# There are multiple sources
|
33
|
+
# (https://stackoverflow.com/questions/3844794/server-failure-bug-gc-sweep-unknown-data-type-0x0,
|
34
|
+
# https://github.com/sass/sass/issues/581, etc.)
|
35
|
+
# indicating that other people have hit this repeatedly, and we don't seem to ever see it on other Ruby
|
36
|
+
# versions.
|
37
|
+
#
|
38
|
+
# Since 1.8.7 is very old as of this writing, while I'd like to keep officially supporting it, I'm going to
|
39
|
+
# keep running these tests but monitor them manually, to see if anything *other* than the Rails specs
|
40
|
+
# starts failing.
|
41
|
+
- rvm: 1.8.7
|
42
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.2.3 PARCELS_SPECS_RAILS_VERSION=3.2.21
|
43
|
+
- rvm: 1.8.7
|
44
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.0.5 PARCELS_SPECS_RAILS_VERSION=3.1.12
|
45
|
+
# 2014-12-14 ageweke -- Just like Fortitude, getting Travis to actually do reliable JRuby specs seems to be
|
46
|
+
# impossible, sadly.
|
47
|
+
- rvm: jruby-1.7.17
|
48
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.1.7
|
49
|
+
- rvm: jruby-1.7.17
|
50
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.11.3 PARCELS_SPECS_RAILS_VERSION=4.0.11
|
51
|
+
- rvm: jruby-1.7.17
|
52
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.2.3 PARCELS_SPECS_RAILS_VERSION=3.2.21
|
53
|
+
- rvm: jruby-1.7.17
|
54
|
+
env: PARCELS_SPECS_SPROCKETS_VERSION=2.0.5 PARCELS_SPECS_RAILS_VERSION=3.1.12
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andrew Geweke
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Parcels
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'parcels'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install parcels
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/parcels/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'tsort'
|
2
|
+
|
3
|
+
module Parcels
|
4
|
+
class DependencyParcelList
|
5
|
+
def initialize
|
6
|
+
@tag_to_child_tag_map = { }
|
7
|
+
@parcel_to_tag_map = { }
|
8
|
+
@tag_to_parcel_map = { }
|
9
|
+
|
10
|
+
@loose_parcels = [ ]
|
11
|
+
end
|
12
|
+
|
13
|
+
def tsort_each_node(&block)
|
14
|
+
parcel_to_tag_map.keys.each(&block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def tsort_each_child(parcel, &block)
|
18
|
+
tag = parcel_to_tag_map[parcel]
|
19
|
+
child_tags = tag_to_child_tag_map[tag] || [ ]
|
20
|
+
child_parcels = child_tags.map { |t| tag_to_parcel_map[t] }.compact
|
21
|
+
|
22
|
+
child_parcels.each(&block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_parcels!(parcels)
|
26
|
+
parcels.each do |parcel|
|
27
|
+
if parcel.tag
|
28
|
+
parcel_to_tag_map[parcel] = parcel.tag
|
29
|
+
tag_to_parcel_map[parcel.tag] = parcel
|
30
|
+
|
31
|
+
parcel.tags_that_must_come_before.each do |tag_that_must_come_before|
|
32
|
+
tag_to_child_tag_map[tag_that_must_come_before] ||= [ ]
|
33
|
+
tag_to_child_tag_map[tag_that_must_come_before] << parcel.tag
|
34
|
+
end
|
35
|
+
else
|
36
|
+
loose_parcels << parcel
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def parcels_in_order
|
42
|
+
tsort.reverse # tsort puts children before parents; we want the exact opposite
|
43
|
+
end
|
44
|
+
|
45
|
+
include TSort
|
46
|
+
|
47
|
+
private
|
48
|
+
attr_reader :tag_to_child_tag_map, :parcel_to_tag_map, :tag_to_parcel_map, :loose_parcels
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'parcels/widget_tree'
|
2
|
+
|
3
|
+
module Parcels
|
4
|
+
class Environment
|
5
|
+
attr_reader :sprockets_environment
|
6
|
+
|
7
|
+
delegate :root, :to => :sprockets_environment
|
8
|
+
|
9
|
+
def initialize(sprockets_environment)
|
10
|
+
@sprockets_environment = sprockets_environment
|
11
|
+
@widget_trees = [ ]
|
12
|
+
|
13
|
+
register_engines!
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_underneath_root?(filename)
|
17
|
+
filename = File.expand_path(filename)
|
18
|
+
filename.length > root.length && filename[0..(root.length - 1)] == root
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_widget_tree!(widget_tree_root)
|
22
|
+
widget_tree_root = File.expand_path(widget_tree_root, root)
|
23
|
+
widget_tree = widget_trees.detect { |wt| wt.root == widget_tree_root }
|
24
|
+
|
25
|
+
if (! widget_tree)
|
26
|
+
widget_tree = WidgetTree.new(self, widget_tree_root)
|
27
|
+
widget_trees << widget_tree
|
28
|
+
end
|
29
|
+
|
30
|
+
widget_tree.add_workaround_directory_to_sprockets!(sprockets_environment)
|
31
|
+
end
|
32
|
+
|
33
|
+
def widget_class_from_file(pathname)
|
34
|
+
::Fortitude::Widget.widget_class_from_file(pathname, :root_dirs => widget_trees.map(&:root))
|
35
|
+
end
|
36
|
+
|
37
|
+
def create_and_add_all_workaround_directories!
|
38
|
+
# widget_trees.each do |widget_tree|
|
39
|
+
# widget_tree.add_workaround_directory_to_sprockets!(sprockets_environment)
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_all_widgets_to!(sprockets_context, set_names)
|
44
|
+
widget_trees.each { |wt| wt.add_all_widgets_to_sprockets_context!(sprockets_context, set_names) }
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
attr_reader :widget_trees
|
49
|
+
|
50
|
+
def register_engines!
|
51
|
+
@engines_registered ||= begin
|
52
|
+
if ::Parcels.fortitude_available?
|
53
|
+
@sprockets_environment.register_engine '.rb', ::Parcels::Fortitude::WidgetEngine
|
54
|
+
@sprockets_environment.register_engine '.pcss', ::Parcels::Fortitude::AlongsideEngine
|
55
|
+
end
|
56
|
+
true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Parcels
|
4
|
+
module Fortitude
|
5
|
+
class AlongsideEngine < Tilt::Template
|
6
|
+
self.default_mime_type = 'text/css'
|
7
|
+
|
8
|
+
def self.engine_initialized?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_engine
|
13
|
+
require_template_library 'fortitude'
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare
|
17
|
+
end
|
18
|
+
|
19
|
+
def evaluate(context, locals, &block)
|
20
|
+
parcels_environment = context.environment.parcels
|
21
|
+
widget_file = ::Parcels::Utils::PathUtils.widget_class_file_for_alongside_file(context.pathname)
|
22
|
+
|
23
|
+
unless widget_file
|
24
|
+
raise Errno::ENOENT, "Somehow, we're being asked to render CSS from #{context.pathname.to_s.inspect}, but we can't find a Fortitude widget class next to that file"
|
25
|
+
end
|
26
|
+
|
27
|
+
widget_class = parcels_environment.widget_class_from_file(widget_file)
|
28
|
+
|
29
|
+
if widget_class
|
30
|
+
widget_class._parcels_widget_class_alongside_css(parcels_environment, context)
|
31
|
+
else
|
32
|
+
""
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/concern'
|
3
|
+
|
4
|
+
require 'parcels/fragments/css_fragment'
|
5
|
+
|
6
|
+
require 'sass'
|
7
|
+
|
8
|
+
module Parcels
|
9
|
+
module Fortitude
|
10
|
+
module Assets
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def inherited(new_class)
|
15
|
+
super(new_class)
|
16
|
+
|
17
|
+
if respond_to?(:caller_locations, true) && false
|
18
|
+
locations = caller_locations(1, 1)
|
19
|
+
filename = locations.first.absolute_path
|
20
|
+
new_class._parcels_inherited_called_from(filename)
|
21
|
+
else
|
22
|
+
string = caller[0]
|
23
|
+
if string =~ /^([^:]+):\d+/
|
24
|
+
new_class._parcels_inherited_called_from($1)
|
25
|
+
else
|
26
|
+
raise "Parcels: #{new_class} inherited from #{self.name}, but caller string was unparseable: '#{string}'"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def _parcels_inherited_called_from(filename)
|
32
|
+
@_parcels_class_definition_files ||= [ ]
|
33
|
+
@_parcels_class_definition_files << filename
|
34
|
+
end
|
35
|
+
|
36
|
+
def _parcels_class_definition_files
|
37
|
+
@_parcels_class_definition_files ||= [ ]
|
38
|
+
end
|
39
|
+
|
40
|
+
def _parcels_widget_outer_element_classes
|
41
|
+
@_parcels_widget_outer_element_classes ||= begin
|
42
|
+
out = [ ]
|
43
|
+
out << _parcels_widget_outer_element_class if _parcels_wrapping_css_class_required?
|
44
|
+
out += superclass._parcels_widget_outer_element_classes if superclass.respond_to?(:parcels_enabled?) && superclass.parcels_enabled?
|
45
|
+
out
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def _parcels_css_fragments
|
50
|
+
_parcels_alongside_css_fragments + _parcels_inline_css_fragments
|
51
|
+
end
|
52
|
+
|
53
|
+
def _parcels_widget_outer_element_class
|
54
|
+
@_parcels_widget_outer_element_class ||= begin
|
55
|
+
class_suffix = self.name.gsub('::', '__').underscore.gsub(/[^A-Za-z0-9_]/, '_')
|
56
|
+
|
57
|
+
"parcels_class__#{class_suffix}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def _parcels_widget_class_css(parcels_environment, context)
|
62
|
+
::Parcels::Fragments::CssFragment.to_css(parcels_environment, context, _parcels_css_fragments)
|
63
|
+
end
|
64
|
+
|
65
|
+
def _parcels_widget_class_inline_css(parcels_environment, context)
|
66
|
+
::Parcels::Fragments::CssFragment.to_css(parcels_environment, context, _parcels_inline_css_fragments)
|
67
|
+
end
|
68
|
+
|
69
|
+
def _parcels_widget_class_alongside_css(parcels_environment, context)
|
70
|
+
::Parcels::Fragments::CssFragment.to_css(parcels_environment, context, _parcels_alongside_css_fragments)
|
71
|
+
end
|
72
|
+
|
73
|
+
def _parcels_wrapping_css_class_required?
|
74
|
+
_parcels_css_fragments.detect { |f| f.wrapping_css_class_required? }
|
75
|
+
end
|
76
|
+
|
77
|
+
def _parcels_alongside_css_fragments
|
78
|
+
options = { :prefix => _parcels_get_css_prefix }.merge(_parcels_css_options)
|
79
|
+
_parcels_alongside_filenames.map do |filename|
|
80
|
+
if File.exist?(filename)
|
81
|
+
::Parcels::Fragments::CssFragment.new(File.read(filename), self, filename, 1, options)
|
82
|
+
end
|
83
|
+
end.compact
|
84
|
+
end
|
85
|
+
|
86
|
+
def _parcels_alongside_filenames
|
87
|
+
out = [ ]
|
88
|
+
|
89
|
+
_parcels_class_definition_files.each do |filename|
|
90
|
+
filename = $1 if filename =~ /^(.*)\.rb$/i
|
91
|
+
out << "#{filename}.pcss"
|
92
|
+
end
|
93
|
+
|
94
|
+
out.select { |f| File.file?(f) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def _parcels_add_wrapper_css_classes_to(attributes, wrapper_classes)
|
98
|
+
out = attributes || { }
|
99
|
+
key = out.key?('class') ? 'class' : :class
|
100
|
+
out[key] = Array(out[key]) + wrapper_classes
|
101
|
+
out
|
102
|
+
end
|
103
|
+
|
104
|
+
def _parcels_inline_css_fragments
|
105
|
+
@_parcels_inline_css_fragments ||= [ ]
|
106
|
+
end
|
107
|
+
|
108
|
+
def css_options(options)
|
109
|
+
raise ArgumentError, "You must pass a Hash to css_options, not: #{options.inspect}" unless options.kind_of?(Hash)
|
110
|
+
options.assert_valid_keys(:engines)
|
111
|
+
|
112
|
+
@_parcels_css_options = options
|
113
|
+
end
|
114
|
+
|
115
|
+
def _parcels_css_options
|
116
|
+
out = @_parcels_css_options
|
117
|
+
out ||= superclass._parcels_css_options if superclass.respond_to?(:_parcels_css_options)
|
118
|
+
out || { }
|
119
|
+
end
|
120
|
+
|
121
|
+
def css(*css_strings)
|
122
|
+
unless parcels_enabled?
|
123
|
+
klass = self
|
124
|
+
superclasses = all_fortitude_superclasses
|
125
|
+
|
126
|
+
raise %{Before using this Parcels method, you must first enable Parcels on this class. Simply
|
127
|
+
call 'enable_parcels!', a class method, on the base widget class you want to enable -- typically, this
|
128
|
+
is your base Fortitude widget class.
|
129
|
+
|
130
|
+
This class is #{klass.name};
|
131
|
+
you may want to enable Parcels on any of its Fortitude superclasses, which are:
|
132
|
+
#{superclasses.map(&:name).join("\n")}}
|
133
|
+
end
|
134
|
+
|
135
|
+
options = { :prefix => _parcels_get_css_prefix }
|
136
|
+
options.merge!(css_strings.extract_options!)
|
137
|
+
|
138
|
+
caller_line = caller[0]
|
139
|
+
if caller_line =~ /^(.*)\s*:\s*(\d+)\s*:\s*in\s+/i
|
140
|
+
caller_file = $1
|
141
|
+
caller_line = Integer($2)
|
142
|
+
else
|
143
|
+
caller_file = caller_line
|
144
|
+
caller_line = nil
|
145
|
+
end
|
146
|
+
|
147
|
+
@_parcels_inline_css_fragments ||= [ ]
|
148
|
+
@_parcels_inline_css_fragments += css_strings.map do |css_string|
|
149
|
+
::Parcels::Fragments::CssFragment.new(css_string, self, caller_file, caller_line, _parcels_css_options.merge(options))
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def css_prefix(prefix = nil, &block)
|
154
|
+
if (prefix && block)
|
155
|
+
raise ArgumentError, "You can supply either a String or a block, but not both; you passed: #{prefix.inspect} and #{block.inspect}"
|
156
|
+
end
|
157
|
+
|
158
|
+
if (prefix != nil) && (! prefix.kind_of?(String))
|
159
|
+
raise ArgumentError, "Invalid prefix (must be a String, or nil): #{prefix.inspect}"
|
160
|
+
end
|
161
|
+
|
162
|
+
@_parcels_css_prefix = prefix || block
|
163
|
+
end
|
164
|
+
|
165
|
+
def parcels_sets(*set_names, &block)
|
166
|
+
if set_names.length > 0 && block
|
167
|
+
raise ArgumentError, "You can specify either a set name or a block, but not both; you passed: #{set_names.inspect} and #{block.inspect}"
|
168
|
+
end
|
169
|
+
|
170
|
+
if set_names == [ nil ]
|
171
|
+
@_parcels_sets = [ ]
|
172
|
+
else
|
173
|
+
@_parcels_sets = block || set_names.map(&:to_sym)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def _parcels_get_sets(defining_file_path)
|
178
|
+
_parcels_get_sets_for_class(self, defining_file_path)
|
179
|
+
end
|
180
|
+
|
181
|
+
def _parcels_get_sets_for_class(klass, defining_file_path)
|
182
|
+
if @_parcels_sets
|
183
|
+
out = @_parcels_sets
|
184
|
+
out = out.call(klass, defining_file_path) if out.respond_to?(:call)
|
185
|
+
out = Array(out).map(&:to_sym)
|
186
|
+
out
|
187
|
+
elsif superclass.respond_to?(:_parcels_get_sets_for_class)
|
188
|
+
superclass._parcels_get_sets_for_class(klass, defining_file_path)
|
189
|
+
else
|
190
|
+
[ ]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def _parcels_get_css_prefix
|
195
|
+
_parcels_get_css_prefix_for_class(self)
|
196
|
+
end
|
197
|
+
|
198
|
+
def _parcels_get_css_prefix_for_class(klass)
|
199
|
+
if @_parcels_css_prefix
|
200
|
+
out = @_parcels_css_prefix
|
201
|
+
out = out.call(klass) if out.respond_to?(:call)
|
202
|
+
out
|
203
|
+
elsif superclass.respond_to?(:_parcels_get_css_prefix_for_class)
|
204
|
+
superclass._parcels_get_css_prefix_for_class(klass)
|
205
|
+
else
|
206
|
+
nil
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/concern'
|
3
|
+
|
4
|
+
module Parcels
|
5
|
+
module Fortitude
|
6
|
+
module Enabling
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def parcels_enabled?
|
11
|
+
out = false
|
12
|
+
out = true if superclass.respond_to?(:parcels_enabled?) && superclass.parcels_enabled?
|
13
|
+
out = true if @_parcels_enabled
|
14
|
+
out
|
15
|
+
end
|
16
|
+
|
17
|
+
def enable_parcels!
|
18
|
+
raise "Already enabled on #{self}!" if @_parcels_enabled
|
19
|
+
|
20
|
+
record_tag_emission true
|
21
|
+
|
22
|
+
@_parcels_tag_methods_module = Module.new
|
23
|
+
const_set(:ParcelsEnablingModule, @_parcels_tag_methods_module)
|
24
|
+
include @_parcels_tag_methods_module
|
25
|
+
|
26
|
+
_parcels_ensure_all_tag_methods_overridden!
|
27
|
+
|
28
|
+
@_parcels_enabled = true
|
29
|
+
end
|
30
|
+
|
31
|
+
def tags_changed!(tags)
|
32
|
+
super
|
33
|
+
_parcels_ensure_all_tag_methods_overridden! if parcels_enabled?
|
34
|
+
end
|
35
|
+
|
36
|
+
def _parcels_tag_method_overridden?(tag_name)
|
37
|
+
@_parcels_tag_methods_overridden ||= { }
|
38
|
+
@_parcels_tag_methods_overridden[tag_name.to_sym]
|
39
|
+
end
|
40
|
+
|
41
|
+
def _parcels_tag_method_overridden!(tag_name)
|
42
|
+
@_parcels_tag_methods_overridden[tag_name.to_sym] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
def _parcels_ensure_all_tag_methods_overridden!
|
46
|
+
tags.each do |tag_name, tag_object|
|
47
|
+
done = _parcels_tag_method_overridden?(tag_name)
|
48
|
+
next if done
|
49
|
+
|
50
|
+
tag_object.all_method_names.each do |tag_method_name|
|
51
|
+
@_parcels_tag_methods_module.send(:define_method, tag_method_name) do |*args, &block|
|
52
|
+
content_or_attributes = args[0]
|
53
|
+
attributes = args[1]
|
54
|
+
|
55
|
+
directly_inside = rendering_context.current_element_nesting.last
|
56
|
+
if directly_inside.kind_of?(::Fortitude::Widget) && (css_wrapper_classes = directly_inside.class.try(:_parcels_widget_outer_element_classes))
|
57
|
+
if attributes || content_or_attributes.kind_of?(String)
|
58
|
+
super(content_or_attributes, self.class._parcels_add_wrapper_css_classes_to(attributes, css_wrapper_classes), &block)
|
59
|
+
else
|
60
|
+
super(self.class._parcels_add_wrapper_css_classes_to(content_or_attributes, css_wrapper_classes), attributes, &block)
|
61
|
+
end
|
62
|
+
else
|
63
|
+
super(content_or_attributes, attributes, &block)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Parcels
|
4
|
+
module Fortitude
|
5
|
+
class FortitudeEngine < Tilt::Template
|
6
|
+
self.default_mime_type = 'text/css'
|
7
|
+
|
8
|
+
def self.engine_initialized?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_engine
|
13
|
+
require_template_library 'fortitude'
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare
|
17
|
+
end
|
18
|
+
|
19
|
+
def evaluate(context, locals, &block)
|
20
|
+
parcels_environment = context.environment.parcels
|
21
|
+
widget_class = parcels_environment.widget_class_from_file(context.pathname)
|
22
|
+
|
23
|
+
if widget_class
|
24
|
+
css_from_widget_class(widget_class, parcels_environment, context)
|
25
|
+
else
|
26
|
+
""
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def css_from_widget_class(widget_class, parcels_environment, context)
|
31
|
+
raise "must implement in #{self.class.name}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# See if we can load Fortitude -- but don't fail if we can't; we'll just use this to decide whether we should
|
2
|
+
# load the Fortitude extensions or not.
|
3
|
+
begin
|
4
|
+
gem 'fortitude'
|
5
|
+
rescue Gem::LoadError => le
|
6
|
+
# ok
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'fortitude'
|
11
|
+
rescue LoadError => le
|
12
|
+
# ok
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(::Fortitude)
|
16
|
+
require 'parcels/fortitude/assets'
|
17
|
+
require 'parcels/fortitude/enabling'
|
18
|
+
require 'parcels/fortitude/widget_engine'
|
19
|
+
require 'parcels/fortitude/alongside_engine'
|
20
|
+
|
21
|
+
::Fortitude::Widget.class_eval do
|
22
|
+
include ::Parcels::Fortitude::Assets
|
23
|
+
include ::Parcels::Fortitude::Enabling
|
24
|
+
end
|
25
|
+
|
26
|
+
::Parcels.fortitude_available!
|
27
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Parcels
|
4
|
+
module Fortitude
|
5
|
+
class WidgetEngine < Tilt::Template
|
6
|
+
self.default_mime_type = 'text/css'
|
7
|
+
|
8
|
+
def self.engine_initialized?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_engine
|
13
|
+
require_template_library 'fortitude'
|
14
|
+
end
|
15
|
+
|
16
|
+
def prepare
|
17
|
+
end
|
18
|
+
|
19
|
+
def evaluate(context, locals, &block)
|
20
|
+
parcels_environment = context.environment.parcels
|
21
|
+
widget_class = parcels_environment.widget_class_from_file(context.pathname)
|
22
|
+
|
23
|
+
if widget_class
|
24
|
+
widget_class._parcels_widget_class_inline_css(parcels_environment, context)
|
25
|
+
else
|
26
|
+
""
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|