plasmoid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +19 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/plasmoid +8 -0
- data/lib/plasmoid/errors.rb +2 -0
- data/lib/plasmoid/generator/options.rb +80 -0
- data/lib/plasmoid/generator/template_helper.rb +39 -0
- data/lib/plasmoid/generator/templates/Rakefile +3 -0
- data/lib/plasmoid/generator/templates/contents/code/application.js +1 -0
- data/lib/plasmoid/generator/templates/contents/code/main.html +38 -0
- data/lib/plasmoid/generator/templates/contents/code/page1.html +11 -0
- data/lib/plasmoid/generator/templates/contents/code/page2.html +11 -0
- data/lib/plasmoid/generator/templates/contents/code/style.css +0 -0
- data/lib/plasmoid/generator/templates/metadata.desktop +19 -0
- data/lib/plasmoid/generator.rb +116 -0
- data/lib/plasmoid/haml.rb +31 -0
- data/lib/plasmoid/package.rb +44 -0
- data/lib/plasmoid/tasks.rb +45 -0
- data/lib/plasmoid.rb +0 -0
- data/plasmoid.gemspec +76 -0
- data/spec/plasmoid_spec.rb +7 -0
- data/spec/spec_helper.rb +12 -0
- metadata +124 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "jeweler"
|
4
|
+
|
5
|
+
# Add dependencies required to use your gem here.
|
6
|
+
# Example:
|
7
|
+
# gem "activesupport", ">= 2.3.5"
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development do
|
12
|
+
# gem "rspec", "~> 2.1.0"
|
13
|
+
gem "bundler", "~> 1.0.0"
|
14
|
+
# gem "jeweler", "~> 1.5.1"
|
15
|
+
# gem "rcov", ">= 0"
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.5.1)
|
6
|
+
bundler (~> 1.0.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.8.7)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
bundler (~> 1.0.0)
|
16
|
+
jeweler
|
17
|
+
|
18
|
+
METADATA
|
19
|
+
version: 1.0.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 David A. Cuadrado
|
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.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= plasmoid
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to plasmoid
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 David A. Cuadrado. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "plasmoid"
|
16
|
+
gem.homepage = "http://github.com/dcu/plasmoid"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{ruby gem to work with KDE plasmoids}
|
19
|
+
gem.description = %Q{ruby gem to build and work with KDE plasmoids}
|
20
|
+
gem.email = "krawek@gmail.com"
|
21
|
+
gem.authors = ["David A. Cuadrado"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
=begin
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
37
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
38
|
+
spec.rcov = true
|
39
|
+
end
|
40
|
+
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
require 'rake/rdoctask'
|
44
|
+
Rake::RDocTask.new do |rdoc|
|
45
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "plasmoid #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
51
|
+
end
|
52
|
+
=end
|
53
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/plasmoid
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Plasmoid
|
4
|
+
class Generator
|
5
|
+
class Options < Hash
|
6
|
+
attr_reader :parser, :argv
|
7
|
+
|
8
|
+
def initialize(args)
|
9
|
+
super()
|
10
|
+
|
11
|
+
@argv = args.clone
|
12
|
+
@parser = OptionParser.new do |o|
|
13
|
+
o.banner = "Usage: #{File.basename($0)} [options] name\ne.g. #{File.basename($0)} weba"
|
14
|
+
|
15
|
+
o.on('--directory [DIRECTORY]', 'specify the directory to generate into') do |directory|
|
16
|
+
self[:directory] = directory
|
17
|
+
end
|
18
|
+
|
19
|
+
o.separator ""
|
20
|
+
|
21
|
+
o.on('--haml', 'enable haml') do |o|
|
22
|
+
self[:use_haml] = true
|
23
|
+
end
|
24
|
+
|
25
|
+
o.on('--jquery', 'enable jquery') do |o|
|
26
|
+
self[:use_jquery] = true
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on('--jquery-mobile', 'enable jquery mobile') do |o|
|
30
|
+
self[:use_jquery] = true
|
31
|
+
self[:use_jquery_mobile] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
o.on('--jquery-ui', 'enable jquery ui') do |o|
|
35
|
+
self[:use_jquery_ui] = true
|
36
|
+
end
|
37
|
+
|
38
|
+
o.separator ""
|
39
|
+
|
40
|
+
o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
|
41
|
+
self[:summary] = summary
|
42
|
+
end
|
43
|
+
|
44
|
+
o.on('--description [DESCRIPTION]', 'specify a description of the project') do |description|
|
45
|
+
self[:description] = description
|
46
|
+
end
|
47
|
+
|
48
|
+
o.separator ""
|
49
|
+
|
50
|
+
o.on('--user-name [USER_NAME]', "the user's name, ie that is credited in the LICENSE") do |user_name|
|
51
|
+
self[:user_name] = user_name
|
52
|
+
end
|
53
|
+
|
54
|
+
o.on('--user-email [USER_EMAIL]', "the user's email, ie that is credited in the Gem specification") do |user_email|
|
55
|
+
self[:user_email] = user_email
|
56
|
+
end
|
57
|
+
|
58
|
+
o.separator ""
|
59
|
+
|
60
|
+
o.on('--homepage [HOMEPAGE]', "the homepage for your project") do |homepage|
|
61
|
+
self[:homepage] = homepage
|
62
|
+
end
|
63
|
+
|
64
|
+
o.separator ""
|
65
|
+
|
66
|
+
o.on_tail('-h', '--help', 'display this help and exit') do
|
67
|
+
self[:show_help] = true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
@parser.parse!(args)
|
73
|
+
self[:project_name] = args.shift
|
74
|
+
rescue OptionParser::InvalidOption => e
|
75
|
+
self[:invalid_argument] = e.message
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Plasmoid
|
2
|
+
class Generator
|
3
|
+
module TemplateHelper
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def template_dir
|
10
|
+
@template_dir ||= File.join(File.dirname(__FILE__), 'templates')
|
11
|
+
end
|
12
|
+
|
13
|
+
def render_template(source)
|
14
|
+
template_contents = File.read(File.join(template_dir, source))
|
15
|
+
template = ERB.new(template_contents, nil, '<>')
|
16
|
+
|
17
|
+
template.result(binding).gsub(/\n\n\n+/, "\n\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_template(source, destination = source)
|
21
|
+
final_destination = File.join(target_dir, destination)
|
22
|
+
template_result = render_template(source)
|
23
|
+
|
24
|
+
File.open(final_destination, 'w') do |file|
|
25
|
+
file.write(template_result)
|
26
|
+
end
|
27
|
+
|
28
|
+
$stdout.puts ">> create\t#{final_destination}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def mkdir(path)
|
32
|
+
destination = File.join(target_dir, path)
|
33
|
+
FileUtils.mkpath(destination)
|
34
|
+
$stdout.puts ">> mkdir\t#{destination}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
alert("javascript was loaded")
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8' />
|
5
|
+
<title><%= options[:project_name] %></title>
|
6
|
+
|
7
|
+
<% if options[:use_jquery] %>
|
8
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
|
9
|
+
<% end %>
|
10
|
+
<% if options[:use_jquery_ui] %>
|
11
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
12
|
+
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css" />
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if options[:use_jquery_mobile] %>
|
16
|
+
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" />
|
17
|
+
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<script type="text/javascript" src="application.js"></script>
|
21
|
+
<link rel="stylesheet" type="text/css" href="style.css" />
|
22
|
+
</head>
|
23
|
+
<body>
|
24
|
+
<% if !options[:use_jquery_mobile] %>
|
25
|
+
<iframe height='400' src='http://plasma.kde.org/' width='100%'></iframe>
|
26
|
+
<% else %>
|
27
|
+
<div data-role="page" data-theme="b">
|
28
|
+
<div data-role="content">
|
29
|
+
<ul data-role="listview" data-theme="c" data-dividertheme="b">
|
30
|
+
<li data-role="list-divider">Pages</li>
|
31
|
+
<li><a href="page1.html">Page 1</a></li>
|
32
|
+
<li><a href="page2.html">Page 2</a></li>
|
33
|
+
</ul>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
<% end %>
|
37
|
+
</body>
|
38
|
+
</html>
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
[Desktop Entry]
|
2
|
+
Encoding=UTF-8
|
3
|
+
Name=<%= options[:project_name] %>
|
4
|
+
Name[nl]=<%= options[:project_name] %>
|
5
|
+
Type=Service
|
6
|
+
ServiceTypes=Plasma/Applet
|
7
|
+
Icon=chronometer
|
8
|
+
X-Plasma-API=webkit
|
9
|
+
X-Plasma-MainScript=code/main.html
|
10
|
+
X-KDE-PluginInfo-Author=<%= options[:user_name] %>
|
11
|
+
X-KDE-PluginInfo-Email=<%= options[:project_email] %>
|
12
|
+
X-KDE-PluginInfo-Name=<%= options[:project_name] %>
|
13
|
+
X-KDE-PluginInfo-Version=1.0
|
14
|
+
X-KDE-PluginInfo-Website=http://plasma.kde.org/
|
15
|
+
X-KDE-PluginInfo-Category=Web Based
|
16
|
+
X-KDE-PluginInfo-Depends=
|
17
|
+
X-KDE-PluginInfo-License=GPL
|
18
|
+
X-KDE-PluginInfo-EnabledByDefault=true
|
19
|
+
X-Plasma-DefaultSize=600,400
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'pathname'
|
6
|
+
require 'find'
|
7
|
+
|
8
|
+
require 'plasmoid/generator/options'
|
9
|
+
require 'plasmoid/generator/template_helper'
|
10
|
+
|
11
|
+
module Plasmoid
|
12
|
+
class Generator
|
13
|
+
include TemplateHelper
|
14
|
+
|
15
|
+
attr_accessor :target_dir
|
16
|
+
attr_accessor :options
|
17
|
+
attr_accessor :project_name, :summary, :description, :user_name, :user_email, :homepage
|
18
|
+
|
19
|
+
def initialize(options = {})
|
20
|
+
self.options = options
|
21
|
+
|
22
|
+
self.project_name = options[:project_name]
|
23
|
+
if self.project_name.nil? || self.project_name.squeeze.strip == ""
|
24
|
+
raise "no name was given"
|
25
|
+
end
|
26
|
+
|
27
|
+
self.target_dir = options[:directory] || self.project_name
|
28
|
+
|
29
|
+
self.summary = options[:summary] || 'TODO: one-line summary of your plasmoid'
|
30
|
+
self.description = options[:description] || 'TODO: longer description of your plasmoid'
|
31
|
+
|
32
|
+
self.user_name = options[:user_name]
|
33
|
+
self.user_email = options[:user_email]
|
34
|
+
self.homepage = options[:homepage]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.run!(*args)
|
38
|
+
options = Plasmoid::Generator::Options.new(args)
|
39
|
+
|
40
|
+
if options[:invalid_argument]
|
41
|
+
$stderr.puts options[:invalid_argument]
|
42
|
+
options[:show_help] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
if options[:show_help]
|
46
|
+
$stderr.puts options.parser
|
47
|
+
return 1
|
48
|
+
end
|
49
|
+
|
50
|
+
if options[:project_name].nil? || options[:project_name].squeeze.strip == ""
|
51
|
+
$stderr.puts options.parser
|
52
|
+
return 1
|
53
|
+
end
|
54
|
+
|
55
|
+
generator = Plasmoid::Generator.new(options)
|
56
|
+
generator.run
|
57
|
+
return 0
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
create_files
|
62
|
+
create_version_control
|
63
|
+
$stdout.puts "Your plasmoid is ready at #{target_dir}\ntype `rake -T` to see the available actions"
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def create_files
|
68
|
+
puts "Creating files in #{target_dir}"
|
69
|
+
FileUtils.mkpath(target_dir)
|
70
|
+
|
71
|
+
Find.find(template_dir) do |path|
|
72
|
+
dest = path.sub(template_dir, "")
|
73
|
+
|
74
|
+
next if path =~ /^\.+$/ || dest.empty? || path =~ /~$/
|
75
|
+
if File.directory?(path)
|
76
|
+
mkdir(dest)
|
77
|
+
else
|
78
|
+
write_template(dest, dest)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
if options[:use_haml]
|
83
|
+
Dir.chdir(target_dir) do
|
84
|
+
Dir.glob(File.join("contents/**/**/*.html")) do |path|
|
85
|
+
dest = path + ".haml"
|
86
|
+
puts dest
|
87
|
+
system("html2haml '#{path}' '#{dest}'")
|
88
|
+
File.unlink path
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def create_version_control
|
95
|
+
Dir.chdir(target_dir) do
|
96
|
+
begin
|
97
|
+
@repo = Git.init()
|
98
|
+
rescue Git::GitExecuteError => e
|
99
|
+
raise "Encountered an error during gitification. Maybe the repo already exists, or has already been pushed to?"
|
100
|
+
end
|
101
|
+
|
102
|
+
begin
|
103
|
+
@repo.add('.')
|
104
|
+
rescue Git::GitExecuteError => e
|
105
|
+
raise
|
106
|
+
end
|
107
|
+
|
108
|
+
begin
|
109
|
+
@repo.commit "Initial commit to #{project_name}."
|
110
|
+
rescue Git::GitExecuteError => e
|
111
|
+
raise
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'haml'
|
2
|
+
|
3
|
+
module Plasmoid
|
4
|
+
class Haml
|
5
|
+
def initialize(path)
|
6
|
+
@path = path
|
7
|
+
@output_path = path.sub(/\.haml$/, "")
|
8
|
+
|
9
|
+
if valid?
|
10
|
+
::Haml::Engine.new(File.read(@path)).def_method(self, :render)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
15
|
+
defined?(::Haml)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write
|
19
|
+
return if !valid?
|
20
|
+
File.open(@output_path, "w") do |f|
|
21
|
+
f.write(self.render)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.generate
|
26
|
+
Dir["contents/**/**/*.haml"].each do |path|
|
27
|
+
Plasmoid::Haml.new(path).write
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'zip/zipfilesystem'
|
3
|
+
|
4
|
+
module Plasmoid
|
5
|
+
class Package
|
6
|
+
def initialize(filename)
|
7
|
+
@filename = filename
|
8
|
+
@pkg_name = File.basename(@filename, ".zip")
|
9
|
+
end
|
10
|
+
|
11
|
+
def write
|
12
|
+
File.unlink(@filename) if File.exist?(@filename)
|
13
|
+
Zip::ZipFile.open(@filename, Zip::ZipFile::CREATE) do |zf|
|
14
|
+
Find.find(".") do |path|
|
15
|
+
path.sub!(/^\.\//, "")
|
16
|
+
|
17
|
+
if path.empty? || path =~ /^\.+$/ || path =~ /\.(zip|haml)$/ || path == "Rakefile"
|
18
|
+
next
|
19
|
+
end
|
20
|
+
|
21
|
+
if File.directory?(path)
|
22
|
+
zf.dir.mkdir(path)
|
23
|
+
else
|
24
|
+
zf.file.open(path, "w") do |file|
|
25
|
+
file.write(File.read(path))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
system("plasmoidviewer '#{@pkg_name}'")
|
34
|
+
end
|
35
|
+
|
36
|
+
def install
|
37
|
+
system("plasmapkg -i '#{@filename}'")
|
38
|
+
end
|
39
|
+
|
40
|
+
def uninstall
|
41
|
+
system("plasmapkg -r '#{@pkg_name}'")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'plasmoid/haml'
|
3
|
+
|
4
|
+
require 'plasmoid/package'
|
5
|
+
|
6
|
+
task :_init do
|
7
|
+
File.open("metadata.desktop") do |f|
|
8
|
+
f.each_line do |line|
|
9
|
+
if line =~ /X-KDE-PluginInfo-Name=(.+)$/
|
10
|
+
@filename = $1
|
11
|
+
break
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if !@filename
|
16
|
+
raise "X-KDE-PluginInfo-Name was not found in metadata.desktop"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Compile haml files"
|
22
|
+
task :haml => [:_init] do
|
23
|
+
Plasmoid::Haml.generate
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Generate plasmoid package"
|
27
|
+
task :pkg => [:_init, :haml] do
|
28
|
+
Plasmoid::Package.new("#{@filename}.zip").write
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Installs the plasmoid"
|
32
|
+
task :install => [:_init, :pkg] do
|
33
|
+
Plasmoid::Package.new("#{@filename}.zip").install
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "View plasmoid"
|
37
|
+
task :view => [:_init, :install] do
|
38
|
+
Plasmoid::Package.new("#{@filename}.zip").run
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Uninstalls the plasmoid"
|
42
|
+
task :uninstall => [:_init, :pkg] do
|
43
|
+
Plasmoid::Package.new("#{@filename}.zip").uninstall
|
44
|
+
end
|
45
|
+
|
data/lib/plasmoid.rb
ADDED
File without changes
|
data/plasmoid.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{plasmoid}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["David A. Cuadrado"]
|
12
|
+
s.date = %q{2010-11-30}
|
13
|
+
s.default_executable = %q{plasmoid}
|
14
|
+
s.description = %q{ruby gem to build and work with KDE plasmoids}
|
15
|
+
s.email = %q{krawek@gmail.com}
|
16
|
+
s.executables = ["plasmoid"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.rdoc",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"bin/plasmoid",
|
31
|
+
"lib/plasmoid.rb",
|
32
|
+
"lib/plasmoid/errors.rb",
|
33
|
+
"lib/plasmoid/generator.rb",
|
34
|
+
"lib/plasmoid/generator/options.rb",
|
35
|
+
"lib/plasmoid/generator/template_helper.rb",
|
36
|
+
"lib/plasmoid/generator/templates/Rakefile",
|
37
|
+
"lib/plasmoid/generator/templates/contents/code/application.js",
|
38
|
+
"lib/plasmoid/generator/templates/contents/code/main.html",
|
39
|
+
"lib/plasmoid/generator/templates/contents/code/page1.html",
|
40
|
+
"lib/plasmoid/generator/templates/contents/code/page2.html",
|
41
|
+
"lib/plasmoid/generator/templates/contents/code/style.css",
|
42
|
+
"lib/plasmoid/generator/templates/metadata.desktop",
|
43
|
+
"lib/plasmoid/haml.rb",
|
44
|
+
"lib/plasmoid/package.rb",
|
45
|
+
"lib/plasmoid/tasks.rb",
|
46
|
+
"plasmoid.gemspec",
|
47
|
+
"spec/plasmoid_spec.rb",
|
48
|
+
"spec/spec_helper.rb"
|
49
|
+
]
|
50
|
+
s.homepage = %q{http://github.com/dcu/plasmoid}
|
51
|
+
s.licenses = ["MIT"]
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubygems_version = %q{1.3.7}
|
54
|
+
s.summary = %q{ruby gem to work with KDE plasmoids}
|
55
|
+
s.test_files = [
|
56
|
+
"spec/plasmoid_spec.rb",
|
57
|
+
"spec/spec_helper.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::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_runtime_dependency(%q<jeweler>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'plasmoid'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plasmoid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- David A. Cuadrado
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-30 00:00:00 -05:00
|
19
|
+
default_executable: plasmoid
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
requirement: *id001
|
32
|
+
prerelease: false
|
33
|
+
type: :runtime
|
34
|
+
name: jeweler
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 23
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 0
|
46
|
+
version: 1.0.0
|
47
|
+
requirement: *id002
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
name: bundler
|
51
|
+
description: ruby gem to build and work with KDE plasmoids
|
52
|
+
email: krawek@gmail.com
|
53
|
+
executables:
|
54
|
+
- plasmoid
|
55
|
+
extensions: []
|
56
|
+
|
57
|
+
extra_rdoc_files:
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.rdoc
|
60
|
+
files:
|
61
|
+
- .document
|
62
|
+
- .rspec
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.rdoc
|
67
|
+
- Rakefile
|
68
|
+
- VERSION
|
69
|
+
- bin/plasmoid
|
70
|
+
- lib/plasmoid.rb
|
71
|
+
- lib/plasmoid/errors.rb
|
72
|
+
- lib/plasmoid/generator.rb
|
73
|
+
- lib/plasmoid/generator/options.rb
|
74
|
+
- lib/plasmoid/generator/template_helper.rb
|
75
|
+
- lib/plasmoid/generator/templates/Rakefile
|
76
|
+
- lib/plasmoid/generator/templates/contents/code/application.js
|
77
|
+
- lib/plasmoid/generator/templates/contents/code/main.html
|
78
|
+
- lib/plasmoid/generator/templates/contents/code/page1.html
|
79
|
+
- lib/plasmoid/generator/templates/contents/code/page2.html
|
80
|
+
- lib/plasmoid/generator/templates/contents/code/style.css
|
81
|
+
- lib/plasmoid/generator/templates/metadata.desktop
|
82
|
+
- lib/plasmoid/haml.rb
|
83
|
+
- lib/plasmoid/package.rb
|
84
|
+
- lib/plasmoid/tasks.rb
|
85
|
+
- plasmoid.gemspec
|
86
|
+
- spec/plasmoid_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://github.com/dcu/plasmoid
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 1.3.7
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: ruby gem to work with KDE plasmoids
|
122
|
+
test_files:
|
123
|
+
- spec/plasmoid_spec.rb
|
124
|
+
- spec/spec_helper.rb
|