fume-nav 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61c581dd814201aeed99d89866bf09d24f17c0bf
4
- data.tar.gz: 6187cf03f279ee08b8a219b8aac36d51dfd9e047
3
+ metadata.gz: 905bb9b15d89dff0a4094c794b3feb81e4f77f07
4
+ data.tar.gz: 94672d65dd227cf69054690ec5d257493ea59d0b
5
5
  SHA512:
6
- metadata.gz: 00cd59d51870ab924d2c08f0d8f0c15101faca50ff16535e0b3e0ac224311367cf3d66a826d80f57deefec355567c9bc28c361e8095bfad6b686756d0f530399
7
- data.tar.gz: ebbf014bb5cd1e34b84ae2f865b3379a6b6b1488f6662fd27af695c645d312a3c6f17ffc06403b856fc395f185ad18265b6e585c074b7ead07b38e81038932df
6
+ metadata.gz: 5aee52aec3cf7db83e916aed9791e939bf1d96b7d7baedf6efcc49926d6401e27af4ccdad74ca4cd646f62d2408f2dbd42810e9fb6a711292d6ffd03fda3785d
7
+ data.tar.gz: 9d29a5f19606d2d8fc18121a7348d5cc9b1ca215919de1ef4ce4177be543b1caae11cc3feeac99c6656d5a59a0ca85e80887204374b4ec4cb5f26410d3cde66d
data/.gitignore CHANGED
@@ -1,6 +1,14 @@
1
- .DS_Store
2
- coverage
3
- pkg/*
4
- tmp/*
5
- gem_graph.png
6
- Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ script: "bundle exec rake spec"
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+
6
+ gemfile:
7
+ - Gemfile
8
+ - gemfiles/rails3_2.gemfile
9
+
10
+ before_install:
11
+ - gem install bundler
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in fume.gemspec
3
+ gem "rails", "~> 4.0"
4
+
5
+ # Specify your gem's dependencies in fume-nav.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -1,12 +1,17 @@
1
1
  # Fume::Nav
2
2
 
3
+ [![Build Status](https://travis-ci.org/sunteya/fume-nav.svg?branch=master)](https://travis-ci.org/sunteya/fume-nav)
4
+
3
5
  help build navigation for rails.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
9
- gem 'fume-nav'
11
+ ```ruby
12
+ gem 'fume-nav'
13
+ ```
14
+
10
15
 
11
16
  ## Usage
12
17
 
@@ -62,8 +67,8 @@ OPTIONS:
62
67
 
63
68
  ## Contributing
64
69
 
65
- 1. Fork it
70
+ 1. Fork it ( https://github.com/sunteya/fume-nav/fork )
66
71
  2. Create your feature branch (`git checkout -b my-new-feature`)
67
72
  3. Commit your changes (`git commit -am 'Add some feature'`)
68
73
  4. Push to the branch (`git push origin my-new-feature`)
69
- 5. Create new Pull Request
74
+ 5. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'bundler/gem_tasks'
2
-
3
- require 'rake/version_task'
4
- Rake::VersionTask.new
5
-
6
-
1
+ require "bundler/gem_tasks"
7
2
 
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new do |t|
5
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
data/fume-nav.gemspec CHANGED
@@ -1,25 +1,28 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fume/nav/version'
4
5
 
5
6
  Gem::Specification.new do |spec|
6
7
  spec.name = "fume-nav"
7
- spec.version = File.read(File.expand_path("../VERSION", __FILE__)).chomp
8
+ spec.version = Fume::Nav::VERSION
8
9
  spec.authors = ["sunteya"]
9
10
  spec.email = ["sunteya@gmail.com"]
10
- spec.description = %q{help build navigation for rails.}
11
11
  spec.summary = %q{help build navigation for rails.}
12
+ spec.description = %q{help build navigation for rails.}
12
13
  spec.homepage = "https://github.com/sunteya/fume-nav"
13
14
  spec.license = "MIT"
14
15
 
15
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files -z`.split("\x0")
16
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
19
  spec.require_paths = ["lib"]
19
20
 
20
- spec.add_dependency "railties"
21
-
22
- spec.add_development_dependency "bundler", "~> 1.3"
23
- spec.add_development_dependency "rake"
24
- spec.add_development_dependency "version"
21
+ spec.add_dependency "rails"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.1.0"
27
+ spec.add_development_dependency "pry-byebug"
25
28
  end
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 3.2.0"
4
+
5
+ # Specify your gem's dependencies in rspec-do_action.gemspec
6
+ gemspec path: '..'
data/lib/fume/nav.rb CHANGED
@@ -1,2 +1,5 @@
1
- require File.expand_path("../nav/helper_ext", __FILE__)
2
- require File.expand_path("../nav/railtie", __FILE__)
1
+ require "fume/nav/version"
2
+
3
+ require "fume/nav/nav_tag"
4
+ require "fume/nav/helper_ext"
5
+ require "fume/nav/railtie"
@@ -1,6 +1,8 @@
1
+ require "fume/nav/nav_tag"
2
+
1
3
  module Fume
2
4
  module Nav
3
- module HelperExtensions
5
+ module HelperExt
4
6
  def fume_nav(*args, &block)
5
7
  attributes = {
6
8
  active_class: "active",
@@ -14,38 +16,7 @@ module Fume
14
16
 
15
17
  return content if !tag.hide?
16
18
  end
17
-
18
- class NavTag
19
- attr_accessor :helper, :current, :active_class, :hide_if_empty
20
-
21
- def initialize(attributes = {})
22
- attributes.each_pair do |name, value|
23
- send("#{name}=", value)
24
- end
25
- @empty = true
26
- end
27
-
28
- def hide?
29
- hide_if_empty && @empty
30
- end
31
-
32
- def li_tag(value, options = {}, &block)
33
- self.content_tag(value, :li, options, &block)
34
- end
35
19
 
36
- def content_tag(value, tag_name, options = {}, &block)
37
- if value == current
38
- if options[:class]
39
- options[:class] += " #{active_class}"
40
- else
41
- options[:class] = "#{active_class}"
42
- end
43
- end
44
-
45
- @empty = false
46
- helper.content_tag(tag_name, options, &block)
47
- end
48
- end
49
20
  end
50
21
  end
51
- end
22
+ end
@@ -0,0 +1,46 @@
1
+ module Fume
2
+ module Nav
3
+ class NavTag
4
+ attr_accessor :helper, :current, :active_class, :hide_if_empty
5
+
6
+ def initialize(attributes = {})
7
+ attributes.each_pair do |name, value|
8
+ send("#{name}=", value)
9
+ end
10
+ @empty = true
11
+ end
12
+
13
+ def hide?
14
+ hide_if_empty && @empty
15
+ end
16
+
17
+ def li_tag(value, options = {}, &block)
18
+ content_tag(value, :li, options, &block)
19
+ end
20
+
21
+ def content_tag(value, tag_name, options = {}, &block)
22
+ apply_active_options(value, options)
23
+ helper.content_tag(tag_name, options, &block)
24
+ end
25
+
26
+ def apply_active_options(value, options)
27
+ match = case value
28
+ when Regexp
29
+ value.match(current)
30
+ else
31
+ value.to_s == current.to_s
32
+ end
33
+
34
+ if match
35
+ if options[:class]
36
+ options[:class] += " #{active_class}"
37
+ else
38
+ options[:class] = "#{active_class}"
39
+ end
40
+ end
41
+
42
+ @empty = false
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,10 +1,11 @@
1
1
  require "rails/railtie"
2
+ require "fume/nav/helper_ext"
2
3
 
3
4
  module Fume
4
5
  module Nav
5
6
  class Railtie < ::Rails::Railtie
6
- initializer 'fume.initialize', :after => :after_initialize do |app|
7
- ::ActionView::Base.send :include, HelperExtensions
7
+ initializer 'fume.initialize', after: :after_initialize do |app|
8
+ ::ActionView::Base.send :include, HelperExt
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,5 @@
1
+ module Fume
2
+ module Nav
3
+ VERSION = "0.0.3"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+ require "action_view"
3
+
4
+ RSpec.describe Fume::Nav::HelperExt do
5
+ class TestView < ::ActionView::Base
6
+ include Fume::Nav::HelperExt
7
+ end
8
+
9
+ let(:controller) { ActionView::TestCase::TestController.new }
10
+ let(:view) { TestView.new }
11
+ before { view.output_buffer = ActionView::OutputBuffer.new }
12
+
13
+ describe "#fume_nav" do
14
+ let(:current) { :foo }
15
+ subject { view.fume_nav(current) { |n| n.li_tag(:foo) { "foo" } } }
16
+ it { is_expected.to include('<li class="active">foo</li>') }
17
+
18
+ context "then hide_if_empty is true" do
19
+ subject { view.fume_nav(current, hide_if_empty: true) { |n| "hide" } }
20
+ it { is_expected.to eq nil }
21
+ end
22
+
23
+ context "then hide_if_empty is true" do
24
+ subject { view.fume_nav(current, hide_if_empty: false) { |n| "show" } }
25
+ it { is_expected.to eq "show" }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fume::Nav::NavTag do
4
+ let(:context) { double :context }
5
+ let(:current) { nil }
6
+ let(:attributes) { { helper: context, current: current, active_class: "active", hide_if_empty: true } }
7
+ subject { described_class.new(attributes) }
8
+
9
+ describe "#li_tag" do
10
+ let(:current) { :foo }
11
+
12
+ context "then match" do
13
+ before { expect(context).to receive(:content_tag).with(:li, hash_including(class: "active")) }
14
+ it { subject.li_tag(:foo) }
15
+
16
+ context "value is Regexp" do
17
+ let(:current) { :foo }
18
+ it { subject.li_tag(/^foo/) }
19
+ end
20
+ end
21
+
22
+ context "then not match" do
23
+ before { expect(context).to receive(:content_tag).with(:li, hash_excluding(class: "active")) }
24
+ it { subject.li_tag(:not_match) }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,88 @@
1
+ require "pry-byebug"
2
+ require "fume/nav"
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
7
+ # file to always be loaded, without a need to explicitly require it in any files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need it.
15
+ #
16
+ # The `.rspec` file also contains a few flags that are not defaults but that
17
+ # users commonly want.
18
+ #
19
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+ # These two settings work together to allow you to limit a spec run
45
+ # to individual examples or groups you care about by tagging them with
46
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
47
+ # get run.
48
+ config.filter_run :focus
49
+ config.run_all_when_everything_filtered = true
50
+
51
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
52
+ # For more details, see:
53
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
54
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
55
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
56
+ config.disable_monkey_patching!
57
+
58
+ # This setting enables warnings. It's recommended, but in some cases may
59
+ # be too noisy due to issues in dependencies.
60
+ # config.warnings = true
61
+
62
+ # Many RSpec users commonly either run the entire suite or an individual
63
+ # file, and it's useful to allow more verbose output when running an
64
+ # individual spec file.
65
+ if config.files_to_run.one?
66
+ # Use the documentation formatter for detailed output,
67
+ # unless a formatter has already been configured
68
+ # (e.g. via a command-line flag).
69
+ config.default_formatter = 'doc'
70
+ end
71
+
72
+ # Print the 10 slowest examples and example groups at the
73
+ # end of the spec run, to help surface which specs are running
74
+ # particularly slow.
75
+ config.profile_examples = 10
76
+
77
+ # Run specs in random order to surface order dependencies. If you find an
78
+ # order dependency and want to debug it, you can fix the order by providing
79
+ # the seed, which is printed after each run.
80
+ # --seed 1234
81
+ config.order = :random
82
+
83
+ # Seed global randomization in this process using the `--seed` CLI option.
84
+ # Setting this allows you to use `--seed` to deterministically reproduce
85
+ # test failures related to randomization by passing the same `--seed` value
86
+ # as the one that triggered the failure.
87
+ Kernel.srand config.seed
88
+ end
metadata CHANGED
@@ -1,69 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fume-nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sunteya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-20 00:00:00.000000000 Z
11
+ date: 2014-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: railties
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '1.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '10.0'
48
48
  type: :development
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: '0'
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
55
69
  - !ruby/object:Gem::Dependency
56
- name: version
70
+ name: pry-byebug
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  description: help build navigation for rails.
@@ -73,17 +87,23 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - .gitignore
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
77
93
  - Gemfile
78
94
  - LICENSE.txt
79
95
  - README.md
80
96
  - Rakefile
81
- - VERSION
82
97
  - fume-nav.gemspec
83
- - lib/fume-nav.rb
98
+ - gemfiles/rails3_2.gemfile
84
99
  - lib/fume/nav.rb
85
100
  - lib/fume/nav/helper_ext.rb
101
+ - lib/fume/nav/nav_tag.rb
86
102
  - lib/fume/nav/railtie.rb
103
+ - lib/fume/nav/version.rb
104
+ - spec/fume/nav/helper_ext_spec.rb
105
+ - spec/fume/nav/nav_tag_spec.rb
106
+ - spec/spec_helper.rb
87
107
  homepage: https://github.com/sunteya/fume-nav
88
108
  licenses:
89
109
  - MIT
@@ -94,18 +114,21 @@ require_paths:
94
114
  - lib
95
115
  required_ruby_version: !ruby/object:Gem::Requirement
96
116
  requirements:
97
- - - '>='
117
+ - - ">="
98
118
  - !ruby/object:Gem::Version
99
119
  version: '0'
100
120
  required_rubygems_version: !ruby/object:Gem::Requirement
101
121
  requirements:
102
- - - '>='
122
+ - - ">="
103
123
  - !ruby/object:Gem::Version
104
124
  version: '0'
105
125
  requirements: []
106
126
  rubyforge_project:
107
- rubygems_version: 2.0.3
127
+ rubygems_version: 2.2.2
108
128
  signing_key:
109
129
  specification_version: 4
110
130
  summary: help build navigation for rails.
111
- test_files: []
131
+ test_files:
132
+ - spec/fume/nav/helper_ext_spec.rb
133
+ - spec/fume/nav/nav_tag_spec.rb
134
+ - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.2
data/lib/fume-nav.rb DELETED
@@ -1 +0,0 @@
1
- require File.expand_path("../fume/nav", __FILE__)