middleman-kss 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2c752e9099cb3519f05631eef81ad64823f38ae
4
- data.tar.gz: 812c479ddc11f50ffaddeab0386d6bfe0d7a8936
3
+ metadata.gz: 2b7bce4a832b29d26b1ad37f71974534425c2d54
4
+ data.tar.gz: 2faeb01d47817a1ae87cbd73a5e960c808a79425
5
5
  SHA512:
6
- metadata.gz: 73c70d442d5dbb23c148735c2e7d3c658e84e1dafed906cb2b66f1799849ca5ae17868c63bcd8d5aafcac10c98f981da67405bf0e1b79e5b5e6b537b90ee1763
7
- data.tar.gz: 32d8a79973b9f6e4ea025de449981d9e71b626c9d3cfee92aa227f943cf5a0c69316854ac35d3f7acd362525c292f51765c12a2723dfcc0731e372815de1dfc6
6
+ metadata.gz: a61853655503fba484196d966c36dc084ba809d800db1e6193f5379b89358f2d528a5ec2968bc6fc57fa673037f2320b904ad01084cf9abc59099030dde37a81
7
+ data.tar.gz: 88a88f44e572fe62732bdb03923ca61dc8d5a0011021bdf25a7f00e5f5342b14735ffff5a1934e5786b2871eead2f9cf30862186fa0dc5f95cf64b3a62477377
data/Rakefile CHANGED
@@ -1 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ require 'cucumber/rake/task'
4
+
5
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
6
+ exempt_tags = ""
7
+ exempt_tags << "--tags ~@nojava " if RUBY_PLATFORM == "java"
8
+ t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
9
+ end
10
+
11
+ require 'rake/clean'
12
+
13
+ task :test => ["cucumber"]
@@ -0,0 +1,16 @@
1
+ Feature: Syntax highlighting with the "code" helper method
2
+
3
+ Scenario: Renders the styleguide
4
+ Given the Server is running at "test-app"
5
+ When I go to "/styleguide.html"
6
+ Then I should see '<h1>Styleguide</h1>'
7
+
8
+ Scenario: Renders plain styleblock
9
+ Given the Server is running at "test-app"
10
+ When I go to "/styleguide.html"
11
+ Then I should see '<button class="btn">Button</button>'
12
+
13
+ Scenario: Renders pseudo classes when section is found
14
+ Given the Server is running at "test-app"
15
+ When I go to "/styleguide.html"
16
+ Then I should see '<button class="btn pseudo-class-hover">Button</button>'
@@ -0,0 +1,5 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ ENV['TEST'] = 'true'
3
+ require "middleman-core"
4
+ require "middleman-core/step_definitions"
5
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-kss')
@@ -0,0 +1 @@
1
+ activate :kss, :kss_dir => 'css'
@@ -0,0 +1,15 @@
1
+ /*
2
+ Just some simple buttons for testing.
3
+
4
+ :hover - Subtle hover hilight
5
+
6
+ Styleguide 1.1.
7
+ */
8
+ .btn {
9
+ background: red;
10
+ border: 0;
11
+ }
12
+
13
+ .btn:hover {
14
+ background: teal;
15
+ }
@@ -0,0 +1,3 @@
1
+ <button class="btn$modifier_class">Button</button>
2
+ <a class="btn$modifier_class">Link button</a>
3
+ <input type="submit" class="btn$modifier_class" value="Submit button" />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: Styleguide
3
+ ---
4
+
5
+ # Styleguide
6
+
7
+ ## Plain styleblock
8
+
9
+ <%= styleblock 'buttons' %>
10
+
11
+ ## Pretty styleblock
12
+
13
+ <%= styleblock 'buttons', section: '1.1' %>
@@ -28,6 +28,8 @@ module Middleman
28
28
  end
29
29
 
30
30
  module Helpers
31
+ DEFAULT_STYLEGUIDE_BLOCK_FILE = '_styleguide_block.html.erb'
32
+
31
33
  # Renders a styleblock with or without styleguide information.
32
34
  #
33
35
  # @param [String] tile
@@ -40,29 +42,26 @@ module Middleman
40
42
  # @return [String] Generated HTML.
41
43
  #
42
44
  def styleblock(tile, options = {})
43
- extension_options = ::Middleman::KSS.options
44
-
45
- # Parse the KSS style guide once per request (because it might change a lot, yo)
46
- unless request.has_key?(:styleguide)
47
- request[:styleguide] = ::Kss::Parser.new(File.join(self.source_dir, extension_options[:kss_dir]))
48
- end
49
-
50
- @styleguide = request[:styleguide]
51
-
52
45
  tile_file = "_#{tile}.html.erb"
53
- # TODO: remove "styleblocks" magic string
54
46
  tile_path = File.join(self.source_dir, "styleblocks", tile_file)
55
- @block_html = File.read(tile_path)
47
+ tile_template = ::Tilt.new(tile_path)
48
+
49
+ @block_html = tile_template.render
50
+ @styleguide = self.get_styleguide
56
51
 
57
52
  if options.has_key?(:section)
58
53
  @section = @styleguide.section(options[:section])
59
- # TODO: remove magic strings: "partials" and "_styleguide_block.html.erb"
60
- styleguide_block_path = File.join(File.dirname(__FILE__), '_styleguide_block.html.erb')
61
- #styleguide_block_path = File.join(self.source_dir, "partials", "_styleguide_block.html.erb")
62
- render_individual_file(styleguide_block_path)
54
+ raise "Section must have a description. Section #{options[:section]} does not have one or section does not exist." if @section.description.blank?
55
+ end
56
+
57
+ if @section
58
+ # Render the styleguide block
59
+ styleguide_block_path = File.join(File.dirname(__FILE__), DEFAULT_STYLEGUIDE_BLOCK_FILE)
60
+ template = ::Tilt.new(styleguide_block_path)
61
+ return template.render(self)
63
62
  else
64
- return @block_html.gsub('$modifier_class', '').gsub(' class=""', '')
65
- #render_individual_file(@block_html)
63
+ # Render just the HTML without the $modifier_class thingies
64
+ return @block_html.gsub('$modifier_class', '').gsub(' class=""', '').prepend('<div class="styleguide-styleblock">') << '</div>'
66
65
  end
67
66
  end
68
67
 
@@ -77,6 +76,16 @@ module Middleman
77
76
  markdown.render(input)
78
77
  end
79
78
 
79
+ def get_styleguide
80
+ # Parse the KSS style guide once per request (because it probably changes every request)
81
+ unless request.has_key?(:styleguide)
82
+ extension_options = ::Middleman::KSS.options
83
+ request[:styleguide] = ::Kss::Parser.new(File.join(self.source_dir, extension_options[:kss_dir]))
84
+ end
85
+
86
+ return request[:styleguide]
87
+ end
88
+
80
89
  end
81
90
  end
82
91
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module KSS
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.required_ruby_version = '>= 1.8.7'
22
+ spec.required_ruby_version = '>= 1.9.2'
23
23
  spec.add_development_dependency 'bundler', '~> 1.3'
24
24
  spec.add_development_dependency 'rake'
25
25
 
26
- spec.add_runtime_dependency('middleman-core', '<= 3.0.14')
27
- spec.add_runtime_dependency('kss', '~> 0.4')
26
+ spec.add_runtime_dependency('middleman-core', '~> 3.0')
27
+ spec.add_runtime_dependency('kss', '~> 0.5.0')
28
28
  spec.add_runtime_dependency('redcarpet', '~> 2.2.2')
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-kss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antti-Jussi Kovalainen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: middleman-core
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - <=
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 3.0.14
47
+ version: '3.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - <=
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 3.0.14
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: kss
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.4'
61
+ version: 0.5.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0.4'
68
+ version: 0.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,12 @@ files:
94
94
  - README.md
95
95
  - Rakefile
96
96
  - TODO.md
97
+ - features/helper.feature
98
+ - features/support/env.rb
99
+ - fixtures/test-app/config.rb
100
+ - fixtures/test-app/source/css/test.css
101
+ - fixtures/test-app/source/styleblocks/_buttons.html.erb
102
+ - fixtures/test-app/source/styleguide.html.md.erb
97
103
  - lib/middleman-kss.rb
98
104
  - lib/middleman-kss/_styleguide_block.html.erb
99
105
  - lib/middleman-kss/extension.rb
@@ -112,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
118
  requirements:
113
119
  - - '>='
114
120
  - !ruby/object:Gem::Version
115
- version: 1.8.7
121
+ version: 1.9.2
116
122
  required_rubygems_version: !ruby/object:Gem::Requirement
117
123
  requirements:
118
124
  - - '>='
@@ -124,4 +130,7 @@ rubygems_version: 2.0.5
124
130
  signing_key:
125
131
  specification_version: 4
126
132
  summary: KSS (Knyle Style Sheets) helpers for Middleman
127
- test_files: []
133
+ test_files:
134
+ - features/helper.feature
135
+ - features/support/env.rb
136
+ has_rdoc: