ofxbundler 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/OfxFile +4 -0
- data/README.md +20 -0
- data/Rakefile +2 -0
- data/bin/ofxbundle +52 -0
- data/lib/ofxbundler/dsl.rb +99 -0
- data/lib/ofxbundler/version.rb +3 -0
- data/lib/ofxbundler.rb +6 -0
- data/ofxbundler.gemspec +20 -0
- metadata +78 -0
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Meng-Yang Lee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/OfxFile
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# OfxBundler
|
2
|
+
|
3
|
+
OfBundler help you to manager your ofx addons and version
|
4
|
+
|
5
|
+
inspired by vundle and bundler
|
6
|
+
|
7
|
+
## pre-install
|
8
|
+
|
9
|
+
git,
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
edit the OfxFile
|
14
|
+
|
15
|
+
bundle "armadillu/ofxAnimatable" will download this repo to ofx
|
16
|
+
|
17
|
+
|
18
|
+
or
|
19
|
+
|
20
|
+
ofxbundle -s searhTerm # this will return possible addons
|
data/Rakefile
ADDED
data/bin/ofxbundle
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'faraday'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'ofxbundler'
|
6
|
+
options={}
|
7
|
+
|
8
|
+
def colorize(text, color_code)
|
9
|
+
"\e[#{color_code}m#{text}\e[0m"
|
10
|
+
end
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: example.rb [options]"
|
13
|
+
opts.on("-l","list current openframeworks version") do |v|
|
14
|
+
response = Faraday.get do |req|
|
15
|
+
req.url "http://www.openframeworks.cc/download/"
|
16
|
+
end
|
17
|
+
doc = Nokogiri::HTML(response.body)
|
18
|
+
version = doc.css("#download-latest-header h2")
|
19
|
+
puts "Openframeworks current version is "+ version.text
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("install","install by bundler file") do |v|
|
23
|
+
#find bundler.file
|
24
|
+
OfxBundler::Dsl.evalute("OfxFile")
|
25
|
+
end
|
26
|
+
opts.on("-s w","--search w","search the addons") do |w|
|
27
|
+
response = Faraday.get do |req|
|
28
|
+
req.url "http://ofxaddons.com/"
|
29
|
+
end
|
30
|
+
doc = Nokogiri::HTML(response.body)
|
31
|
+
doc.css("div.repo").each do |repo|
|
32
|
+
is_found=false;
|
33
|
+
repo_name=''
|
34
|
+
repo.css("p.name a").each do |item|
|
35
|
+
text = item.text()
|
36
|
+
if text.downcase.include?(w.downcase)
|
37
|
+
is_found=true
|
38
|
+
repo_name=text
|
39
|
+
end
|
40
|
+
end
|
41
|
+
if is_found
|
42
|
+
repo_author = repo.css("p.author").first.text()
|
43
|
+
puts " "+colorize(repo_name,31)+" - #{repo_author}"
|
44
|
+
repo_desc = repo.css("p.description em").first.text()
|
45
|
+
repo_desc.gsub!(/\[view on Github\]/,'')
|
46
|
+
github_link = (repo.css("p.description em a.github_link").first)["href"]
|
47
|
+
puts " "+colorize(repo_desc,32)
|
48
|
+
puts " github:"+github_link
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end.parse!
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'net/http'
|
4
|
+
require 'zip/zip'
|
5
|
+
module OfxBundler
|
6
|
+
class Dsl
|
7
|
+
@@download_href={
|
8
|
+
:osx=>{
|
9
|
+
"007"=>"http://www.openframeworks.cc/versions/preRelease_v0.07/of_preRelease_v007_osx.zip",
|
10
|
+
"filename"=>'of_preRelease_v007_osx.zip"',
|
11
|
+
"dirname"=>'of_preRelease_v007_osx'
|
12
|
+
}
|
13
|
+
|
14
|
+
}
|
15
|
+
def initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.evalute(filename)
|
19
|
+
begin
|
20
|
+
bundler = new
|
21
|
+
bundler.eval_ofxfile(filename)
|
22
|
+
rescue
|
23
|
+
"OfxFile error"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def eval_ofxfile(filename)
|
28
|
+
instance_eval(File.read(filename))
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_config
|
32
|
+
config=nil
|
33
|
+
if RUBY_PLATFORM.downcase.include?("darwin")
|
34
|
+
config= @@download_href[:osx]
|
35
|
+
elsif RUBY_PLATFORM.downcase.include?("mswin")
|
36
|
+
elsif RUBY_PLATFORM.downcase.include?("linux")
|
37
|
+
end
|
38
|
+
config
|
39
|
+
end
|
40
|
+
|
41
|
+
#install latest version
|
42
|
+
def ofx(version="latest")
|
43
|
+
response = Faraday.get do |req|
|
44
|
+
req.url "http://www.openframeworks.cc/download/"
|
45
|
+
end
|
46
|
+
doc = Nokogiri::HTML(response.body)
|
47
|
+
version = doc.css("#download-latest-header h2")
|
48
|
+
puts "Openframeworks current version is "+ version.text+"\n"
|
49
|
+
puts "your os is "+RUBY_PLATFORM.downcase
|
50
|
+
href=""
|
51
|
+
if RUBY_PLATFORM.downcase.include?("darwin")
|
52
|
+
href = @@download_href[:osx]["007"]
|
53
|
+
elsif RUBY_PLATFORM.downcase.include?("mswin")
|
54
|
+
elsif RUBY_PLATFORM.downcase.include?("linux")
|
55
|
+
end
|
56
|
+
|
57
|
+
if href!=""
|
58
|
+
p "downing "+href
|
59
|
+
uri = URI(href)
|
60
|
+
Net::HTTP.start(uri.host,uri.port) do |http|
|
61
|
+
request = Net::HTTP::Get.new uri.request_uri
|
62
|
+
|
63
|
+
http.request request do |response|
|
64
|
+
open 'ofx.zip', 'w' do |io|
|
65
|
+
response.read_body do |chunk|
|
66
|
+
io.write chunk
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
destination="."
|
73
|
+
Zip::ZipFile.open("ofx.zip") {|file|
|
74
|
+
|
75
|
+
file.each do |f|
|
76
|
+
f_path = File.join(destination, f.name)
|
77
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
78
|
+
file.extract(f,f_path)
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def addon name
|
88
|
+
config = get_config
|
89
|
+
addon_author,addon_name = name.split("/")
|
90
|
+
if Dir.exists?("#{config["dirname"]}/addons/#{addon_name}")
|
91
|
+
puts "update #{name}"
|
92
|
+
`cd #{config["dirname"]}/addons/#{addon_name} && git pull`
|
93
|
+
else
|
94
|
+
puts "clone #{name}"
|
95
|
+
`cd #{config["dirname"]}/addons && git clone https://github.com/#{name}.git`
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/ofxbundler.rb
ADDED
data/ofxbundler.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/ofxbundler/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["crazylion"]
|
6
|
+
gem.email = ["crazylion2@gmail.com"]
|
7
|
+
gem.description = %q{help user to manager their openframes addons }
|
8
|
+
gem.summary = %q{help user to manager their openframes addons }
|
9
|
+
gem.homepage = "https://github.com/crazylion/ofxbundler"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "ofxbundler"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Ofxbundler::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'fadary'
|
19
|
+
gem.add_development_dependency 'nokogiri'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ofxbundler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- crazylion
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fadary
|
16
|
+
requirement: &70186037407480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70186037407480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &70186037407060 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70186037407060
|
36
|
+
description: ! 'help user to manager their openframes addons '
|
37
|
+
email:
|
38
|
+
- crazylion2@gmail.com
|
39
|
+
executables:
|
40
|
+
- ofxbundle
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- Gemfile
|
45
|
+
- LICENSE
|
46
|
+
- OfxFile
|
47
|
+
- README.md
|
48
|
+
- Rakefile
|
49
|
+
- bin/ofxbundle
|
50
|
+
- lib/ofxbundler.rb
|
51
|
+
- lib/ofxbundler/dsl.rb
|
52
|
+
- lib/ofxbundler/version.rb
|
53
|
+
- ofxbundler.gemspec
|
54
|
+
homepage: https://github.com/crazylion/ofxbundler
|
55
|
+
licenses: []
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.8.15
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: help user to manager their openframes addons
|
78
|
+
test_files: []
|