roger 1.1.3 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -0
  3. data/.rubocop.yml +47 -0
  4. data/.travis.yml +1 -5
  5. data/CHANGELOG.md +8 -0
  6. data/Gemfile +3 -3
  7. data/Rakefile +10 -4
  8. data/bin/roger +1 -1
  9. data/doc/mockupfile.md +97 -0
  10. data/doc/templating.md +5 -1
  11. data/examples/default_template/Gemfile +1 -1
  12. data/lib/roger/cli.rb +41 -36
  13. data/lib/roger/cli/command.rb +2 -4
  14. data/lib/roger/cli/generate.rb +1 -0
  15. data/lib/roger/cli/release.rb +2 -2
  16. data/lib/roger/cli/serve.rb +11 -11
  17. data/lib/roger/cli/test.rb +6 -5
  18. data/lib/roger/extractor.rb +42 -43
  19. data/lib/roger/generators.rb +27 -19
  20. data/lib/roger/generators/generator.rb +7 -10
  21. data/lib/roger/generators/new.rb +56 -41
  22. data/lib/roger/generators/templates/generator.tt +5 -5
  23. data/lib/roger/helpers/get_callable.rb +15 -14
  24. data/lib/roger/helpers/logging.rb +35 -13
  25. data/lib/roger/mockupfile.rb +13 -23
  26. data/lib/roger/project.rb +41 -34
  27. data/lib/roger/rack/roger.rb +28 -29
  28. data/lib/roger/rack/sleep.rb +4 -5
  29. data/lib/roger/release.rb +95 -72
  30. data/lib/roger/release/cleaner.rb +14 -13
  31. data/lib/roger/release/finalizers.rb +10 -10
  32. data/lib/roger/release/finalizers/dir.rb +17 -19
  33. data/lib/roger/release/finalizers/git_branch.rb +76 -38
  34. data/lib/roger/release/finalizers/rsync.rb +60 -49
  35. data/lib/roger/release/finalizers/zip.rb +32 -29
  36. data/lib/roger/release/injector.rb +43 -37
  37. data/lib/roger/release/processors.rb +24 -22
  38. data/lib/roger/release/processors/mockup.rb +97 -69
  39. data/lib/roger/release/processors/url_relativizer.rb +57 -30
  40. data/lib/roger/release/scm.rb +30 -27
  41. data/lib/roger/release/scm/git.rb +101 -92
  42. data/lib/roger/resolver.rb +86 -61
  43. data/lib/roger/server.rb +52 -27
  44. data/lib/roger/template.rb +102 -74
  45. data/lib/roger/test.rb +16 -13
  46. data/lib/roger/version.rb +3 -2
  47. data/roger.gemspec +9 -5
  48. data/test/helpers/cli.rb +17 -15
  49. data/test/project/Gemfile +2 -2
  50. data/test/project/html/formats/csv.rcsv +0 -0
  51. data/test/project/lib/generators/test.rb +2 -3
  52. data/test/project/lib/tests/fail/fail.rb +5 -6
  53. data/test/project/lib/tests/noop/lib/cli.rb +2 -1
  54. data/test/project/lib/tests/noop/lib/test.rb +5 -5
  55. data/test/project/lib/tests/noop/noop.rb +2 -1
  56. data/test/project/lib/tests/succeed/succeed.rb +5 -6
  57. data/test/unit/cli/cli_base_test.rb +2 -3
  58. data/test/unit/cli/cli_generate_test.rb +9 -10
  59. data/test/unit/cli/cli_serve_test.rb +22 -18
  60. data/test/unit/cli/cli_test_test.rb +13 -15
  61. data/test/unit/cli/cli_version_test.rb +4 -4
  62. data/test/unit/generators_test.rb +8 -10
  63. data/test/unit/helpers/logging_test.rb +64 -0
  64. data/test/unit/rack/roger_test.rb +21 -0
  65. data/test/unit/release/cleaner_test.rb +23 -19
  66. data/test/unit/release/finalizers/git_branch_test.rb +2 -1
  67. data/test/unit/release/finalizers/zip_test.rb +48 -0
  68. data/test/unit/release/mockup_test.rb +48 -0
  69. data/test/unit/release/processors_test.rb +19 -19
  70. data/test/unit/release_test.rb +15 -14
  71. data/test/unit/resolver_test.rb +21 -14
  72. data/test/unit/server_test.rb +31 -0
  73. data/test/unit/template_test.rb +58 -36
  74. data/test/unit/test_test.rb +3 -2
  75. metadata +35 -9
  76. data/test/Mockupfile-syntax.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 529078b0dd6c7db86bf462cc8c41227781a2ffd6
4
- data.tar.gz: 5a9ea1e08b310b790b0db1d98eab685050d96b77
3
+ metadata.gz: d86fb892f4028385d30405b3f4d06fa709cf4d5e
4
+ data.tar.gz: c0bf2f37b72b13a4b9e070487915d4915717eea1
5
5
  SHA512:
6
- metadata.gz: 136bbf5bda373b17f22552debc7ab00a86dc14e4f58eb4c10d031fee800e9eee21802620482c848c9f8a02cc39b2a64e1a30bd14143e890898b363d9e82042bf
7
- data.tar.gz: 223c5f6a9e329d6e6a9f4913a5925c587f51106bb261f31190c00df03483e77a57fdcca37c3c1529819e7e094f8d0ef7dcc00000ca80d6eb647da5225804ad8b
6
+ metadata.gz: c4f2e4e2948a90dfb8ace4ef4763b85cd4309fb03e144fde95199d04dc0746e9fc38a4af80fb7617ff5f1cee1250fc6209cd1470d7a0369a3959b694af467c27
7
+ data.tar.gz: 2a4ae577eb0a87c5d8835737ba6974e5c72f057b90d890b3cc6ba75557c546a3652ff94d149ec56be1ff85e95ebf71304066965f6cf4c9944e25f6f80e93fa07
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
@@ -0,0 +1,47 @@
1
+ LineLength:
2
+ Description: 'Limit lines to 100 characters.'
3
+ Max: 100
4
+ Enabled: true
5
+
6
+ StringLiterals:
7
+ EnforcedStyle: double_quotes
8
+ Enabled: true
9
+
10
+ Style/DotPosition:
11
+ EnforcedStyle: trailing
12
+ Enabled: true
13
+
14
+ Metrics/MethodLength:
15
+ CountComments: false # count full line comments?
16
+ Max: 20
17
+
18
+ Metrics/AbcSize:
19
+ Max: 20
20
+
21
+ Style/ClassAndModuleChildren:
22
+ EnforcedStyle: compact
23
+ Enabled: false
24
+
25
+ # By default, the rails cops are not run. Override in project or home
26
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
27
+ AllCops:
28
+ RunRailsCops: false
29
+
30
+ # Disabled cops
31
+ Metrics/ClassLength:
32
+ Enabled: false
33
+
34
+ Metrics/ModuleLength:
35
+ Enabled: false
36
+
37
+ Style/EachWithObject:
38
+ Enabled: false
39
+
40
+ Style/AccessorMethodName:
41
+ Enabled: false
42
+
43
+ Lint/AssignmentInCondition:
44
+ Enabled: false
45
+
46
+ Style/SingleLineBlockParams:
47
+ Enabled: false
@@ -3,13 +3,9 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - 2.1.1
6
- - rbx-2
7
- - jruby
6
+ - 2.2.2
8
7
  before_script:
9
8
  - git config --global user.email "travis-ci@digitpaint.nl"
10
9
  - git config --global user.name "Travis-CI"
11
10
  matrix:
12
- allow_failures:
13
- - rvm: rbx-2
14
- - rvm: jruby
15
11
  fast_finish: true
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.2.1
4
+ * Fix missing env (https://github.com/DigitPaint/roger/issues/24)
5
+
6
+ ## Version 1.2.0
7
+ * `roger.project` is now always in `env` when running as a project or as a release. Use this in favor of `env["MOCKUP_PROJECT"]`
8
+ * All Roger code now is linted by Rubocop. More tests have been added and more documentation as well. Still not everything may have been covered by the tests.
9
+
10
+
3
11
  ## Version 1.1.3
4
12
  * Add `--version` flag so we can ask what version of Roger we're running.
5
13
 
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gemspec :name => "roger"
3
+ gemspec name: "roger"
4
4
 
5
- gem "rake"
5
+ gem "rake"
data/Rakefile CHANGED
@@ -1,9 +1,15 @@
1
- require 'rake/testtask'
1
+ require "rake/testtask"
2
+ require "rubocop/rake_task"
2
3
 
3
- task :default => [:test]
4
+ task default: [:test, :rubocop]
5
+
6
+ desc "Run rubocop"
7
+ task :rubocop do
8
+ RuboCop::RakeTask.new
9
+ end
4
10
 
5
11
  Rake::TestTask.new do |t|
6
12
  t.libs << "test"
7
- t.test_files = FileList['test/unit/**/*_test.rb']
13
+ t.test_files = FileList["test/unit/**/*_test.rb"]
8
14
  t.verbose = true
9
- end
15
+ end
data/bin/roger CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require File.dirname(__FILE__) + "/../lib/roger/cli"
4
4
 
5
- Roger::Cli::Base.start
5
+ Roger::Cli::Base.start
@@ -1,3 +1,100 @@
1
1
  # Mockupfile
2
2
 
3
3
  The mockupfile is where all the project configuration for releasing, serving etc. happens.
4
+
5
+ ## Example
6
+
7
+ ```ruby
8
+
9
+ # Some SASS defaults
10
+ Sass::Plugin.options[:style] = :expanded
11
+ Sass::Plugin.options[:template_location] = "./html/stylesheets"
12
+ Sass::Plugin.options[:css_location] = "./html/stylesheets"
13
+
14
+ # Set verbosity to true (you can also pass --verbose to roger)
15
+ # mockup.project.options[:verbose] = true
16
+
17
+ # These are defaults, but can be set here
18
+ # mockup.project.html_path = mockup.project.path + "html"
19
+ # mockup.project.partial_path = mockup.project.path + "partials"
20
+
21
+ # Server is a regular Rack interface.
22
+ mockup.serve do |server|
23
+ server.use :sass
24
+ end
25
+
26
+ # Define tests
27
+ mockup.test do |t|
28
+ t.use :jshint
29
+ end
30
+
31
+ mockup.release do |release|
32
+
33
+ # The variables below can be used anywhere in this section
34
+ release.target_path # The target path where releases are put
35
+ release.build_path # The path where the release gets built
36
+ release.source_path # The source for this mockup
37
+
38
+ # Get git version, these variables can be used anywhere in this section
39
+ release.scm.previous # Get the previous version SCM op (looks for tags)
40
+ release.scm.version # Get the git version
41
+ release.scm.date # Get the git date
42
+
43
+ # Extract mockup (this is optional)
44
+ # release.mockup
45
+
46
+ # Create custom banner
47
+ #
48
+ # The default banner looks like this:
49
+ #
50
+ # =======================
51
+ # = Version : v1.0.0 =
52
+ # = Date : 2012-06-20 =
53
+ # =======================
54
+ release.banner do
55
+ "bla bla bla"
56
+ end
57
+
58
+ # Sassify CSS (this are the defaults too), all options except form :match and :skip are passed to Sass.compile_file
59
+ # release.use :sass, :match => ["stylesheets/**/*.scss"], :skip => [/_.*\.scss\Z/], :style => :expanded
60
+ # The previous statement is the same as:
61
+ release.use :sass
62
+
63
+ # Run requirejs optimizer
64
+ # release.use :requirejs, {
65
+ # :build_files => {"javascripts/site.build.js" => "javascripts"},
66
+ # :rjs => release.source_path + "../vendor/requirejs/r.js",
67
+ # :node => "node"
68
+ # }
69
+ release.use :requirejs
70
+
71
+ # Minify, will not minify anything above the :delimiter
72
+ # release.use :yuicompressor, {
73
+ # :match => ["**/*.{css,js}"],
74
+ # :skip => [/javascripts\/vendor\/.*\.js\Z/, /_doc\/.*/],
75
+ # :delimiter => Regexp.escape("/* -------------------------------------------------------------------------------- */")
76
+ # }
77
+ # The previous statement is the same as:
78
+ release.use :yuicompressor
79
+
80
+ # Inject VERSION / DATE (i.e. in TOC)
81
+ r.inject({ "[VERSION]" => release.scm.version, "[DATE]" => release.scm.date.strftime("%Y-%m-%d") }, into: %w(_doc/toc.html))
82
+
83
+ # Inject Banners on everything matching the regexp in all .css files
84
+ # The banner will be commented as CSS.
85
+ release.inject({ /\/\*\s*\[BANNER\]\s*\*\// => r.banner(comment: :css) }, into: %w(**/*.css))
86
+
87
+ # Inject CHANGELOG
88
+ release.inject({ "[CHANGELOG]" => { file: "../CHANGELOG", processor: "md" } }, into: %w(_doc/changelog.html))
89
+
90
+ # Inject NOTES
91
+ release.inject({ "[NOTES]" => { file: "../NOTES.md", processor: "md" } }, into: %w(_doc/notes.html))
92
+
93
+ # Cleanup on the build
94
+ release.cleanup "**/.DS_Store"
95
+
96
+ # Finalize the release
97
+ # This is the default finalizer so not required
98
+ # release.finalize :dir
99
+ end
100
+ ```
@@ -85,4 +85,8 @@ In the partial these can be accessed as local variables. So for instance in you
85
85
 
86
86
  ```erb
87
87
  <%= key %>
88
- ```
88
+ ```
89
+
90
+ ## Access to Project
91
+
92
+ You can access the Roger project with all it's might and glory by accessing `env["roger.project"]`.
@@ -1,3 +1,3 @@
1
1
  source :rubygems
2
2
 
3
- gem "roger"
3
+ gem "roger"
@@ -1,24 +1,21 @@
1
- require 'rubygems'
1
+ require "rubygems"
2
2
 
3
3
  # Require bundler gems if available
4
- if Object.const_defined?(:Bundler)
5
- Bundler.require(:default)
6
- end
7
-
4
+ Bundler.require(:default) if Object.const_defined?(:Bundler)
8
5
 
9
- require 'thor'
10
- require 'thor/group'
6
+ require "thor"
7
+ require "thor/group"
11
8
 
12
- require 'pathname'
13
- require 'fileutils'
9
+ require "pathname"
10
+ require "fileutils"
14
11
  include FileUtils
15
12
 
16
13
  require File.dirname(__FILE__) + "/version"
17
14
  require File.dirname(__FILE__) + "/template"
18
15
  require File.dirname(__FILE__) + "/project"
19
16
 
20
-
21
17
  module Roger
18
+ # The CLI namespace
22
19
  module Cli; end
23
20
  end
24
21
 
@@ -31,10 +28,9 @@ require File.dirname(__FILE__) + "/cli/test"
31
28
  require File.dirname(__FILE__) + "/generators"
32
29
  require File.dirname(__FILE__) + "/test"
33
30
 
34
-
35
31
  module Roger
32
+ # The Roger main entrypoint!
36
33
  class Cli::Base < Thor
37
-
38
34
  def initialize(*args)
39
35
  super
40
36
  self.class.project ||= initialize_project
@@ -49,38 +45,49 @@ module Roger
49
45
  end
50
46
 
51
47
  class_option :path,
52
- :desc => "Project root path",
53
- :type => :string,
54
- :required => false,
55
- :default => "."
48
+ desc: "Project root path",
49
+ type: :string,
50
+ required: false,
51
+ default: "."
56
52
 
57
53
  class_option :html_path,
58
- :desc => 'The document root, defaults to "[directory]/html"',
59
- :type => :string
54
+ desc: 'The document root, defaults to "[directory]/html"',
55
+ type: :string
60
56
 
61
57
  class_option :partial_path,
62
- :desc => 'Defaults to [directory]/partials',
63
- :type => :string
58
+ desc: "Defaults to [directory]/partials",
59
+ type: :string
64
60
 
65
61
  class_option :verbose,
66
- :desc => "Sets verbose output",
67
- :aliases => ["-v"],
68
- :default => false,
69
- :type => :boolean
62
+ desc: "Sets verbose output",
63
+ aliases: ["-v"],
64
+ default: false,
65
+ type: :boolean
70
66
 
71
- map %w{--version} => :version
67
+ map %w(--version) => :version
72
68
 
73
- desc "test [COMMAND]", "Run one or more tests. Test can be 'all' for all defined tests or a specific test name"
69
+ desc "test [COMMAND]", "Run one or more tests. Test can be 'all' for all
70
+ defined tests or a specific test name"
74
71
  subcommand "test", Cli::Test
75
72
 
76
73
  desc "generate [COMMAND]", "Run a generator"
77
74
  subcommand "generate", Cli::Generate
78
75
 
79
- register Cli::Serve, "serve", "serve #{Cli::Serve.arguments.map{ |arg| arg.banner }.join(" ")}", Cli::Serve.desc
80
- self.tasks["serve"].options = Cli::Serve.class_options
81
-
82
- register Cli::Release, "release", "release #{Cli::Release.arguments.map{ |arg| arg.banner }.join(" ")}", Cli::Release.desc
83
- self.tasks["release"].options = Cli::Release.class_options
76
+ register(
77
+ Cli::Serve,
78
+ "serve",
79
+ "serve #{Cli::Serve.arguments.map(&:banner).join(' ')}",
80
+ Cli::Serve.desc
81
+ )
82
+ tasks["serve"].options = Cli::Serve.class_options
83
+
84
+ register(
85
+ Cli::Release,
86
+ "release",
87
+ "release #{Cli::Release.arguments.map(&:banner).join(' ')}",
88
+ Cli::Release.desc
89
+ )
90
+ tasks["release"].options = Cli::Release.class_options
84
91
 
85
92
  desc "version", "Get the current Roger version"
86
93
  def version
@@ -91,14 +98,12 @@ module Roger
91
98
 
92
99
  # TODO: handle options
93
100
  def initialize_project
94
- if((Pathname.new(options[:path]) + "../partials").exist?)
101
+ if (Pathname.new(options[:path]) + "../partials").exist?
95
102
  puts "[ERROR]: Don't use the \"html\" path, use the project base path instead"
96
103
  exit(1)
97
104
  end
98
105
 
99
- Project.new(options[:path], {:shell => self.shell}.update(options))
106
+ Project.new(options[:path], { shell: shell }.update(options))
100
107
  end
101
-
102
108
  end
103
-
104
- end
109
+ end
@@ -1,11 +1,10 @@
1
1
  module Roger
2
-
2
+ # Abstract base class for Roger commands
3
3
  class Cli::Command < Thor::Group
4
4
  def self.exit_on_failure?
5
5
  true
6
6
  end
7
7
 
8
-
9
8
  def initialize_project
10
9
  @project = Cli::Base.project
11
10
  end
@@ -17,5 +16,4 @@ module Roger
17
16
  puts " Partials: \"#{project.partial_path}\""
18
17
  end
19
18
  end
20
-
21
- end
19
+ end
@@ -1,4 +1,5 @@
1
1
  module Roger::Cli
2
+ # The Generate command
2
3
  class Generate < Thor
3
4
  def self.exit_on_failure?
4
5
  true
@@ -1,10 +1,10 @@
1
1
  module Roger
2
+ # The release command
2
3
  class Cli::Release < Cli::Command
3
-
4
4
  desc "Release the current project"
5
5
 
6
6
  def release
7
7
  @project.release.run!
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -1,25 +1,26 @@
1
1
  module Roger
2
+ # The serve command
2
3
  class Cli::Serve < Cli::Command
3
-
4
-
5
4
  desc "Serve the current project"
6
5
 
7
- class_options :port => :string, # Defaults to 9000
8
- :host => :string, # Defaults to 0.0.0.0
9
- :handler => :string # The handler to use (defaults to mongrel)
6
+ class_options port: :string, # Defaults to 9000
7
+ host: :string, # Defaults to 0.0.0.0
8
+ handler: :string # The handler to use (defaults to mongrel)
10
9
 
11
10
  def serve
12
11
  server_options = {}
13
- options.each{|k,v| server_options[k.to_sym] = v }
12
+ options.each { |k, v| server_options[k.to_sym] = v }
14
13
  server_options[:server] = {}
15
14
  [:port, :handler, :host].each do |k|
16
- server_options[:server][k] = server_options.delete(k) if server_options.has_key?(k)
15
+ server_options[:server][k] = server_options.delete(k) if server_options.key?(k)
17
16
  end
18
17
 
19
- server = @project.server
20
- server.set_options(server_options[:server])
18
+ @project.server.set_options(server_options[:server])
19
+ end
21
20
 
22
- puts "Running Roger with #{server.handler.inspect} on #{server.host}:#{server.port}"
21
+ def show_banner
22
+ server = @project.server
23
+ puts "Running Roger with #{server.handler.inspect} on #{server.host}:#{server.port}"
23
24
  puts project_banner(@project)
24
25
  end
25
26
 
@@ -29,4 +30,3 @@ module Roger
29
30
  end
30
31
  end
31
32
  end
32
-