Class: OfxBundler::Dsl
- Inherits:
-
Object
- Object
- OfxBundler::Dsl
- Defined in:
- lib/ofxbundler/dsl.rb
Constant Summary collapse
- @@latest_version =
"007"
- @@configs =
{ :osx=>{ "007"=> { "file"=>"http://www.openframeworks.cc/versions/preRelease_v0.07/of_preRelease_v007_osx.zip", "filename"=>'of_preRelease_v007_osx.zip"', "dirname"=>'of_preRelease_v007_osx' } }, :linux=>{ "007" =>{ "file"=> "http://www.openframeworks.cc/versions/preRelease_v0.07/of_preRelease_v007_linux.tar.gz", "filename"=>"of_preRelease_v007_linux.tar.gz", "dirname" => "of_preRelease_v007_linux" }, "007_64" => { "file"=> "http://www.openframeworks.cc/versions/preRelease_v0.07/of_preRelease_v007_linux64.tar.gz", "filename" => "of_preRelease_v007_linux64.tar.gz", "dirname"=> "of_preRelease_v007_linux64" } } }
Instance Attribute Summary collapse
-
#_version ⇒ Object
Returns the value of attribute _version.
Class Method Summary collapse
Instance Method Summary collapse
-
#addon(name, version = @@latest_version) ⇒ Object
install or update the addon.
- #eval_ofxfile(filename) ⇒ Object
- #get_config(version) ⇒ Object
-
#initialize ⇒ Dsl
constructor
A new instance of Dsl.
-
#ofx(version = @@latest_version) ⇒ Object
install latest version.
Constructor Details
#initialize ⇒ Dsl
Returns a new instance of Dsl.
37 38 39 |
# File 'lib/ofxbundler/dsl.rb', line 37 def initialize self._version = @@latest_version end |
Instance Attribute Details
#_version ⇒ Object
Returns the value of attribute _version.
7 8 9 |
# File 'lib/ofxbundler/dsl.rb', line 7 def _version @_version end |
Class Method Details
.evalute(filename) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/ofxbundler/dsl.rb', line 41 def self.evalute(filename) begin bundler = new bundler.eval_ofxfile(filename) rescue =>e p "OfxFile error" p e. end end |
Instance Method Details
#addon(name, version = @@latest_version) ⇒ Object
install or update the addon
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ofxbundler/dsl.rb', line 125 def addon name,version=@@latest_version config = get_config(self._version) ,addon_name = name.split("/") if File.exists?("#{config["dirname"]}/addons/#{addon_name}") puts "update #{name}" `cd #{config["dirname"]}/addons/#{addon_name} && git pull` else puts "clone #{name}" `cd #{config["dirname"]}/addons && git clone https://github.com/#{name}.git` end end |
#eval_ofxfile(filename) ⇒ Object
51 52 53 |
# File 'lib/ofxbundler/dsl.rb', line 51 def eval_ofxfile(filename) instance_eval(File.read(filename)) end |
#get_config(version) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ofxbundler/dsl.rb', line 55 def get_config version config=nil if RUBY_PLATFORM.downcase.include?("darwin") config= @@configs[:osx][version] elsif RUBY_PLATFORM.downcase.include?("mswin") elsif RUBY_PLATFORM.downcase.include?("linux") config= @@configs[:linux][version] end config end |
#ofx(version = @@latest_version) ⇒ Object
install latest version
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/ofxbundler/dsl.rb', line 67 def ofx version=@@latest_version self._version=version response = Faraday.get do |req| req.url "http://www.openframeworks.cc/download/" end doc = Nokogiri::HTML(response.body) latest_version = doc.css("#download-latest-header h2") puts "Openframeworks current version is "+ latest_version.text+"\n" puts "your os is "+RUBY_PLATFORM.downcase config = get_config(version) href=config["file"] if href and href!="" p "downing "+href uri = URI(href) Net::HTTP.start(uri.host,uri.port) do |http| request = Net::HTTP::Get.new uri.request_uri http.request request do |response| open config["filename"], 'w' do |io| response.read_body do |chunk| io.write chunk end end end end if File.exists?(config["dirname"]) puts "openframewors dir #{config['dirname']} exists. pass.." else if RUBY_PLATFORM.downcase.include?("darwin") puts "unzip dir.." destination="." Zip::ZipFile.open(config["filename"]) {|file| file.each do |f| f_path = File.join(destination, f.name) FileUtils.mkdir_p(File.dirname(f_path)) file.extract(f,f_path) end } #cleanup p "cleanup..." `rm -rf __MACOSX` `rm -rf ofx.zip` elsif RUBY_PLATFORM.downcase.include?("linux") p "tar file... #{config['filename']}" `tar vzxf #{config["filename"]}` end end end end |