confluence 0.2.0 → 1.0.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.
Files changed (56) hide show
  1. data/Gemfile +6 -0
  2. data/Gemfile.lock +86 -0
  3. data/VERSION +1 -1
  4. data/confluence.gemspec +64 -6
  5. data/lib/confluence.rb +6 -3
  6. data/lib/confluence/railtie.rb +14 -0
  7. data/lib/confluence/railties/resolver.rb +78 -0
  8. data/lib/confluence/templates/%project_name%.cabal.tt +4 -4
  9. data/lib/confluence/templates/Rakefile.tt +4 -4
  10. data/spec/confluence/railtie_spec.rb +7 -0
  11. data/spec/confluence/railties/resolver_spec.rb +160 -0
  12. data/spec/confluence/welcome_controller_spec.rb +37 -0
  13. data/spec/confluence_spec.rb +15 -2
  14. data/spec/fixture/.gitignore +15 -0
  15. data/spec/fixture/README.rdoc +261 -0
  16. data/spec/fixture/Rakefile +7 -0
  17. data/spec/fixture/app/assets/images/rails.png +0 -0
  18. data/spec/fixture/app/assets/javascripts/application.js +13 -0
  19. data/spec/fixture/app/assets/stylesheets/application.css +13 -0
  20. data/spec/fixture/app/controllers/application_controller.rb +3 -0
  21. data/spec/fixture/app/controllers/welcome_controller.rb +3 -0
  22. data/spec/fixture/app/views/layouts/application.html.erb +14 -0
  23. data/spec/fixture/app/views/welcome/index.html.haml +1 -0
  24. data/spec/fixture/config.ru +4 -0
  25. data/spec/fixture/config/application.rb +66 -0
  26. data/spec/fixture/config/boot.rb +6 -0
  27. data/spec/fixture/config/environment.rb +5 -0
  28. data/spec/fixture/config/environments/development.rb +26 -0
  29. data/spec/fixture/config/environments/production.rb +51 -0
  30. data/spec/fixture/config/environments/test.rb +35 -0
  31. data/spec/fixture/config/initializers/backtrace_silencers.rb +7 -0
  32. data/spec/fixture/config/initializers/inflections.rb +15 -0
  33. data/spec/fixture/config/initializers/mime_types.rb +5 -0
  34. data/spec/fixture/config/initializers/secret_token.rb +7 -0
  35. data/spec/fixture/config/initializers/session_store.rb +8 -0
  36. data/spec/fixture/config/initializers/wrap_parameters.rb +10 -0
  37. data/spec/fixture/config/locales/en.yml +5 -0
  38. data/spec/fixture/config/routes.rb +58 -0
  39. data/spec/fixture/lib/assets/.gitkeep +0 -0
  40. data/spec/fixture/lib/tasks/.gitkeep +0 -0
  41. data/spec/fixture/log/.gitkeep +0 -0
  42. data/spec/fixture/public/404.html +26 -0
  43. data/spec/fixture/public/422.html +26 -0
  44. data/spec/fixture/public/500.html +25 -0
  45. data/spec/fixture/public/favicon.ico +0 -0
  46. data/spec/fixture/public/index.html +241 -0
  47. data/spec/fixture/public/robots.txt +5 -0
  48. data/spec/fixture/script/rails +6 -0
  49. data/spec/fixture/vendor/assets/javascripts/.gitkeep +0 -0
  50. data/spec/fixture/vendor/assets/stylesheets/.gitkeep +0 -0
  51. data/spec/fixture/vendor/plugins/.gitkeep +0 -0
  52. data/spec/spec_helper.rb +7 -0
  53. metadata +142 -6
  54. data/lib/confluence/navigator.rb +0 -67
  55. data/spec/confluence/navigator_spec.rb +0 -68
  56. data/spec/support/file_sytem/navigator.rb +0 -9
data/Gemfile CHANGED
@@ -10,10 +10,16 @@ gem "simplecov"
10
10
  gem "rspec"
11
11
  gem "thor"
12
12
  gem "activesupport"
13
+ gem "git"
13
14
  # Add dependencies to develop your gem here.
14
15
  # Include everything needed to run rake, tests, features, etc.
15
16
  group :development do
16
17
  gem "jeweler", "~> 1.8.4"
18
+ gem "rails"
19
+ gem "haml"
20
+ gem "rspec"
21
+ gem "rspec-rails"
22
+ gem "header_navigation", "~>0.0.1" # used only in the spec files
17
23
  end
18
24
 
19
25
  group :debug do
data/Gemfile.lock CHANGED
@@ -2,23 +2,87 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  remote: http://gems.github.com/
4
4
  specs:
5
+ actionmailer (3.2.11)
6
+ actionpack (= 3.2.11)
7
+ mail (~> 2.4.4)
8
+ actionpack (3.2.11)
9
+ activemodel (= 3.2.11)
10
+ activesupport (= 3.2.11)
11
+ builder (~> 3.0.0)
12
+ erubis (~> 2.7.0)
13
+ journey (~> 1.0.4)
14
+ rack (~> 1.4.0)
15
+ rack-cache (~> 1.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.2.1)
18
+ activemodel (3.2.11)
19
+ activesupport (= 3.2.11)
20
+ builder (~> 3.0.0)
21
+ activerecord (3.2.11)
22
+ activemodel (= 3.2.11)
23
+ activesupport (= 3.2.11)
24
+ arel (~> 3.0.2)
25
+ tzinfo (~> 0.3.29)
26
+ activeresource (3.2.11)
27
+ activemodel (= 3.2.11)
28
+ activesupport (= 3.2.11)
5
29
  activesupport (3.2.11)
6
30
  i18n (~> 0.6)
7
31
  multi_json (~> 1.0)
8
32
  archive-tar-minitar (0.5.2)
33
+ arel (3.0.2)
34
+ builder (3.0.4)
9
35
  columnize (0.3.6)
10
36
  diff-lcs (1.1.3)
37
+ erubis (2.7.0)
38
+ faker (1.1.2)
39
+ i18n (~> 0.5)
11
40
  git (1.2.5)
41
+ haml (3.1.7)
42
+ header_navigation (0.0.1)
43
+ faker
44
+ presentable
45
+ hike (1.2.1)
12
46
  i18n (0.6.1)
13
47
  jeweler (1.8.4)
14
48
  bundler (~> 1.0)
15
49
  git (>= 1.2.5)
16
50
  rake
17
51
  rdoc
52
+ journey (1.0.4)
18
53
  json (1.7.6)
19
54
  linecache19 (0.5.12)
20
55
  ruby_core_source (>= 0.1.4)
56
+ mail (2.4.4)
57
+ i18n (>= 0.4.0)
58
+ mime-types (~> 1.16)
59
+ treetop (~> 1.4.8)
60
+ mime-types (1.21)
21
61
  multi_json (1.5.0)
62
+ polyglot (0.3.3)
63
+ presentable (0.0.0)
64
+ rack (1.4.5)
65
+ rack-cache (1.2)
66
+ rack (>= 0.4)
67
+ rack-ssl (1.3.3)
68
+ rack
69
+ rack-test (0.6.2)
70
+ rack (>= 1.0)
71
+ rails (3.2.11)
72
+ actionmailer (= 3.2.11)
73
+ actionpack (= 3.2.11)
74
+ activerecord (= 3.2.11)
75
+ activeresource (= 3.2.11)
76
+ activesupport (= 3.2.11)
77
+ bundler (~> 1.0)
78
+ railties (= 3.2.11)
79
+ railties (3.2.11)
80
+ actionpack (= 3.2.11)
81
+ activesupport (= 3.2.11)
82
+ rack-ssl (~> 1.3.2)
83
+ rake (>= 0.8.7)
84
+ rdoc (~> 3.4)
85
+ thor (>= 0.14.6, < 2.0)
22
86
  rake (10.0.3)
23
87
  rdoc (3.12.1)
24
88
  json (~> 1.4)
@@ -30,6 +94,13 @@ GEM
30
94
  rspec-expectations (2.12.1)
31
95
  diff-lcs (~> 1.1.3)
32
96
  rspec-mocks (2.12.2)
97
+ rspec-rails (2.12.2)
98
+ actionpack (>= 3.0)
99
+ activesupport (>= 3.0)
100
+ railties (>= 3.0)
101
+ rspec-core (~> 2.12.0)
102
+ rspec-expectations (~> 2.12.0)
103
+ rspec-mocks (~> 2.12.0)
33
104
  ruby-debug-base19 (0.11.25)
34
105
  columnize (>= 0.3.1)
35
106
  linecache19 (>= 0.5.11)
@@ -44,7 +115,17 @@ GEM
44
115
  multi_json (~> 1.0)
45
116
  simplecov-html (~> 0.7.1)
46
117
  simplecov-html (0.7.1)
118
+ sprockets (2.2.2)
119
+ hike (~> 1.2)
120
+ multi_json (~> 1.0)
121
+ rack (~> 1.0)
122
+ tilt (~> 1.1, != 1.3.0)
47
123
  thor (0.17.0)
124
+ tilt (1.3.3)
125
+ treetop (1.4.12)
126
+ polyglot
127
+ polyglot (>= 0.3.1)
128
+ tzinfo (0.3.35)
48
129
 
49
130
  PLATFORMS
50
131
  ruby
@@ -52,10 +133,15 @@ PLATFORMS
52
133
  DEPENDENCIES
53
134
  activesupport
54
135
  bundler
136
+ git
137
+ haml
138
+ header_navigation (~> 0.0.1)
55
139
  jeweler (~> 1.8.4)
140
+ rails
56
141
  rake
57
142
  rdoc
58
143
  rspec
144
+ rspec-rails
59
145
  ruby-debug19
60
146
  simplecov
61
147
  thor
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 1.0.0
data/confluence.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "confluence"
8
- s.version = "0.2.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Chen"]
12
- s.date = "2013-02-19"
12
+ s.date = "2013-02-20"
13
13
  s.description = "confluence is the merging of rivers. In particular, it is the merging of the fay-haskell-coffee-js river with the scss-css river with the psd-png river into the rails-ruby-haml rivers"
14
14
  s.email = "foxnewsnetwork@gmail.com"
15
15
  s.executables = ["confluence"]
@@ -29,7 +29,8 @@ Gem::Specification.new do |s|
29
29
  "bin/confluence",
30
30
  "confluence.gemspec",
31
31
  "lib/confluence.rb",
32
- "lib/confluence/navigator.rb",
32
+ "lib/confluence/railtie.rb",
33
+ "lib/confluence/railties/resolver.rb",
33
34
  "lib/confluence/templates/%project_name%.cabal.tt",
34
35
  "lib/confluence/templates/.document",
35
36
  "lib/confluence/templates/.gitignore",
@@ -88,10 +89,49 @@ Gem::Specification.new do |s|
88
89
  "lib/confluence/templates/test/integration/vendor/assets/stylesheets/.gitkeep",
89
90
  "lib/confluence/templates/test/integration/vendor/plugins/.gitkeep",
90
91
  "lib/confluence/templates/test/javascripts/README.markdown.tt",
91
- "spec/confluence/navigator_spec.rb",
92
+ "spec/confluence/railtie_spec.rb",
93
+ "spec/confluence/railties/resolver_spec.rb",
94
+ "spec/confluence/welcome_controller_spec.rb",
92
95
  "spec/confluence_spec.rb",
93
- "spec/spec_helper.rb",
94
- "spec/support/file_sytem/navigator.rb"
96
+ "spec/fixture/.gitignore",
97
+ "spec/fixture/README.rdoc",
98
+ "spec/fixture/Rakefile",
99
+ "spec/fixture/app/assets/images/rails.png",
100
+ "spec/fixture/app/assets/javascripts/application.js",
101
+ "spec/fixture/app/assets/stylesheets/application.css",
102
+ "spec/fixture/app/controllers/application_controller.rb",
103
+ "spec/fixture/app/controllers/welcome_controller.rb",
104
+ "spec/fixture/app/views/layouts/application.html.erb",
105
+ "spec/fixture/app/views/welcome/index.html.haml",
106
+ "spec/fixture/config.ru",
107
+ "spec/fixture/config/application.rb",
108
+ "spec/fixture/config/boot.rb",
109
+ "spec/fixture/config/environment.rb",
110
+ "spec/fixture/config/environments/development.rb",
111
+ "spec/fixture/config/environments/production.rb",
112
+ "spec/fixture/config/environments/test.rb",
113
+ "spec/fixture/config/initializers/backtrace_silencers.rb",
114
+ "spec/fixture/config/initializers/inflections.rb",
115
+ "spec/fixture/config/initializers/mime_types.rb",
116
+ "spec/fixture/config/initializers/secret_token.rb",
117
+ "spec/fixture/config/initializers/session_store.rb",
118
+ "spec/fixture/config/initializers/wrap_parameters.rb",
119
+ "spec/fixture/config/locales/en.yml",
120
+ "spec/fixture/config/routes.rb",
121
+ "spec/fixture/lib/assets/.gitkeep",
122
+ "spec/fixture/lib/tasks/.gitkeep",
123
+ "spec/fixture/log/.gitkeep",
124
+ "spec/fixture/public/404.html",
125
+ "spec/fixture/public/422.html",
126
+ "spec/fixture/public/500.html",
127
+ "spec/fixture/public/favicon.ico",
128
+ "spec/fixture/public/index.html",
129
+ "spec/fixture/public/robots.txt",
130
+ "spec/fixture/script/rails",
131
+ "spec/fixture/vendor/assets/javascripts/.gitkeep",
132
+ "spec/fixture/vendor/assets/stylesheets/.gitkeep",
133
+ "spec/fixture/vendor/plugins/.gitkeep",
134
+ "spec/spec_helper.rb"
95
135
  ]
96
136
  s.homepage = "http://github.com/foxnewsnetwork/confluence"
97
137
  s.licenses = ["MIT"]
@@ -110,7 +150,13 @@ Gem::Specification.new do |s|
110
150
  s.add_runtime_dependency(%q<rspec>, [">= 0"])
111
151
  s.add_runtime_dependency(%q<thor>, [">= 0"])
112
152
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
153
+ s.add_runtime_dependency(%q<git>, [">= 0"])
113
154
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
155
+ s.add_development_dependency(%q<rails>, [">= 0"])
156
+ s.add_development_dependency(%q<haml>, [">= 0"])
157
+ s.add_development_dependency(%q<rspec>, [">= 0"])
158
+ s.add_development_dependency(%q<rspec-rails>, [">= 0"])
159
+ s.add_development_dependency(%q<header_navigation>, ["~> 0.0.1"])
114
160
  else
115
161
  s.add_dependency(%q<rake>, [">= 0"])
116
162
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -119,7 +165,13 @@ Gem::Specification.new do |s|
119
165
  s.add_dependency(%q<rspec>, [">= 0"])
120
166
  s.add_dependency(%q<thor>, [">= 0"])
121
167
  s.add_dependency(%q<activesupport>, [">= 0"])
168
+ s.add_dependency(%q<git>, [">= 0"])
122
169
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
170
+ s.add_dependency(%q<rails>, [">= 0"])
171
+ s.add_dependency(%q<haml>, [">= 0"])
172
+ s.add_dependency(%q<rspec>, [">= 0"])
173
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
174
+ s.add_dependency(%q<header_navigation>, ["~> 0.0.1"])
123
175
  end
124
176
  else
125
177
  s.add_dependency(%q<rake>, [">= 0"])
@@ -129,7 +181,13 @@ Gem::Specification.new do |s|
129
181
  s.add_dependency(%q<rspec>, [">= 0"])
130
182
  s.add_dependency(%q<thor>, [">= 0"])
131
183
  s.add_dependency(%q<activesupport>, [">= 0"])
184
+ s.add_dependency(%q<git>, [">= 0"])
132
185
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
186
+ s.add_dependency(%q<rails>, [">= 0"])
187
+ s.add_dependency(%q<haml>, [">= 0"])
188
+ s.add_dependency(%q<rspec>, [">= 0"])
189
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
190
+ s.add_dependency(%q<header_navigation>, ["~> 0.0.1"])
133
191
  end
134
192
  end
135
193
 
data/lib/confluence.rb CHANGED
@@ -1,18 +1,21 @@
1
1
  require "rubygems"
2
2
  require "thor"
3
+ require "git"
3
4
  require "active_support/core_ext/string"
4
- Dir[File.join(File.dirname(__FILE__), "confluence", "*.rb")].each { |source| require source }
5
+ require File.join(File.dirname(__FILE__), "confluence", "railtie") if defined?(Rails)
5
6
 
6
7
  module Confluence
7
8
  class Application < Thor
8
9
  include Thor::Actions
9
10
 
10
- attr_accessor :project_name, :project_author
11
+ attr_accessor :project_name, :project_author, :project_email, :project_github_user
11
12
 
12
13
  desc "new", "Creates a new confluence assets project for you in your specified directory"
13
14
  def new(project_name)
14
15
  @project_name = project_name
15
- @project_author = "Me"
16
+ @project_author = Git.global_config["user.name"]
17
+ @project_email = Git.global_config["user.email"]
18
+ @project_github_user = Git.global_config["github.email"]
16
19
  source_path = File.join File.dirname(__FILE__), "confluence", "templates"
17
20
  destination_path = project_name
18
21
  directory( source_path, destination_path )
@@ -0,0 +1,14 @@
1
+ require File.join File.dirname(__FILE__), "railties", "resolver"
2
+
3
+ module Confluence
4
+ module Rails
5
+ class Railtie < ::Rails::Railtie
6
+ # expose the confluence controller runtime
7
+ initializer "confluence.setup" do |app|
8
+ ActiveSupport.on_load(:action_controller) do
9
+ append_view_path Confluence::Railties::Resolver.instance
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,78 @@
1
+ require "singleton"
2
+ module Confluence
3
+ module Railties
4
+ class Resolver < ActionView::Resolver
5
+ include Singleton
6
+ def find_templates(name, prefix, partial, details)
7
+ if partial
8
+ gem_directory = _get_gem_directory prefix
9
+ partial_path = _get_partial_path name, gem_directory
10
+ handler = _get_handler_from_nothing
11
+ source = _get_source_from_path(partial_path)
12
+ identifier = _get_identifier name, prefix
13
+ _get_templates( source, identifier, handler, details )
14
+
15
+ else
16
+ []
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def _checks
23
+ @_checks ||= [
24
+ lambda do |not_null|
25
+ !not_null.nil?
26
+ end
27
+ ]
28
+ end
29
+
30
+ def _get_templates( *stuffs )
31
+ results = _checks.inject(true) do |status, check|
32
+ stuffs.inject(status) do |mem, stuff|
33
+ mem && check.call(stuff)
34
+ end
35
+ end
36
+ if results
37
+ [ActionView::Template.new(stuffs.shift, stuffs.shift, stuffs.shift, stuffs.shift)]
38
+ else
39
+ []
40
+ end
41
+ end
42
+
43
+ def _get_gem_directory(prefix)
44
+ return nil if prefix.nil? || prefix.blank?
45
+ prefixes = prefix.split("/")
46
+ gem_name = prefixes.first
47
+ if gem_root_path = Gem.loaded_specs[gem_name].try( :full_gem_path)
48
+ File.join(gem_root_path, "assets", "html", *prefixes[1..-1])
49
+ else
50
+ nil
51
+ end
52
+ end
53
+
54
+ # This assumes, of course, our gem is built from confluence
55
+ # TODO: throw an error if our gem isn't confluent
56
+ def _get_partial_path(name, path)
57
+ return nil if name.nil? || path.nil?
58
+ names = name.split("/")
59
+ names.push( "_#{names.pop}" )
60
+ File.join(path, *names)
61
+ end
62
+
63
+ def _get_source_from_path(path)
64
+ return nil if path.nil?
65
+ File.read( path + ".html.haml" )
66
+ end
67
+
68
+ def _get_handler_from_nothing
69
+ ActionView::Template.registered_template_handler("haml")
70
+ end
71
+
72
+ def _get_identifier(name, prefix)
73
+ "#{name.hash}-#{prefix.hash}"
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -19,7 +19,7 @@ synopsis: WRITE ME!
19
19
  -- description: WRITE ME
20
20
 
21
21
  -- URL for the project homepage or repository.
22
- homepage: WRITE ME
22
+ homepage: https://github.com/<%= project_github_user %>/<%= project_name %>
23
23
 
24
24
  -- The license under which the package is released.
25
25
  license: MIT
@@ -28,11 +28,11 @@ license: MIT
28
28
  license-file: LICENSE.txt
29
29
 
30
30
  -- The package author(s).
31
- author: WRITE ME
31
+ author: <%= project_author %>
32
32
 
33
33
  -- An email address to which users can send suggestions, bug reports, and
34
34
  -- patches.
35
- maintainer: WRITE ME
35
+ maintainer: <%= project_author %>
36
36
 
37
37
  -- A copyright notice.
38
38
  -- copyright:
@@ -60,5 +60,5 @@ library
60
60
 
61
61
 
62
62
  -- Directories containing source files.
63
- hs-source-dirs: src/javascripts
63
+ hs-source-dirs: assets/javascripts
64
64
 
@@ -15,12 +15,12 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "<%= project_name %>"
18
- gem.homepage = %Q{TODO: your homepage}
18
+ gem.homepage = "https://github.com/<%= project_github_user %>/<%= project_name %>"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{TODO: one-line summary of your gem}
21
21
  gem.description = %Q{TODO: longer description of your gem}
22
- gem.email = %Q{TODO: your email}
23
- gem.authors = [%Q{TODO: YOU}]
22
+ gem.email = "<%= project_email %>"
23
+ gem.authors = ["<%= project_author %>"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
26
  Jeweler::RubygemsDotOrgTasks.new
@@ -30,7 +30,7 @@ Rake::RDocTask.new do |rdoc|
30
30
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
31
31
 
32
32
  rdoc.rdoc_dir = 'rdoc'
33
- rdoc.title = "comment #{version}"
33
+ rdoc.title = "<%= project_name %> #{version}"
34
34
  rdoc.rdoc_files.include('README*')
35
35
  rdoc.rdoc_files.include('lib/**/*.rb')
36
36
  end