hotchpotch-chrome-extension-starter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog ADDED
@@ -0,0 +1,2 @@
1
+
2
+
data/README.rdoc ADDED
@@ -0,0 +1,32 @@
1
+
2
+ = chrome-extension-starter
3
+
4
+
5
+ == Description
6
+
7
+ == Installation
8
+
9
+ === Archive Installation
10
+
11
+ rake install
12
+
13
+ === Gem Installation
14
+
15
+ gem sources -a http://gems.github.com
16
+ gem install zipruby json Constellation-crxmake Constellation-jsonschema uuidtools
17
+ gem install hotchpotch-chrome-extension-starter
18
+
19
+ == Features/Problems
20
+
21
+
22
+ == Synopsis
23
+
24
+ chrome-extension-starter myextension
25
+ cd myextension
26
+ rake
27
+
28
+ == Copyright
29
+
30
+ Author:: hotchpotch <hotchpotch@gmail.com>
31
+ Copyright:: Copyright (c) 2009 hotchpotch
32
+ License:: MIT License
data/Rakefile ADDED
@@ -0,0 +1,144 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'rake/contrib/sshpublisher'
10
+ require 'fileutils'
11
+ include FileUtils
12
+
13
+ NAME = "chrome-extension-starter"
14
+ AUTHOR = "hotchpotch"
15
+ EMAIL = "hotchpotch@gmail.com"
16
+ DESCRIPTION = ""
17
+ RUBYFORGE_PROJECT = "chromeextensionstarter"
18
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
19
+ BIN_FILES = %w( chrome-extension-starter )
20
+ VERS = "0.0.2"
21
+
22
+ REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
23
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
24
+ RDOC_OPTS = [
25
+ '--title', "#{NAME} documentation",
26
+ "--charset", "utf-8",
27
+ "--opname", "index.html",
28
+ "--line-numbers",
29
+ "--main", "README.rdoc",
30
+ "--inline-source",
31
+ ]
32
+
33
+ task :default => [:test]
34
+ task :package => [:clean]
35
+
36
+ Rake::TestTask.new("test") do |t|
37
+ t.libs << "test"
38
+ t.pattern = "test/**/*_test.rb"
39
+ t.verbose = true
40
+ end
41
+
42
+ spec = Gem::Specification.new do |s|
43
+ s.name = NAME
44
+ s.version = VERS
45
+ s.platform = Gem::Platform::RUBY
46
+ s.has_rdoc = true
47
+ s.extra_rdoc_files = ["README.rdoc", "ChangeLog"]
48
+ s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
49
+ s.summary = DESCRIPTION
50
+ s.description = DESCRIPTION
51
+ s.author = AUTHOR
52
+ s.email = EMAIL
53
+ s.homepage = HOMEPATH
54
+ s.executables = BIN_FILES
55
+ s.rubyforge_project = RUBYFORGE_PROJECT
56
+ s.bindir = "bin"
57
+ s.require_path = "lib"
58
+ s.autorequire = ""
59
+ s.test_files = Dir["test/*_test.rb"]
60
+
61
+ s.add_dependency('rake')
62
+ s.add_dependency('json')
63
+ #s.add_dependency('jsonschema')
64
+ #s.add_dependency('crxmake')
65
+ s.add_dependency('zipruby')
66
+ s.add_dependency('uuidtools', '>= 2.0.0')
67
+ #s.add_dependency('activesupport', '>=1.3.1')
68
+ #s.required_ruby_version = '>= 1.8.2'
69
+
70
+ s.files = %w(README.rdoc ChangeLog Rakefile) +
71
+ Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
72
+ Dir.glob("ext/**/*.{h,c,rb}") +
73
+ Dir.glob("examples/**/*.rb") +
74
+ Dir.glob("tools/*.rb")
75
+
76
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
77
+ end
78
+
79
+ Rake::GemPackageTask.new(spec) do |p|
80
+ p.need_tar = true
81
+ p.gem_spec = spec
82
+ end
83
+
84
+ task :install do
85
+ name = "#{NAME}-#{VERS}.gem"
86
+ sh %{rake package}
87
+ sh %{sudo gem install pkg/#{name}}
88
+ end
89
+
90
+ task :uninstall => [:clean] do
91
+ sh %{sudo gem uninstall #{NAME}}
92
+ end
93
+
94
+
95
+ Rake::RDocTask.new do |rdoc|
96
+ rdoc.rdoc_dir = 'html'
97
+ rdoc.options += RDOC_OPTS
98
+ rdoc.template = "resh"
99
+ #rdoc.template = "#{ENV['template']}.rb" if ENV['template']
100
+ if ENV['DOC_FILES']
101
+ rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
102
+ else
103
+ rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
104
+ #rdoc.rdoc_files.include('lib/**/*.rb')
105
+ rdoc.rdoc_files.include('lib/*.rb')
106
+ #rdoc.rdoc_files.include('ext/**/*.c')
107
+ end
108
+ end
109
+
110
+ desc "Publish to RubyForge"
111
+ task :rubyforge => [:rdoc, :package] do
112
+ require 'rubyforge'
113
+ Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, 'gorou').upload
114
+ end
115
+
116
+ desc 'Package and upload the release to rubyforge.'
117
+ task :release => [:clean, :package] do |t|
118
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
119
+ abort "Versions don't match #{v} vs #{VERS}" unless v == VERS
120
+ pkg = "pkg/#{NAME}-#{VERS}"
121
+
122
+ require 'rubyforge'
123
+ rf = RubyForge.new
124
+ puts "Logging in"
125
+ rf.login
126
+
127
+ c = rf.userconfig
128
+ # c["release_notes"] = description if description
129
+ # c["release_changes"] = changes if changes
130
+ c["preformatted"] = true
131
+
132
+ files = [
133
+ "#{pkg}.tgz",
134
+ "#{pkg}.gem"
135
+ ].compact
136
+
137
+ puts "Releasing #{NAME} v. #{VERS}"
138
+ rf.add_release RUBYFORGE_PROJECT, NAME, VERS, *files
139
+ end
140
+
141
+ desc 'Show information about the gem.'
142
+ task :debug_gem do
143
+ puts spec.to_ruby
144
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'chrome_extension_starter'
5
+
6
+ ChromeExtensionStarter.new(ARGV).run
@@ -0,0 +1,44 @@
1
+
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ require 'erb'
5
+ require 'rubygems'
6
+ require 'uuidtools'
7
+
8
+ class ChromeExtensionStarter
9
+ def initialize(argv)
10
+ @target_name = argv.first
11
+ @uuid = UUIDTools::UUID.random_create.to_s.gsub('-', '')
12
+ if !@target_name
13
+ warn "usage: chrome-extension-starter myextension"
14
+ exit 1
15
+ end
16
+ @path = Pathname.new Dir.pwd
17
+ @root_path = Pathname.new(__FILE__).parent.parent
18
+ end
19
+
20
+ def run
21
+ target_path = @path.join(@target_name)
22
+ if target_path.exist?
23
+ warn "#{@target_name} is already exist."
24
+ exit 1
25
+ end
26
+
27
+ generate_templates(target_path, @root_path.join('templates'))
28
+ end
29
+
30
+ def generate_templates(target_path, template_path)
31
+ FileUtils.cp_r template_path.to_s, target_path.to_s
32
+ Pathname.glob(target_path.to_s + "**/**/*") do |f|
33
+ next unless f.file?
34
+ f.open("r+") do |f|
35
+ target_name = @target_name
36
+ uuid = @uuid
37
+ content = f.read
38
+ f.rewind
39
+ f.puts ERB.new(content).result(binding)
40
+ f.truncate f.tell
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,61 @@
1
+
2
+ require 'rubygems'
3
+ require 'json/pure'
4
+ require 'rake'
5
+ require 'pathname'
6
+ require 'crxmake'
7
+ require 'open-uri'
8
+
9
+ project_name = '<%= target_name %>'
10
+
11
+ github_account = 'youracountname' # `git config github.user`.chomp
12
+ github_project = '<%= target_name %>'
13
+ extension_url = "http://cloud.github.com/downloads/#{github_account}/#{github_project}/#{project_name}.crx"
14
+
15
+ root_path = Pathname.new(__FILE__).parent
16
+ src_path = root_path.join('src')
17
+ manifest_path = src_path.join('manifest.json')
18
+ update_path = src_path.join('update.xml')
19
+ output_path = root_path.join('bin')
20
+ pem_file = ENV['PEM'] || root_path.join(project_name + '.pem')
21
+
22
+ task :release => [:update_xml, :package]
23
+ task :default => [:release]
24
+
25
+ namespace :manifest do
26
+ desc "json schema check"
27
+ task :check do
28
+ require 'jsonschema'
29
+ data = JSON.parse manifest_path.read
30
+ schema = JSON.parse open('http://gist.github.com/179669.txt').read # manifest.json schema by os0x
31
+ puts "JSON schema check."
32
+ begin
33
+ JSON::Schema.validate(data, schema)
34
+ puts "JSON schema valid."
35
+ rescue JSON::Schema::ValueError => e
36
+ puts "JSON schema invalid!"
37
+ puts e.to_s
38
+ end
39
+ end
40
+ end
41
+
42
+ task :package do
43
+ output_path.mkpath unless output_path.directory?
44
+ crx = output_path.join("#{project_name}.crx").to_s
45
+ options = {
46
+ :ex_dir => src_path.to_s,
47
+ :crx_output => crx,
48
+ # :verbose => true,
49
+ :ignorefile => /\.sw[op]/,
50
+ :ignoredir => /\.(?:svn|git|cvs)/
51
+ }
52
+ if pem_file && Pathname.new(pem_file.to_s).exist?
53
+ options[:pkey] = pem_file.to_s
54
+ else
55
+ options[:pkey_output] = pem_file.to_s
56
+ end
57
+ CrxMake.make(options)
58
+ puts "generated package: #{crx}"
59
+ puts "generated pkem(.pem): #{options[:pkey_output]}" if options[:pkey_output]
60
+ end
61
+
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <script type="text/javascript" src="../lib/utils.js"></script>
6
+ <script type="text/javascript" src="background.js"></script>
7
+ </head>
8
+ <body></body>
9
+ </html>
@@ -0,0 +1,2 @@
1
+
2
+ console.log('call first time only');
@@ -0,0 +1,2 @@
1
+
2
+ // utility
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "<%= target_name %>",
3
+ "id": "<%= uuid %>",
4
+ "description": "my extention",
5
+ "version": "0.0.1",
6
+ "update_url": "http://localhost/example/update.xml",
7
+ "permissions": [
8
+ "http://*/",
9
+ "https://*/",
10
+ "tabs"
11
+ ],
12
+ "background_page": "background/background.html",
13
+ "toolstrips": [
14
+ "toolstrips/toolstrip.html"
15
+ ]
16
+ // "content_scripts": [
17
+ // {
18
+ // "run_at": "document_start",
19
+ // "js": [
20
+ // "content/main.js"
21
+ // ],
22
+ // "css": [
23
+ // "content/main.css"
24
+ // ],
25
+ // "matches": [
26
+ // "http://*/*",
27
+ // "https://*/*",
28
+ // "file://*"
29
+ // ]
30
+ // }
31
+ // ],
32
+ // "page_actions": [
33
+ // {
34
+ // "id": "<%= target_name %>_page_action",
35
+ // "name": "<%= target_name %>_page_action",
36
+ // "icons": ["images/icon.png"]
37
+ // }
38
+ // ]
39
+ }
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <script type="text/javascript" src="../lib/utils.js"></script>
6
+ <script type="text/javascript" src="toolstrip.js"></script>
7
+ </head>
8
+ <body>
9
+ <div class="toolstrip-button">
10
+ <span>Hello World!</span>
11
+ </div>
12
+ </body>
13
+ </html>
@@ -0,0 +1,2 @@
1
+
2
+
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ require "test/unit"
4
+ class ChromeExtensionStarterTest < Test::Unit::TestCase
5
+ def test_new
6
+ assert ChromeExtensionStarter.new('a')
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/chrome_extension_starter'
3
+
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hotchpotch-chrome-extension-starter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - hotchpotch
8
+ autorequire: ""
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-24 00:00:00 -07:00
13
+ default_executable: chrome-extension-starter
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: zipruby
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: uuidtools
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.0.0
54
+ version:
55
+ description: ""
56
+ email: hotchpotch@gmail.com
57
+ executables:
58
+ - chrome-extension-starter
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - README.rdoc
63
+ - ChangeLog
64
+ files:
65
+ - README.rdoc
66
+ - ChangeLog
67
+ - Rakefile
68
+ - bin/chrome-extension-starter
69
+ - test/chrome-extension-starter_test.rb
70
+ - test/test_helper.rb
71
+ - lib/chrome_extension_starter.rb
72
+ - templates/src
73
+ - templates/src/lib
74
+ - templates/src/lib/utils.js
75
+ - templates/src/toolstrips
76
+ - templates/src/toolstrips/toolstrip.html
77
+ - templates/src/toolstrips/toolstrip.js
78
+ - templates/src/background
79
+ - templates/src/background/background.html
80
+ - templates/src/background/background.js
81
+ - templates/src/manifest.json
82
+ - templates/Rakefile
83
+ has_rdoc: false
84
+ homepage: http://chromeextensionstarter.rubyforge.org
85
+ licenses:
86
+ post_install_message:
87
+ rdoc_options:
88
+ - --title
89
+ - chrome-extension-starter documentation
90
+ - --charset
91
+ - utf-8
92
+ - --opname
93
+ - index.html
94
+ - --line-numbers
95
+ - --main
96
+ - README.rdoc
97
+ - --inline-source
98
+ - --exclude
99
+ - ^(examples|extras)/
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: "0"
107
+ version:
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ version:
114
+ requirements: []
115
+
116
+ rubyforge_project: chromeextensionstarter
117
+ rubygems_version: 1.3.5
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: ""
121
+ test_files:
122
+ - test/chrome-extension-starter_test.rb