middleman-targets 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.md +7 -0
  5. data/README.md +21 -4
  6. data/Rakefile +12 -6
  7. data/documentation_project/Gemfile +1 -1
  8. data/documentation_project/config.rb +7 -7
  9. data/documentation_project/source/helpers-resources.html.md.erb +14 -66
  10. data/documentation_project/source/partials/config.erb +326 -0
  11. data/documentation_project/source/partials/helpers.erb +354 -0
  12. data/documentation_project/source/partials/resources.erb +100 -0
  13. data/documentation_project/source/stylesheets/_middlemac_minimal.scss +283 -1
  14. data/documentation_project/source/target-feature-config.html.md.erb +6 -36
  15. data/features/build_target_option.feature +42 -0
  16. data/features/helpers_and_resources.feature +44 -0
  17. data/features/server_target_option.feature +42 -0
  18. data/features/support/env.rb +20 -0
  19. data/fixtures/middleman_targets_app/config.rb +33 -0
  20. data/fixtures/middleman_targets_app/source/all-root-logo.png +0 -0
  21. data/fixtures/middleman_targets_app/source/all-root.png +0 -0
  22. data/fixtures/middleman_targets_app/source/free-root.png +0 -0
  23. data/fixtures/middleman_targets_app/source/images/all-image.png +0 -0
  24. data/fixtures/middleman_targets_app/source/images/all-logo.png +0 -0
  25. data/fixtures/middleman_targets_app/source/images/free-image.png +0 -0
  26. data/fixtures/middleman_targets_app/source/images/pro-image.png +0 -0
  27. data/fixtures/middleman_targets_app/source/index.html.md.erb +35 -0
  28. data/fixtures/middleman_targets_app/source/pro-root.png +0 -0
  29. data/lib/middleman-targets/extension.rb +182 -54
  30. data/lib/middleman-targets/middleman-cli/build_all.rb +5 -6
  31. data/lib/middleman-targets/version.rb +1 -1
  32. data/middleman-targets.gemspec +9 -2
  33. data/yard/readme.md +6 -0
  34. data/yard/templates/default/fulldoc/html/css/common.css +1 -0
  35. data/yard/templates/default/fulldoc/html/css/full_list.css +57 -0
  36. data/yard/templates/default/fulldoc/html/css/style.css +343 -0
  37. data/yard/templates/default/onefile/html/files.erb +5 -0
  38. data/yard/templates/default/onefile/html/headers.erb +6 -0
  39. data/yard/templates/default/onefile/html/layout.erb +17 -0
  40. data/yard/templates/default/onefile/html/readme.erb +3 -0
  41. data/yard/templates/default/onefile/html/setup.rb +61 -0
  42. data/yard/yard_extensions.rb +73 -0
  43. metadata +83 -3
@@ -51,7 +51,7 @@ html
51
51
 
52
52
  body
53
53
  {
54
- font-family: -apple-system-font, -webkit-system-font, "HelveticaNeue", "Helvetica Neue", "Helvetica", sans-serif;
54
+ font-family: -apple-system-font, -webkit-system-font, "HelveticaNeue", "Helvetica Neue", "Helvetica", sans-serif;
55
55
  height: 100%;
56
56
  min-width: 600px;
57
57
  }
@@ -514,3 +514,285 @@ div.image_article:after
514
514
  display: table;
515
515
  clear: both;
516
516
  }
517
+
518
+
519
+ //*************************************
520
+ // For partials extracted from YARD
521
+ //*************************************
522
+
523
+ $yard_color_symbol: rgba(0,136,204,1);
524
+ $yard_font_mono: Menlo, Consolas, Monaco, Courier, monospace;
525
+
526
+ div.attr_details,
527
+ div.method_details_list
528
+ {
529
+ .inline
530
+ {
531
+ display: inline;
532
+
533
+ p:first-child
534
+ {
535
+ display: inline;
536
+ }
537
+ }
538
+
539
+ .method_details
540
+ {
541
+ border-top: 1px dotted #aaa;
542
+ margin-top: 15px;
543
+ padding-top: 0;
544
+
545
+ &.first
546
+ {
547
+ border: 0;
548
+ }
549
+ }
550
+
551
+ p.signature,
552
+ h3.signature
553
+ {
554
+ font-size: 0.9em;
555
+ font-weight: normal;
556
+ font-family: $yard_font_mono;
557
+ padding: 6px 10px;
558
+ margin-top: 18px;
559
+ background: #f2f3ff;
560
+ border: 1px solid #d8d8e5;
561
+ -moz-border-radius: 3px;
562
+ -webkit-border-radius: 3px;
563
+ color: $yard_color_symbol;
564
+
565
+ strong
566
+ {
567
+ color: inherit;;
568
+ }
569
+
570
+ tt
571
+ {
572
+ font-family: inherit;
573
+ }
574
+
575
+ .overload
576
+ {
577
+ display: block;
578
+ }
579
+
580
+ .extras
581
+ {
582
+ font-weight: normal;
583
+ font-family: sans-serif;
584
+ color: #444;
585
+ font-size: 1em;
586
+ }
587
+
588
+ .not_defined_here,
589
+ .aliases
590
+ {
591
+ display: block;
592
+ font-weight: normal;
593
+ font-size: 0.9em;
594
+ font-family: $yard_font_mono;
595
+ margin-top: 0px;
596
+ color: #555;
597
+
598
+ .names
599
+ {
600
+ font-family: $yard_font_mono;
601
+ font-weight: bold;
602
+ color: #000;
603
+ font-size: 1.2em;
604
+ }
605
+ }
606
+ }
607
+
608
+ div.docstring
609
+ {
610
+ div.discussion
611
+ {
612
+
613
+ }
614
+ }
615
+
616
+ div.tags
617
+ {
618
+ margin-bottom: 12px;
619
+
620
+ .tag_title
621
+ {
622
+ font-size: 1em;
623
+ margin-bottom: 0;
624
+ font-weight: bold; }
625
+
626
+ ul
627
+ {
628
+ margin-top: 5px;
629
+ padding-left: 30px;
630
+ list-style: square;
631
+
632
+ li {
633
+ margin-bottom: 3px;
634
+ }
635
+
636
+ .name
637
+ {
638
+ font-family: $yard_font_mono;
639
+ font-weight: bold;
640
+ }
641
+
642
+ .note
643
+ {
644
+ padding: 3px 6px;
645
+ }
646
+
647
+ }
648
+
649
+ .examples
650
+ {
651
+ .tag_title
652
+ {
653
+ margin-bottom: 10px;
654
+ font-weight: bold;
655
+ }
656
+
657
+ .inline p
658
+ {
659
+ padding: 0;
660
+ margin: 0;
661
+ margin-left: 15px;
662
+ font-weight: bold;
663
+ font-size: 0.9em;
664
+ }
665
+ }
666
+
667
+ .overload
668
+ {
669
+ .overload_item
670
+ {
671
+ list-style: none;
672
+ margin-bottom: 25px;
673
+
674
+ .signature
675
+ {
676
+ padding: 2px 8px;
677
+ background: #e5e8ff;
678
+ border: 1px solid #d8d8e5;
679
+ -moz-border-radius: 3px;
680
+ -webkit-border-radius: 3px;
681
+ }
682
+ }
683
+
684
+ .signature
685
+ { margin-left: -15px;
686
+ font-family: monospace;
687
+ display: block;
688
+ font-size: 1.1em;
689
+ }
690
+
691
+ .docstring
692
+ {
693
+ margin-top: 15px;
694
+ }
695
+
696
+ }
697
+
698
+ /* syntax highlighting */
699
+ //.source_code { display: none; padding: 3px 8px; border-left: 8px solid #ddd; margin-top: 5px; }
700
+ //#filecontents pre.code, .docstring pre.code, .source_code pre { font-family: monospace; }
701
+ //#filecontents pre.code, .docstring pre.code { display: block; }
702
+ //.source_code .lines { padding-right: 12px; color: #555; text-align: right; }
703
+
704
+ #filecontents pre.code,
705
+ .docstring pre.code,
706
+ pre.example
707
+ {
708
+ padding: 5px 12px; margin-top: 4px; border: 1px solid #eef; background: #f5f5ff;
709
+ }
710
+
711
+ pre.code
712
+ {
713
+ color: #000;
714
+
715
+ info.file { color: #555; }
716
+
717
+ .val { color: #036A07; }
718
+
719
+ .tstring_content,
720
+ .heredoc_beg,
721
+ .heredoc_end,
722
+ .qwords_beg,
723
+ .qwords_end,
724
+ .tstring,
725
+ .dstring
726
+ {
727
+ color: #036A07;
728
+ }
729
+
730
+ .fid,
731
+ .rubyid_new,
732
+ .rubyid_to_s,
733
+ .rubyid_to_sym,
734
+ .rubyid_to_f,
735
+ .dot + pre.code .id,
736
+ .rubyid_to_i pre.code .rubyid_each
737
+ {
738
+ color: #0085FF;
739
+ }
740
+
741
+ .comment
742
+ {
743
+ color: #0066FF;
744
+ }
745
+
746
+ .const,
747
+ .constant
748
+ {
749
+ color: #585CF6;
750
+ }
751
+
752
+ .label,
753
+ .symbol
754
+ {
755
+ color: #C5060B;
756
+ }
757
+
758
+ .kw,
759
+ .rubyid_require,
760
+ .rubyid_extend,
761
+ .rubyid_include
762
+ {
763
+ color: #0000FF;
764
+ }
765
+
766
+ .ivar
767
+ {
768
+ color: #318495;
769
+ }
770
+
771
+ .gvar,
772
+ .rubyid_backref,
773
+ .rubyid_nth_ref
774
+ {
775
+ color: #6D79DE;
776
+ }
777
+
778
+ .regexp,
779
+ .dregexp
780
+ {
781
+ color: #036A07;
782
+ }
783
+
784
+ a
785
+ {
786
+ border-bottom: 1px dotted #bbf;
787
+ }
788
+
789
+ }
790
+ }
791
+
792
+ table.source_code
793
+ {
794
+ display: none;
795
+ }
796
+
797
+
798
+ }
@@ -35,40 +35,10 @@ activate them _before_ activating `middleman-targets`.
35
35
 
36
36
  ## The Configuration Options
37
37
 
38
- `target`
38
+ <%= partial 'partials/config' %>
39
39
 
40
- : This is the target that is used automatically when you `middleman build`
41
- or `middleman server` without using the `--targets` option from the
42
- command line.
40
+ * * *
43
41
 
44
- `targets`
45
-
46
- : The `targets` key is a comprehensive list of your targets, their features,
47
- and other data pertinent to your targets.
48
-
49
- All of the keys contained in this structure are described in the next
50
- section, below.
51
-
52
- `target_magic_images`
53
- `target_magic_word`
54
-
55
- : By enabling `target_magic_images` and using `middleman-targets`’ image
56
- helper, target specific images will be used instead of the image you
57
- specify, *if* that image name is prefixed with `target_magic_word`. For
58
- example, you might request `all-my_image.png`, and `pro-my_image.png` (if it
59
- exists) will be used in your :pro target instead.
60
-
61
- Important: when this is enabled, images from *other* targets will *not* be
62
- included in the build! In the example above, *any* image prefixed with
63
- `free-` would not be included in the output directory.
64
-
65
- `build_dir`
66
-
67
- : Build output will use this directory as a *prefix*; if the target
68
- is `:pro`, then the actual build directory will be `build (pro)/`. If the
69
- `build_dir` key is present for any of the `targets`, they will override this
70
- setting.
71
-
72
42
  ## The `targets` key by example
73
43
 
74
44
  The code below is the actual `targets` key for this sample project. We’ll look
@@ -77,7 +47,7 @@ defined, and how you can effect your build output directory as well as add
77
47
  other arbitrary data to each target.
78
48
 
79
49
  ~~~ ruby
80
- set :targets, {
50
+ config[:targets] = {
81
51
  :free =>
82
52
  {
83
53
  :sample_key => 'People who use free versions don\'t drive profits.',
@@ -109,14 +79,14 @@ Looking at the top level of this structure you can see that there are two
109
79
  targets defined: `free` and `pro`. Nested within each of them are a series of
110
80
  additional keys.
111
81
 
112
- `sample_key`
82
+ `:sample_key`
113
83
 
114
84
  : This is an example data key associated with each target. You can specify as
115
85
  many as you wish using any naming convention that suits you. Target-specific
116
86
  values can be retrieved in your pages using the `target_value`
117
87
  [helper](helpers-resources.html).
118
88
 
119
- `build_dir`
89
+ `:build_dir`
120
90
 
121
91
  : When used for a target then this specified directory overrides the Middleman
122
92
  `build_dir` setting. Note that in this project only the `free` target
@@ -127,7 +97,7 @@ additional keys.
127
97
  a single `%s` **sprintf** placeholder which will be filled with the target
128
98
  name during build, as shown in this example.
129
99
 
130
- `features`
100
+ `:features`
131
101
 
132
102
  : This key is where you define the features that are pertinent to each of your
133
103
  targets, as well as enable or disable them.
@@ -0,0 +1,42 @@
1
+ Feature: Build with various target options.
2
+
3
+ As a software developer
4
+ I want to build output with different targets
5
+ In order to deploy different versions of my project
6
+
7
+ Scenario: Build with the default target (pro)
8
+ Given a fixture app "middleman_targets_app"
9
+ When I run `middleman build` interactively
10
+ And I stop middleman if the output contains:
11
+ """
12
+ Project built successfully.
13
+ """
14
+ Then the output should contain:
15
+ """
16
+ Middleman will build using target "pro".
17
+ """
18
+
19
+ Scenario: Build with --target pro
20
+ Given a fixture app "middleman_targets_app"
21
+ When I run `middleman build --target pro` interactively
22
+ And I stop middleman if the output contains:
23
+ """
24
+ Project built successfully.
25
+ """
26
+ Then the output should contain:
27
+ """
28
+ Middleman will build using target "pro".
29
+ """
30
+
31
+ Scenario: Build with --target free
32
+ Given a fixture app "middleman_targets_app"
33
+ When I run `middleman build --target free` interactively
34
+ And I stop middleman if the output contains:
35
+ """
36
+ Project built successfully.
37
+ """
38
+ Then the output should contain:
39
+ """
40
+ Middleman will build using target "free".
41
+ """
42
+
@@ -0,0 +1,44 @@
1
+ Feature: Provide helpers and resource items to make multiple targets easy to manage.
2
+
3
+ As a software developer
4
+ I want to use helpers and resource items
5
+ In order to deploy different versions of my project
6
+
7
+ Scenario: Build with the default target
8
+ Given a built app at "middleman_targets_app"
9
+ When I cd to "custom_build_dir (pro)"
10
+ And the file "index.html" should contain "Insult: NO"
11
+ And the file "index.html" should contain "TargetName: pro"
12
+ And the file "index.html" should contain "TargetFree: NO"
13
+ And the file "index.html" should contain "TargetValueForSampleKey: You are a valued contributor to our balance sheet!"
14
+ And the file "index.html" should contain "CurrentPageValidFeatures: [:grants_wishes]"
15
+ And the file "index.html" should contain 'src="/pro-root.png"'
16
+ And the file "index.html" should contain 'src="/all-root-logo.png"'
17
+ And the file "index.html" should contain 'src="/images/pro-image.png"'
18
+ And the file "index.html" should contain 'src="/images/all-logo.png"'
19
+
20
+ Scenario: Build with --target pro
21
+ Given a built app at "middleman_targets_app" with flags "--target pro"
22
+ When I cd to "custom_build_dir (pro)"
23
+ And the file "index.html" should contain "Insult: NO"
24
+ And the file "index.html" should contain "TargetName: pro"
25
+ And the file "index.html" should contain "TargetFree: NO"
26
+ And the file "index.html" should contain "TargetValueForSampleKey: You are a valued contributor to our balance sheet!"
27
+ And the file "index.html" should contain "CurrentPageValidFeatures: [:grants_wishes]"
28
+ And the file "index.html" should contain 'src="/pro-root.png"'
29
+ And the file "index.html" should contain 'src="/all-root-logo.png"'
30
+ And the file "index.html" should contain 'src="/images/pro-image.png"'
31
+ And the file "index.html" should contain 'src="/images/all-logo.png"'
32
+
33
+ Scenario: Build with --target free
34
+ Given a built app at "middleman_targets_app" with flags "--target free"
35
+ When I cd to "free_build (free)"
36
+ And the file "index.html" should contain "Insult: YES"
37
+ And the file "index.html" should contain "TargetName: free"
38
+ And the file "index.html" should contain "TargetFree: YES"
39
+ And the file "index.html" should contain "TargetValueForSampleKey: People who use free versions don't drive profits."
40
+ And the file "index.html" should contain "CurrentPageValidFeatures: [:feature_advertise_pro, :insults_user]"
41
+ And the file "index.html" should contain 'src="/free-root.png"'
42
+ And the file "index.html" should contain 'src="/all-root-logo.png"'
43
+ And the file "index.html" should contain 'src="/images/free-image.png"'
44
+ And the file "index.html" should contain 'src="/images/all-logo.png"'
@@ -0,0 +1,42 @@
1
+ Feature: Run the preview server with various target options.
2
+
3
+ As a software developer
4
+ I want to start the preview server with different targets
5
+ In order to view my changes immediately in the browser
6
+
7
+ Background:
8
+ Given a fixture app "middleman_targets_app"
9
+ And the default aruba timeout is 30 seconds
10
+
11
+ Scenario: Start the server with the default target (pro)
12
+ When I run `middleman server` interactively
13
+ And I stop middleman if the output contains:
14
+ """
15
+ Inspect your site configuration
16
+ """
17
+ And the output should contain:
18
+ """
19
+ Middleman will serve using target "pro"
20
+ """
21
+
22
+ Scenario: Start the server with the --pro target
23
+ When I run `middleman server --target pro` interactively
24
+ And I stop middleman if the output contains:
25
+ """
26
+ Inspect your site configuration
27
+ """
28
+ And the output should contain:
29
+ """
30
+ Middleman will serve using target "pro"
31
+ """
32
+
33
+ Scenario: Start the server with the --free target
34
+ When I run `middleman server --target free` interactively
35
+ And I stop middleman if the output contains:
36
+ """
37
+ Inspect your site configuration
38
+ """
39
+ And the output should contain:
40
+ """
41
+ Middleman will serve using target "free"
42
+ """
@@ -0,0 +1,20 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ ENV['TEST'] = 'true'
3
+
4
+ require 'middleman'
5
+ require 'middleman-core/step_definitions'
6
+ require File.join(PROJECT_ROOT_PATH, 'lib', ENV['GEM_NAME'] || 'middleman-targets')
7
+
8
+
9
+ require 'cucumber/formatter/pretty'
10
+ class QuietFormatter < Cucumber::Formatter::Pretty
11
+ def initialize(runtime, io, options)
12
+ $stderr = File.new( '/dev/null', 'w' )
13
+ super(runtime, io, options)
14
+ end
15
+
16
+ def after_features(features)
17
+ $stderr = STDOUT
18
+ super(features)
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ activate :MiddlemanTargets
2
+
3
+ set :target, :pro
4
+
5
+ set :targets, {
6
+ :free =>
7
+ {
8
+ :sample_key => 'People who use free versions don\'t drive profits.',
9
+ :build_dir => 'free_build (%s)',
10
+ :features =>
11
+ {
12
+ :feature_advertise_pro => true,
13
+ :insults_user => true,
14
+ :grants_wishes => false,
15
+ }
16
+ },
17
+
18
+ :pro =>
19
+ {
20
+ :sample_key => 'You are a valued contributor to our balance sheet!',
21
+ :features =>
22
+ {
23
+ :feature_advertise_pro => false,
24
+ :insults_user => false,
25
+ :grants_wishes => true,
26
+ }
27
+ },
28
+ }
29
+
30
+ set :target_magic_images, true
31
+ set :target_magic_word, 'all'
32
+
33
+ set :build_dir, 'custom_build_dir'
@@ -0,0 +1,35 @@
1
+ <% if target_feature?(:insults_user) %>
2
+ Insult: YES
3
+ <% else %>
4
+ Insult: NO
5
+ <% end %>
6
+
7
+ TargetName: <%= target_name %>
8
+
9
+ <% if target_name?(:free) %>
10
+ TargetFree: YES
11
+ <% else %>
12
+ TargetFree: NO
13
+ <% end %>
14
+
15
+ TargetValueForSampleKey: <%= target_value(:sample_key) %>
16
+
17
+ CurrentPageValidFeatures: <%= current_page.valid_features %>
18
+
19
+
20
+ ~~~
21
+ <%= image_tag '/all-root.png' %>
22
+ ~~~
23
+
24
+ ~~~
25
+ <%= image_tag '/all-root-logo.png' %>
26
+ ~~~
27
+
28
+ ~~~
29
+ <%= image_tag 'all-image.png' %>
30
+ ~~~
31
+
32
+ ~~~
33
+ <%= image_tag 'all-logo.png' %>
34
+ ~~~
35
+