smartgen 0.1.0 → 0.1.1

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.
data/ChangeLog.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.1.1
2
+ -----
3
+
4
+ * Added rake task to generate files
5
+ * Fixed an issue when generating files without layout
6
+ * Changed defaults for output_folder and metadata_file, now they defaults to nil
7
+
1
8
  0.1.0
2
9
  -----
3
10
 
data/Gemfile CHANGED
@@ -2,6 +2,8 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem "rake", "0.8.7"
6
+
5
7
  platforms :mri_18 do
6
8
  gem "ruby-debug"
7
9
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smartgen (0.0.1)
4
+ smartgen (0.1.1)
5
5
  RedCloth (>= 4.2.3)
6
6
  activesupport (>= 2.3.5)
7
7
  bluecloth (>= 2.0.9)
@@ -21,6 +21,7 @@ GEM
21
21
  linecache (0.43)
22
22
  linecache19 (0.5.11)
23
23
  ruby_core_source (>= 0.1.4)
24
+ rake (0.8.7)
24
25
  rspec (2.3.0)
25
26
  rspec-core (~> 2.3.0)
26
27
  rspec-expectations (~> 2.3.0)
@@ -54,6 +55,7 @@ DEPENDENCIES
54
55
  activesupport (>= 2.3.5)
55
56
  bluecloth (>= 2.0.9)
56
57
  i18n (>= 0.5.0)
58
+ rake (= 0.8.7)
57
59
  rspec (>= 2.3.0)
58
60
  ruby-debug
59
61
  ruby-debug19
data/README.md CHANGED
@@ -117,3 +117,16 @@ You may create as many resource configurations as you want. You create a configu
117
117
 
118
118
  Smartgen[:doc].generate!
119
119
  Smartgen[:some_other_documentation].generate!
120
+
121
+ ## Rake Task
122
+
123
+ You may also use a rake task:
124
+
125
+ require 'smartgen/rake_task'
126
+
127
+ Smartgen::RakeTask.new :my_doc do |config|
128
+ config.src_files = ['doc/**/*']
129
+ config.output_folder = 'public/docs'
130
+ end
131
+
132
+ The yielded config is exactly the same config yielded by Smartgen::Resource#configure method, so you can use any of the above configs.
@@ -8,10 +8,10 @@ module Smartgen
8
8
 
9
9
  def initialize
10
10
  @src_files = []
11
- @output_folder = 'tmp'
11
+ @output_folder = nil
12
12
  @layout = nil
13
13
  @assets = []
14
- @metadata_file = 'metadata.yml'
14
+ @metadata_file = nil
15
15
  end
16
16
  end
17
17
  end
@@ -52,7 +52,7 @@ module Smartgen
52
52
  end
53
53
 
54
54
  def has_layout?
55
- options.has_key?("layout")
55
+ options["layout"].present?
56
56
  end
57
57
 
58
58
  def layout
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+ require 'smartgen'
6
+
7
+ module Smartgen
8
+ class RakeTask < ::Rake::TaskLib
9
+ def initialize(name=nil, &block)
10
+ name = name || :smartgen
11
+
12
+ Smartgen[name].configure(&block)
13
+
14
+ desc("Generate smartgen files") unless ::Rake.application.last_comment
15
+ task name do
16
+ Smartgen[name].generate!
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Smartgen
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
@@ -11,8 +11,8 @@ describe Smartgen::Configuration do
11
11
  subject.src_files.should be_empty
12
12
  end
13
13
 
14
- it "should initialize output folder to 'tmp'" do
15
- subject.output_folder.should == 'tmp'
14
+ it "should initialize output folder to nil" do
15
+ subject.output_folder.should be_nil
16
16
  end
17
17
 
18
18
  it "should initialize layout to nil" do
@@ -23,8 +23,8 @@ describe Smartgen::Configuration do
23
23
  subject.assets.should be_an_empty_array
24
24
  end
25
25
 
26
- it "should initialize metadata_file to 'metadata.yml'" do
27
- subject.metadata_file.should == 'metadata.yml'
26
+ it "should initialize metadata_file to nil" do
27
+ subject.metadata_file.should be_nil
28
28
  end
29
29
  end
30
30
  end
@@ -72,6 +72,19 @@ describe Smartgen::Generator do
72
72
  read_output("index.html").should == read_fixture("expectations/common/index.html")
73
73
  end
74
74
 
75
+ context "with nil layout" do
76
+ def options
77
+ { :layout => nil }
78
+ end
79
+
80
+ it "should not use layout" do
81
+ capture(:stdout) { subject.invoke_all }
82
+ actual_src_filenames.each do |src_filename, src_ext|
83
+ read_output("#{src_filename}.html").should == read_fixture("expectations/common/#{src_filename}.html")
84
+ end
85
+ end
86
+ end
87
+
75
88
  describe "with layout" do
76
89
  def src_files
77
90
  [fixture('src/with_layout/index.textile')]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartgen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vicente Mundim
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-24 00:00:00 -02:00
18
+ date: 2011-01-25 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -117,8 +117,8 @@ dependencies:
117
117
  description: Smartgen generates static HTML files from markup files, using textile or markdown, and ERB to create layout templates
118
118
  email:
119
119
  - vicente.mundim@gmail.com
120
- executables:
121
- - smartgen
120
+ executables: []
121
+
122
122
  extensions: []
123
123
 
124
124
  extra_rdoc_files: []
@@ -132,6 +132,7 @@ files:
132
132
  - lib/smartgen/generator.rb
133
133
  - lib/smartgen/markup_file.rb
134
134
  - lib/smartgen/object_hash.rb
135
+ - lib/smartgen/rake_task.rb
135
136
  - lib/smartgen/renderers/erb.rb
136
137
  - lib/smartgen/renderers.rb
137
138
  - lib/smartgen/resource.rb
@@ -172,7 +173,6 @@ files:
172
173
  - spec/lib/smartgen_spec.rb
173
174
  - spec/sandbox/.gitkeep
174
175
  - spec/spec_helper.rb
175
- - bin/smartgen
176
176
  has_rdoc: true
177
177
  homepage: ""
178
178
  licenses: []
data/bin/smartgen DELETED
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'smartgen/autorun'
5
- rescue LoadError
6
- $stderr.puts <<-EOS
7
- #{'*'*50}
8
- Could not find 'smartgen/autorun'
9
-
10
- This may happen if you're using rubygems as your package manager, but it is not
11
- being required through some mechanism before executing the rspec command.
12
-
13
- You may need to do one of the following in your shell:
14
-
15
- # for bash/zsh
16
- export RUBYOPT=rubygems
17
-
18
- # for csh, etc.
19
- set RUBYOPT=rubygems
20
-
21
- For background, please see http://gist.github.com/54177.
22
- #{'*'*50}
23
- EOS
24
- exit(1)
25
- end