fuji 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuji (0.1.0)
4
+ fuji (0.1.4)
5
5
  compass
6
6
  sass
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- chunky_png (1.2.7)
11
+ chunky_png (1.2.8)
12
12
  compass (0.12.2)
13
13
  chunky_png (~> 1.2)
14
14
  fssm (>= 0.2.7)
data/README.md CHANGED
@@ -29,8 +29,6 @@ The render method accepts a hash of options with the following defaults:
29
29
  logo_text: "heroku",
30
30
  logo_subtext: nil, # e.g 'dashboard' or 'add-ons'
31
31
  logo_url: "https://www.heroku.com",
32
- login_path: nil, # if present, display login/logout links
33
- logout_path: nil,
34
32
  gravatar_fallback_url: "http://assets.heroku.com.s3.amazonaws.com/addons.heroku.com/gravatar_default.png"
35
33
  }
36
34
  ```
@@ -38,7 +36,7 @@ The render method accepts a hash of options with the following defaults:
38
36
  Here's how it's done in addons:
39
37
 
40
38
  ```haml
41
- = Fuji::Header.render(user: current_user, logo_subtext: "addons", login_path: login_path, logout_path: logout_path)
39
+ = Fuji::Header.render(user: current_user, logo_subtext: "addons")
42
40
  ```
43
41
 
44
42
  Style it up by importing the fuji partial into your sass/scss stylesheet:
data/lib/fuji.rb CHANGED
@@ -3,17 +3,6 @@ require 'digest/md5'
3
3
  require 'uri'
4
4
  require "compass"
5
5
 
6
- # module Foo
7
- #
8
- # module Header
9
- # def render
10
- # puts "rendered!"
11
- # end
12
- # end
13
- # extend Header
14
- #
15
- # end
16
-
17
6
  module Fuji
18
7
 
19
8
  def self.render
@@ -27,6 +16,7 @@ module Fuji
27
16
  end
28
17
 
29
18
  class Header
19
+
30
20
  def self.render(options={})
31
21
 
32
22
  # Options
@@ -35,43 +25,35 @@ module Fuji
35
25
  options[:logo_subtext] ||= nil
36
26
  options[:logo_url] ||= "https://www.heroku.com"
37
27
  options[:user] ||= nil
38
- options[:login_path] ||= nil
39
- options[:logout_path] ||= nil
40
28
  options[:links] ||= nil
41
29
 
42
- links = []
43
-
44
- # unless options[:user]
45
- # links << {id: :how, name: 'How it Works', url: 'https://heroku.com/how'}
46
- # links << {id: :pricing, name: 'Pricing', url: 'https://www.heroku.com/pricing'}
47
- # end
48
-
49
- links << {id: :apps, name: 'Apps', url: 'https://dashboard.heroku.com'}
50
- links << {id: :addons, name: 'Add-ons', url: 'https://addons.heroku.com'}
51
- links << {id: :documentation, name: 'Documentation', url: 'https://devcenter.heroku.com'}
52
- links << {id: :support, name: 'Support', url: 'https://help.heroku.com'}
53
-
54
- if options[:user] && options[:logout_path]
55
- links << {id: :logout, name: 'Log out', url: options[:logout_path]}
56
- end
57
-
58
- # Gravatar
59
- if options[:user] && options[:user].email
60
- gravatar_url = [
61
- "https://secure.gravatar.com/avatar/",
62
- Digest::MD5.hexdigest(options[:user].email),
63
- "?default=",
64
- URI.escape(options[:gravatar_fallback_url])
65
- ].join("")
66
- links << {
67
- id: :gravatar,
68
- name: Fuji::Helper.image_tag(gravatar_url),
69
- url: 'https://dashboard.heroku.com/account'
70
- }
71
- end
72
-
73
- if options[:login_path] && options[:user].nil?
74
- links << {id: :login, name: 'Log in', url: options[:login_path]}
30
+ # Allow links to be overridden entirely
31
+ links = options[:links]
32
+
33
+ if links.nil?
34
+ links = [
35
+ {id: :apps, name: 'Apps', url: 'https://dashboard.heroku.com'},
36
+ {id: :addons, name: 'Add-ons', url: 'https://addons.heroku.com'},
37
+ {id: :documentation, name: 'Documentation', url: 'https://devcenter.heroku.com'},
38
+ {id: :support, name: 'Support', url: 'https://help.heroku.com'},
39
+ {id: :blog, name: 'Blog', url: 'https://blog.heroku.com'},
40
+ {id: :account, name: 'Account', url: "https://dashboard.heroku.com/account"}
41
+ ]
42
+
43
+ # Gravatar
44
+ if options[:user] && options[:user].email
45
+ gravatar_url = [
46
+ "https://secure.gravatar.com/avatar/",
47
+ Digest::MD5.hexdigest(options[:user].email),
48
+ "?default=",
49
+ URI.escape(options[:gravatar_fallback_url])
50
+ ].join("")
51
+ links << {
52
+ id: :gravatar,
53
+ name: Fuji::Helper.image_tag(gravatar_url),
54
+ url: 'https://dashboard.heroku.com/account'
55
+ }
56
+ end
75
57
  end
76
58
 
77
59
  # Join links together
@@ -132,6 +114,4 @@ module Fuji
132
114
 
133
115
  end
134
116
 
135
- end
136
-
137
- # ActionView::Base.send :include, Fuji::ViewHelpers if defined?(ActionView)
117
+ end
data/lib/fuji/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fuji
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
data/spec/fuji_spec.rb CHANGED
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
  require 'digest/md5'
3
3
 
4
4
  describe Fuji::Header do
5
-
6
- describe "fuji" do
5
+
6
+ describe "#render" do
7
7
  before do
8
8
  @user = OpenStruct.new(email: "bob@heroku.com")
9
9
  end
10
-
10
+
11
11
  it "outputs an HTML string" do
12
12
  Fuji::Header.render.should match /div id='fuji'/
13
13
  end
@@ -15,77 +15,76 @@ describe Fuji::Header do
15
15
  it "renders the user's avatar" do
16
16
  h = Fuji::Header.render(user: @user)
17
17
  hash = Digest::MD5.hexdigest(@user.email)
18
-
19
18
  h.should match /#{hash}/
20
19
  end
21
-
20
+
22
21
  end
23
-
22
+
24
23
  describe "Fuji::Helper.current_site_matches?" do
25
-
24
+
26
25
  describe "inside a rails app" do
27
26
  before do
28
27
  @request = OpenStruct.new(protocol: "https://", host_with_port: "dhh.com", fullpath: "/foo")
29
28
  end
30
-
29
+
31
30
  it "detects search string" do
32
31
  Fuji::Helper.current_site_matches?('dhh.com/foo', @request).should == true
33
32
  end
34
-
33
+
35
34
  it "doesn't detect search string" do
36
35
  Fuji::Helper.current_site_matches?('some other shit', @request).should == false
37
36
  end
38
-
37
+
39
38
  end
40
-
39
+
41
40
  describe "inside a sinatra app" do
42
41
 
43
42
  before do
44
43
  @request = OpenStruct.new(url: "https://mizerany.com")
45
44
  end
46
-
45
+
47
46
  it "detects search string" do
48
47
  Fuji::Helper.current_site_matches?('mizerany', @request).should == true
49
48
  end
50
-
49
+
51
50
  it "doesn't detect search string" do
52
51
  Fuji::Helper.current_site_matches?('some other blake', @request).should == false
53
52
  end
54
-
53
+
55
54
  end
56
-
55
+
57
56
  describe "in any kind of ruby app" do
58
-
57
+
59
58
  before do
60
59
  @request = OpenStruct.new(url: "https://the-rest.com")
61
60
  end
62
-
61
+
63
62
  it "allows a symbol as a search string" do
64
63
  Fuji::Helper.current_site_matches?(:rest, @request).should == true
65
64
  end
66
-
65
+
67
66
  it "matches against domain name when given a full URL" do
68
67
  Fuji::Helper.current_site_matches?("http://the-rest.com/extra/mojo", @request).should == true
69
68
  end
70
-
69
+
71
70
  it "returns false if request object is nil" do
72
71
  Fuji::Helper.current_site_matches?('foo').should == false
73
72
  end
74
-
73
+
75
74
  end
76
-
75
+
77
76
  end
78
-
77
+
79
78
  describe "extract_domain" do
80
-
79
+
81
80
  it "pulls the domain out of a URL string" do
82
81
  Fuji::Helper.extract_domain("https://dweeb-fest.example.com/sho/biz").should == "dweeb-fest.example.com"
83
82
  end
84
-
83
+
85
84
  it "returns the original string if it doesn't contain a domain" do
86
85
  Fuji::Helper.extract_domain("turkey jerky").should == "turkey jerky"
87
86
  end
88
-
87
+
89
88
  end
90
-
89
+
91
90
  end
@@ -82,7 +82,7 @@ $fuji-line-size: 40%
82
82
  display: block
83
83
  padding: 3px 8px
84
84
  text-decoration: none
85
- &:hover, &.active, &.login
85
+ &:hover, &.active, &.login, &.account
86
86
  +transition(all 0)
87
87
  color: $fuji-link-color-active
88
88
  background-color: $fuji-link-background-color-active
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -108,12 +108,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ segments:
112
+ - 0
113
+ hash: -1746864864222920062
111
114
  required_rubygems_version: !ruby/object:Gem::Requirement
112
115
  none: false
113
116
  requirements:
114
117
  - - ! '>='
115
118
  - !ruby/object:Gem::Version
116
119
  version: '0'
120
+ segments:
121
+ - 0
122
+ hash: -1746864864222920062
117
123
  requirements: []
118
124
  rubyforge_project:
119
125
  rubygems_version: 1.8.25