Kharites-tools 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in server.rb, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{Kharites-tools}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jose Pablo Barrantes"]
12
+ s.date = %q{2010-05-03}
13
+ s.default_executable = %q{kharites}
14
+ s.description = %q{Tools for Karites.}
15
+ s.email = %q{xjpablobrx@gmail.com}
16
+ s.executables = ["kharites"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ "Kharites-tools.gemspec",
23
+ "LICENSE",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/kharites",
28
+ "lib/kharites.rb",
29
+ "lib/kharites/base.rb",
30
+ "lib/kharites/mixins/console.rb",
31
+ "lib/kharites/mixins/generate.rb",
32
+ "lib/kharites/mixins/server.rb",
33
+ "lib/kharites/mixins/sync.rb",
34
+ "lib/kharites/templates/article/article.kharites",
35
+ "lib/kharites/templates/article/public/images/article.jpg",
36
+ "lib/kharites/templates/article/public/javascripts/article.js",
37
+ "lib/kharites/templates/article/views/application.sass",
38
+ "lib/kharites/templates/article/views/index.haml",
39
+ "lib/kharites/templates/article/views/layout.haml",
40
+ "spec/base_spec.rb",
41
+ "spec/sandbox/test_article/test-article.kharites",
42
+ "spec/sandbox/test_article/views/application.sass",
43
+ "spec/sandbox/test_article/views/index.haml",
44
+ "spec/sandbox/test_article/views/layout.haml",
45
+ "spec/setup_spec.rb",
46
+ "spec/spec_helper.rb"
47
+ ]
48
+ s.homepage = %q{http://github.com/jpablobr/kharites-tools}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubyforge_project = %q{kharites-tools}
52
+ s.rubygems_version = %q{1.3.6}
53
+ s.summary = %q{Tools for the Karites.}
54
+ s.test_files = [
55
+ "spec/spec_helper.rb",
56
+ "spec/setup_spec.rb",
57
+ "spec/base_spec.rb"
58
+ ]
59
+
60
+ if s.respond_to? :specification_version then
61
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
62
+ s.specification_version = 3
63
+
64
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
65
+ else
66
+ end
67
+ else
68
+ end
69
+ end
70
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2010 Jose Pablo Barrantes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # Kharites-tools
2
+
3
+ Gem to provide several tools to [Kharites](http://github.com/jpablobr/kharites)
4
+
5
+ ## Installation ##
6
+
7
+ For the latest stable version:
8
+
9
+ ` sudo gem install kharites-tools`
10
+
11
+ Or from source:
12
+
13
+ git clone git://github.com/jpablobr/kharites-tools.git
14
+ cd kharites-tools
15
+ rake install
16
+
17
+ ## Usage ##
18
+
19
+ Enter `Kharites`
20
+
21
+ Kharites will set up a basic site structure for you with this command:
22
+
23
+ kharites generate <article>
24
+
25
+ After this command you'll have the following files:
26
+
27
+ .
28
+ `-- <article>
29
+ |-- article.kharites
30
+ |-- public
31
+ | |-- images
32
+ | |-- javascripts
33
+ | `-- stylesheets
34
+ `-- views
35
+ |-- application.sass
36
+ |-- index.haml
37
+ `-- layout.haml
38
+
39
+ Kharites sets you up with a sample layout, stylesheet and page file.
40
+
41
+ kharites server
42
+
43
+ Load this URL in your browser:
44
+
45
+ http://localhost:4567/ariticles/article
46
+
47
+ You’re done. SRSLY.
48
+
49
+ ## TODO ##
50
+
51
+ * Add commands for install, start, sync (for [Post receive hooks](http://github.com/guides/post-receive-hooks)), deploy, etc...
52
+
53
+ ## Note on Patches/Pull Requests ##
54
+
55
+ Fork the project.
56
+ Make your feature addition or bug fix.
57
+ Add tests for it. This is important so I don’t break it in a future version unintentionally.
58
+ Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
59
+ Send me a pull request. Bonus points for topic branches.
60
+
61
+ ## Copyright ##
62
+
63
+ Copyright 2009 Jose Pablo Barrantes. MIT Licence, so go for it.
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'spec/rake/spectask'
3
+
4
+ require File.dirname(__FILE__) + '/lib/kharites'
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gemspec|
8
+ gemspec.name = "Kharites-tools"
9
+ gemspec.executables = "kharites"
10
+ gemspec.summary = "Tools for the Karites."
11
+ gemspec.description = "Tools for Karites."
12
+ gemspec.email = "xjpablobrx@gmail.com"
13
+ gemspec.homepage = "http://github.com/jpablobr/kharites-tools"
14
+ gemspec.authors = ["Jose Pablo Barrantes"]
15
+ gemspec.rubyforge_project = "kharites-tools"
16
+ gemspec.files = FileList["[A-Z]*", "{bin,lib,spec}/**/*"]
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
21
+ end
22
+
23
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
24
+
25
+ Spec::Rake::SpecTask.new(:spec) do |spec|
26
+ spec.libs << 'lib' << 'spec'
27
+ spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require File.dirname(__FILE__) + '/../lib/kharites'
3
+
4
+ command = ARGV[0]
5
+ directory = ARGV[1]
6
+
7
+ if !command || !directory
8
+ puts "Usage: #{$0} <generate> <article>"
9
+ exit
10
+ end
11
+
12
+ $:.push File.join(directory, "lib")
13
+
14
+ kharites = Kharites::Base.new(directory)
15
+ kharites.run(command)
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'fileutils'
3
+
4
+ module Kharites
5
+ VERSION = "0.1.0"
6
+ end
7
+
8
+ ["sync", "generate", "server", "console"].each do |mixin|
9
+ require File.join(File.dirname(__FILE__), "kharites", "mixins", mixin)
10
+ end
11
+
12
+ ["base"].each do |lib|
13
+ require File.join(File.dirname(__FILE__), "kharites", lib)
14
+ end
@@ -0,0 +1,36 @@
1
+ module Kharites
2
+ class Base
3
+
4
+ include Kharites::SetupMixin
5
+ attr_reader :current_page, :src_dir, :site_dir
6
+
7
+ def current_file
8
+ @current_file_stack[0] || ""
9
+ end
10
+
11
+ def initialize(base_dir)
12
+ @current_page = nil
13
+ @current_file_stack = []
14
+ @base_dir = base_dir
15
+ @src_dir = File.join(@base_dir, "views")
16
+ @site_dir = File.join(@base_dir, "public")
17
+ @scope = Object.new
18
+ @scope.instance_variable_set("@kharites", self)
19
+ end
20
+
21
+ def base_dir
22
+ @base_dir
23
+ end
24
+
25
+ def run(command)
26
+ puts "Article root is: #{@base_dir}"
27
+
28
+ if %w(sync generate server console).include?(command)
29
+ send(command)
30
+ else
31
+ puts "#{command} is not a valid Kharites command"
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,17 @@
1
+ module Kharites::SetupMixin
2
+
3
+ def generate
4
+ Dir.mkdir(@base_dir) unless File.exists?(@base_dir)
5
+
6
+ Dir[File.join(File.dirname(__FILE__), "..", "templates", "article", "*")].each do |template|
7
+ begin
8
+ FileUtils.cp_r(template, @base_dir)
9
+ rescue Errno::EEXIST
10
+ end
11
+ end
12
+
13
+ FileUtils.cd(@base_dir) {|dir| FileUtils.mv("article.kharites", "#{dir}.kharites") unless "#{dir}.kharites" == "article.kharites"}
14
+
15
+ puts "Done"
16
+ end
17
+ end
@@ -0,0 +1,117 @@
1
+ require 'thor'
2
+
3
+ module Padrino
4
+ module Cli
5
+
6
+ class Base < Thor
7
+ include Thor::Actions
8
+ include Thor::RakeCompat
9
+
10
+ class_option :chdir, :type => :string, :aliases => "-c", :desc => "Change to dir before starting"
11
+ class_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development, :desc => "Padrino Environment"
12
+ class_option :help, :type => :boolean, :desc => "Show help usage"
13
+
14
+ desc "start", "Starts the Padrino application"
15
+ method_option :adapter, :type => :string, :aliases => "-a", :desc => "Rack Handler (default: autodetect)"
16
+ method_option :host, :type => :string, :aliases => "-h", :required => true, :default => "localhost", :desc => "Bind to HOST address"
17
+ method_option :port, :type => :numeric, :aliases => "-p", :required => true, :default => 3000, :desc => "Use PORT"
18
+ method_option :daemonize, :type => :boolean, :aliases => "-d", :desc => "Run daemonized in the background"
19
+ def start
20
+ prepare :start
21
+ require File.expand_path(File.dirname(__FILE__) + "/adapter")
22
+ require 'config/boot'
23
+ Padrino::Cli::Adapter.start(options)
24
+ end
25
+
26
+ desc "stop", "Stops the Padrino application"
27
+ def stop
28
+ require File.expand_path(File.dirname(__FILE__) + "/adapter")
29
+ Padrino::Cli::Adapter.stop
30
+ end
31
+
32
+ desc "rake", "Execute rake tasks"
33
+ method_option :environment, :type => :string, :aliases => "-e", :required => true, :default => :development
34
+ method_option :list, :type => :string, :aliases => "-T", :desc => "Display the tasks (matching optional PATTERN) with descriptions, then exit."
35
+ method_option :trace, :type => :boolean, :aliases => "-t", :desc => "Turn on invoke/execute tracing, enable full backtrace."
36
+ method_option :verbose, :type => :boolean, :aliases => "-v", :desc => "Log message to standard output."
37
+ def rake(*args)
38
+ prepare :rake
39
+ args << "-T" if options[:list]
40
+ args << options[:list] unless options[:list].nil? || options[:list].to_s == "list"
41
+ args << "--trace" if options[:trace]
42
+ args << "--verbose" if options[:verbose]
43
+ ARGV.clear
44
+ ARGV.concat(args)
45
+ puts "=> Executing Rake #{ARGV.join(' ')} ..."
46
+ ENV['PADRINO_LOG_LEVEL'] ||= "test"
47
+ require File.expand_path(File.dirname(__FILE__) + '/rake')
48
+ silence(:stdout) { require 'config/boot' }
49
+ PadrinoTasks.init
50
+ end
51
+
52
+ desc "console", "Boots up the Padrino application irb console"
53
+ def console
54
+ prepare :console
55
+ require File.expand_path(File.dirname(__FILE__) + "/../version")
56
+ ARGV.clear
57
+ puts "=> Loading #{options.environment} console (Padrino v.#{Padrino.version})"
58
+ require 'irb'
59
+ require "irb/completion"
60
+ require 'config/boot'
61
+ require File.expand_path(File.dirname(__FILE__) + '/console')
62
+ IRB.start
63
+ end
64
+
65
+ desc "version", "Show current Padrino Version"
66
+ map "-v" => :version, "--version" => :version
67
+ def version
68
+ require 'padrino-core/version'
69
+ puts "Padrino v. #{Padrino.version}"
70
+ end
71
+
72
+ private
73
+ def prepare(task)
74
+ if options.help?
75
+ help(task.to_s)
76
+ raise SystemExit
77
+ end
78
+ ENV["PADRINO_ENV"] ||= options.environment.to_s
79
+ chdir(options.chdir)
80
+ unless File.exist?('config/boot.rb')
81
+ puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
82
+ raise SystemExit
83
+ end
84
+ end
85
+
86
+ protected
87
+ def self.banner(task)
88
+ "padrino #{task.name}"
89
+ end
90
+
91
+ def chdir(dir)
92
+ return unless dir
93
+ begin
94
+ Dir.chdir(dir.to_s)
95
+ rescue Errno::ENOENT
96
+ puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
97
+ rescue Errno::EACCES
98
+ puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
99
+ end
100
+ end
101
+
102
+ def capture(stream)
103
+ begin
104
+ stream = stream.to_s
105
+ eval "$#{stream} = StringIO.new"
106
+ yield
107
+ result = eval("$#{stream}").string
108
+ ensure
109
+ eval("$#{stream} = #{stream.upcase}")
110
+ end
111
+
112
+ result
113
+ end
114
+ alias :silence :capture
115
+ end # Base
116
+ end # Cli
117
+ end # Padrino
@@ -0,0 +1,12 @@
1
+ {{
2
+ categories:
3
+ - ruby
4
+ - git
5
+ - markdown
6
+ - blogging
7
+ - kharites
8
+ }}
9
+
10
+ # This is the article one (3000/01/01)
11
+
12
+ This is the exceprt of the test article with explicit date...
@@ -0,0 +1,6 @@
1
+ body
2
+ font:
3
+ family: Verdana
4
+ size: 10pt
5
+ color: 555
6
+
@@ -0,0 +1 @@
1
+ %h1 Kharites FTW!
@@ -0,0 +1,6 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title Kharites
5
+ %body
6
+ = yield
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "Kharites::Base" do
4
+ before do
5
+ generate_kharites
6
+ end
7
+
8
+ it "should set initial directory" do
9
+
10
+ end
11
+
12
+ end
@@ -0,0 +1,4 @@
1
+ body
2
+ font:
3
+ family: Verdana
4
+ size: 10pt
@@ -0,0 +1 @@
1
+ %h1 StaticMatic!
@@ -0,0 +1,7 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title StaticMatic
5
+ = stylesheets
6
+ %body
7
+ = yield
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "Kharites::Generate" do
4
+ before do
5
+ generate_kharites
6
+ @tmp_dir = File.dirname(__FILE__) + '/sandbox/tmp'
7
+ kharites = Kharites::Base.new(@tmp_dir)
8
+ kharites.run('generate')
9
+ end
10
+
11
+ it "should set up project directory in given path" do
12
+ %w(
13
+ public/images
14
+ public/javascripts
15
+ public/stylesheets
16
+ views/layout.haml
17
+ views/index.haml
18
+ views/application.sass
19
+ ).each {|path| File.exists?(File.join(@tmp_dir, path)).should(be_true, "#{path} expected to exist in #{@tmp_dir}") }
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'stringio'
3
+ require 'spec'
4
+
5
+ require File.dirname(__FILE__) + '/../lib/kharites'
6
+
7
+ TEST_SITE_PATH = File.expand_path(File.join(File.dirname(__FILE__), "sandbox", "test_article"))
8
+
9
+ Spec::Runner.configure do |config|
10
+ end
11
+
12
+ def setup_kharites
13
+ @kharites = Kharites::Base.new(TEST_ARTICLE_PATH)
14
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Kharites-tools
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jose Pablo Barrantes
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-03 00:00:00 -06:00
18
+ default_executable: kharites
19
+ dependencies: []
20
+
21
+ description: Tools for Karites.
22
+ email: xjpablobrx@gmail.com
23
+ executables:
24
+ - kharites
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - LICENSE
29
+ - README.markdown
30
+ files:
31
+ - Kharites-tools.gemspec
32
+ - LICENSE
33
+ - README.markdown
34
+ - Rakefile
35
+ - VERSION
36
+ - bin/kharites
37
+ - lib/kharites.rb
38
+ - lib/kharites/base.rb
39
+ - lib/kharites/mixins/console.rb
40
+ - lib/kharites/mixins/generate.rb
41
+ - lib/kharites/mixins/server.rb
42
+ - lib/kharites/mixins/sync.rb
43
+ - lib/kharites/templates/article/article.kharites
44
+ - lib/kharites/templates/article/public/images/article.jpg
45
+ - lib/kharites/templates/article/public/javascripts/article.js
46
+ - lib/kharites/templates/article/views/application.sass
47
+ - lib/kharites/templates/article/views/index.haml
48
+ - lib/kharites/templates/article/views/layout.haml
49
+ - spec/base_spec.rb
50
+ - spec/sandbox/test_article/test-article.kharites
51
+ - spec/sandbox/test_article/views/application.sass
52
+ - spec/sandbox/test_article/views/index.haml
53
+ - spec/sandbox/test_article/views/layout.haml
54
+ - spec/setup_spec.rb
55
+ - spec/spec_helper.rb
56
+ has_rdoc: true
57
+ homepage: http://github.com/jpablobr/kharites-tools
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options:
62
+ - --charset=UTF-8
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ requirements: []
80
+
81
+ rubyforge_project: kharites-tools
82
+ rubygems_version: 1.3.6
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Tools for the Karites.
86
+ test_files:
87
+ - spec/spec_helper.rb
88
+ - spec/setup_spec.rb
89
+ - spec/base_spec.rb