confluence 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +6 -0
- data/Gemfile.lock +86 -0
- data/VERSION +1 -1
- data/confluence.gemspec +64 -6
- data/lib/confluence.rb +6 -3
- data/lib/confluence/railtie.rb +14 -0
- data/lib/confluence/railties/resolver.rb +78 -0
- data/lib/confluence/templates/%project_name%.cabal.tt +4 -4
- data/lib/confluence/templates/Rakefile.tt +4 -4
- data/spec/confluence/railtie_spec.rb +7 -0
- data/spec/confluence/railties/resolver_spec.rb +160 -0
- data/spec/confluence/welcome_controller_spec.rb +37 -0
- data/spec/confluence_spec.rb +15 -2
- data/spec/fixture/.gitignore +15 -0
- data/spec/fixture/README.rdoc +261 -0
- data/spec/fixture/Rakefile +7 -0
- data/spec/fixture/app/assets/images/rails.png +0 -0
- data/spec/fixture/app/assets/javascripts/application.js +13 -0
- data/spec/fixture/app/assets/stylesheets/application.css +13 -0
- data/spec/fixture/app/controllers/application_controller.rb +3 -0
- data/spec/fixture/app/controllers/welcome_controller.rb +3 -0
- data/spec/fixture/app/views/layouts/application.html.erb +14 -0
- data/spec/fixture/app/views/welcome/index.html.haml +1 -0
- data/spec/fixture/config.ru +4 -0
- data/spec/fixture/config/application.rb +66 -0
- data/spec/fixture/config/boot.rb +6 -0
- data/spec/fixture/config/environment.rb +5 -0
- data/spec/fixture/config/environments/development.rb +26 -0
- data/spec/fixture/config/environments/production.rb +51 -0
- data/spec/fixture/config/environments/test.rb +35 -0
- data/spec/fixture/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixture/config/initializers/inflections.rb +15 -0
- data/spec/fixture/config/initializers/mime_types.rb +5 -0
- data/spec/fixture/config/initializers/secret_token.rb +7 -0
- data/spec/fixture/config/initializers/session_store.rb +8 -0
- data/spec/fixture/config/initializers/wrap_parameters.rb +10 -0
- data/spec/fixture/config/locales/en.yml +5 -0
- data/spec/fixture/config/routes.rb +58 -0
- data/spec/fixture/lib/assets/.gitkeep +0 -0
- data/spec/fixture/lib/tasks/.gitkeep +0 -0
- data/spec/fixture/log/.gitkeep +0 -0
- data/spec/fixture/public/404.html +26 -0
- data/spec/fixture/public/422.html +26 -0
- data/spec/fixture/public/500.html +25 -0
- data/spec/fixture/public/favicon.ico +0 -0
- data/spec/fixture/public/index.html +241 -0
- data/spec/fixture/public/robots.txt +5 -0
- data/spec/fixture/script/rails +6 -0
- data/spec/fixture/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/fixture/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/fixture/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +7 -0
- metadata +142 -6
- data/lib/confluence/navigator.rb +0 -67
- data/spec/confluence/navigator_spec.rb +0 -68
- data/spec/support/file_sytem/navigator.rb +0 -9
data/lib/confluence/navigator.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
module Confluence
|
2
|
-
class Navigator
|
3
|
-
class Node
|
4
|
-
def self.from_filepath(filepath)
|
5
|
-
new filepath
|
6
|
-
end
|
7
|
-
attr_accessor :filepath
|
8
|
-
|
9
|
-
def initialize(filepath)
|
10
|
-
@filepath = filepath
|
11
|
-
end
|
12
|
-
|
13
|
-
def directory?
|
14
|
-
File.directory?(filepath)
|
15
|
-
end
|
16
|
-
|
17
|
-
def expand_path
|
18
|
-
entries = Dir.entries(filepath).select { |s| !(s == ".." || s == ".") }
|
19
|
-
nodes = entries.map { |entry| Node.from_filepath File.join(filepath, entry ) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
attr_accessor :start_path
|
24
|
-
attr_reader :callbacks
|
25
|
-
|
26
|
-
def initialize(start_path)
|
27
|
-
@start_path = start_path
|
28
|
-
@callbacks ||= {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def on_encounter(type=:file, &block)
|
32
|
-
throw :NoBlockGivenError unless block_given?
|
33
|
-
throw :BadTypeError unless type == :directory || type == :file
|
34
|
-
(@callbacks[type] ||= []) << lambda(&block)
|
35
|
-
self
|
36
|
-
end
|
37
|
-
|
38
|
-
def run
|
39
|
-
_bfs_start(start_path)
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# lol this is actually dfs. sorry
|
45
|
-
def _bfs_start(start_path)
|
46
|
-
# step 0: get a context
|
47
|
-
node_context = Node.from_filepath start_path
|
48
|
-
|
49
|
-
# step 1: expand node
|
50
|
-
nodes = node_context.expand_path
|
51
|
-
|
52
|
-
# step 2: filter nodes
|
53
|
-
node_hash = {}
|
54
|
-
node_hash[:directory] = nodes.select { |node| node.directory? } || []
|
55
|
-
node_hash[:file] = nodes.select { |node| !node.directory? } || []
|
56
|
-
|
57
|
-
# step 3: use the callback on all file nodes
|
58
|
-
callbacks.each do |key, cbs|
|
59
|
-
node_hash[key].each { |node| cbs.each {|cb| cb.call node.filepath } }
|
60
|
-
end
|
61
|
-
|
62
|
-
# step 4: recurse with the rest of the d_nodes
|
63
|
-
node_hash[:directory].each { |node| _bfs_start node.filepath }
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Confluence::Navigator do
|
4
|
-
|
5
|
-
describe Confluence::Navigator::Node do
|
6
|
-
|
7
|
-
context "class method" do
|
8
|
-
|
9
|
-
describe "#from_filepath" do
|
10
|
-
let(:node) { Confluence::Navigator::Node.from_filepath RSpec.root }
|
11
|
-
|
12
|
-
it "should give me a node" do
|
13
|
-
node.should be_a Confluence::Navigator::Node
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#directory?" do
|
17
|
-
specify { node.should be_directory }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#expand_path" do
|
21
|
-
it "should contain all the junk in the spec file path" do
|
22
|
-
node.expand_path.map(&:filepath).sort.should eq ["confluence", "confluence_spec.rb", "spec_helper.rb", "support"].map { |entry| File.join(RSpec.root, entry)}
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "api" do
|
32
|
-
let(:nav) { Confluence::Navigator.new RSpec.root }
|
33
|
-
|
34
|
-
describe "#on_encounter" do
|
35
|
-
it "should complain if no block is give" do
|
36
|
-
expect { nav.on_encounter }.to throw_symbol :NoBlockGivenError
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should complain if a bad type is given" do
|
40
|
-
expect { nav.on_encounter(:dog) { } }.to throw_symbol :BadTypeError
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "usage" do
|
47
|
-
let(:nav) { Confluence::Navigator.new RSpec.root }
|
48
|
-
before :each do
|
49
|
-
push_bfs = lambda { |a| (@bfs_results ||= []) << a }
|
50
|
-
nav.on_encounter do |filepath|
|
51
|
-
push_bfs.call filepath
|
52
|
-
end
|
53
|
-
nav.run
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "#run" do
|
57
|
-
it "a successful should spit out all the files in this very spec folder" do
|
58
|
-
@bfs_results.should_not be_empty
|
59
|
-
end
|
60
|
-
["spec_helper.rb", "confluence_spec.rb"].each do |file|
|
61
|
-
it "should at least contain the basic #{file} file" do
|
62
|
-
@bfs_results.should include File.join(RSpec.root, file)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|