fluxapi 0.5.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +5 -4
- data/Rakefile +2 -2
- data/fluxapi.gemspec +8 -8
- data/lib/fluxapi/asset.rb +10 -3
- data/lib/fluxapi/base.rb +11 -3
- data/lib/fluxapi/tag.rb +4 -1
- data/lib/fluxapi/tags.rb +6 -3
- data/test/fluxapi/asset_test.rb +6 -0
- data/test/test_helper.rb +3 -2
- metadata +10 -10
data/Manifest
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
History.txt
|
2
|
+
Manifest
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
fluxapi.gemspec
|
6
|
+
lib/fluxapi.rb
|
2
7
|
lib/fluxapi/account.rb
|
3
8
|
lib/fluxapi/asset.rb
|
4
9
|
lib/fluxapi/assets.rb
|
@@ -7,10 +12,6 @@ lib/fluxapi/tag.rb
|
|
7
12
|
lib/fluxapi/tags.rb
|
8
13
|
lib/fluxapi/user.rb
|
9
14
|
lib/fluxapi/users.rb
|
10
|
-
lib/fluxapi.rb
|
11
|
-
Manifest
|
12
|
-
Rakefile
|
13
|
-
README.txt
|
14
15
|
test/fixtures/account.xml
|
15
16
|
test/fixtures/assets.xml
|
16
17
|
test/fixtures/download_response
|
data/Rakefile
CHANGED
@@ -3,11 +3,11 @@ require 'rake'
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('fluxapi', '0.
|
6
|
+
Echoe.new('fluxapi', '0.6') do |p|
|
7
7
|
p.description = "A fluxiom api wrapper for ruby"
|
8
8
|
p.url = "http://fluxapi.rubyforge.org"
|
9
9
|
p.author = "Sebastian Gräßl"
|
10
10
|
p.email = "sebastian.graessl@gmail.com"
|
11
11
|
p.project = "fluxapi"
|
12
|
-
p.runtime_dependencies = ["httparty >= 0.
|
12
|
+
p.runtime_dependencies = ["httparty >= 0.5.0"]
|
13
13
|
end
|
data/fluxapi.gemspec
CHANGED
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fluxapi}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sebastian Gr\303\244\303\237l"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2010-01-14}
|
10
10
|
s.description = %q{A fluxiom api wrapper for ruby}
|
11
11
|
s.email = %q{sebastian.graessl@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["lib/fluxapi/account.rb", "lib/fluxapi/asset.rb", "lib/fluxapi/assets.rb", "lib/fluxapi/base.rb", "lib/fluxapi/tag.rb", "lib/fluxapi/tags.rb", "lib/fluxapi/user.rb", "lib/fluxapi/users.rb"
|
13
|
-
s.files = ["History.txt", "lib/fluxapi/account.rb", "lib/fluxapi/asset.rb", "lib/fluxapi/assets.rb", "lib/fluxapi/base.rb", "lib/fluxapi/tag.rb", "lib/fluxapi/tags.rb", "lib/fluxapi/user.rb", "lib/fluxapi/users.rb", "
|
12
|
+
s.extra_rdoc_files = ["README.txt", "lib/fluxapi.rb", "lib/fluxapi/account.rb", "lib/fluxapi/asset.rb", "lib/fluxapi/assets.rb", "lib/fluxapi/base.rb", "lib/fluxapi/tag.rb", "lib/fluxapi/tags.rb", "lib/fluxapi/user.rb", "lib/fluxapi/users.rb"]
|
13
|
+
s.files = ["History.txt", "Manifest", "README.txt", "Rakefile", "lib/fluxapi.rb", "lib/fluxapi/account.rb", "lib/fluxapi/asset.rb", "lib/fluxapi/assets.rb", "lib/fluxapi/base.rb", "lib/fluxapi/tag.rb", "lib/fluxapi/tags.rb", "lib/fluxapi/user.rb", "lib/fluxapi/users.rb", "test/fixtures/account.xml", "test/fixtures/assets.xml", "test/fixtures/download_response", "test/fixtures/tags.xml", "test/fixtures/users.xml", "test/fluxapi/account_test.rb", "test/fluxapi/asset_test.rb", "test/fluxapi/assets_test.rb", "test/fluxapi_test.rb", "test/test_helper.rb", "fluxapi.gemspec"]
|
14
14
|
s.homepage = %q{http://fluxapi.rubyforge.org}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fluxapi", "--main", "README.txt"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{fluxapi}
|
18
|
-
s.rubygems_version = %q{1.3.
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
19
|
s.summary = %q{A fluxiom api wrapper for ruby}
|
20
20
|
s.test_files = ["test/fluxapi/account_test.rb", "test/fluxapi/asset_test.rb", "test/fluxapi/assets_test.rb", "test/fluxapi_test.rb", "test/test_helper.rb"]
|
21
21
|
|
@@ -24,11 +24,11 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.specification_version = 3
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<httparty>, [">= 0", "= 0.
|
27
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
|
28
28
|
else
|
29
|
-
s.add_dependency(%q<httparty>, [">= 0", "= 0.
|
29
|
+
s.add_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
|
30
30
|
end
|
31
31
|
else
|
32
|
-
s.add_dependency(%q<httparty>, [">= 0", "= 0.
|
32
|
+
s.add_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
|
33
33
|
end
|
34
34
|
end
|
data/lib/fluxapi/asset.rb
CHANGED
@@ -3,14 +3,21 @@ class Fluxiom::Asset < Fluxiom
|
|
3
3
|
data.each do |k, v|
|
4
4
|
self.instance_variable_set("@#{k}", v)
|
5
5
|
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")})
|
6
|
+
self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)})
|
6
7
|
end
|
7
8
|
end
|
9
|
+
|
10
|
+
def tag(t)
|
11
|
+
res = self.class.post_call("/api/assets/#{self.id}/tag", :body => {:tags => t.api_name})
|
12
|
+
self.tags = self.tags.to_s + ' ' + t.api_name
|
13
|
+
end
|
14
|
+
|
8
15
|
def download(path_to_file)
|
9
|
-
session = Net::HTTP.new(
|
16
|
+
session = Net::HTTP.new(@@base_url.gsub('https://', ''), 443)
|
10
17
|
session.use_ssl = true
|
11
18
|
session.start {|http|
|
12
|
-
req = Net::HTTP::Get.new("/api/assets
|
13
|
-
req.basic_auth
|
19
|
+
req = Net::HTTP::Get.new("/api/assets/#{self.id}/download")
|
20
|
+
req.basic_auth @@user, @@password
|
14
21
|
resp = http.request(req)
|
15
22
|
open(File.join(path_to_file, self.filename), 'wb') do |file|
|
16
23
|
file.write(resp.body)
|
data/lib/fluxapi/base.rb
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
class Fluxiom
|
2
2
|
include HTTParty
|
3
3
|
format :xml
|
4
|
+
attr_accessor :base_url
|
4
5
|
def initialize(sub, u, p)
|
5
|
-
|
6
|
-
|
6
|
+
@@base_url = 'https://'+ sub + '.fluxiom.com'
|
7
|
+
@@user, @@password = u, p
|
7
8
|
end
|
8
9
|
def self.call(url)
|
9
|
-
|
10
|
+
base_uri @@base_url
|
11
|
+
basic_auth @@user, @@password
|
12
|
+
get(@@base_url + url)
|
13
|
+
end
|
14
|
+
def self.post_call(url, post_data)
|
15
|
+
base_uri @@base_url
|
16
|
+
basic_auth @@user, @@password
|
17
|
+
post(@@base_url + url, post_data)
|
10
18
|
end
|
11
19
|
def account
|
12
20
|
Fluxiom::Account.new
|
data/lib/fluxapi/tag.rb
CHANGED
data/lib/fluxapi/tags.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
class Fluxiom::Tags < Fluxiom
|
2
2
|
include Enumerable
|
3
3
|
def initialize
|
4
|
-
@
|
4
|
+
@tags = []
|
5
5
|
self.class.call('/api/tags.xml')['tags'].each do |v|
|
6
|
-
@
|
6
|
+
@tags << Fluxiom::Tag.new(v)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
def each
|
10
|
-
@
|
10
|
+
@tags.each {|pt| yield pt}
|
11
|
+
end
|
12
|
+
def first
|
13
|
+
@tags.first
|
11
14
|
end
|
12
15
|
end
|
data/test/fluxapi/asset_test.rb
CHANGED
@@ -14,6 +14,12 @@ class Fluxiom::AssetTest < Test::Unit::TestCase
|
|
14
14
|
assert File.exists?(File.join(@tmp_dir, @asset.filename))
|
15
15
|
end
|
16
16
|
|
17
|
+
def test_tagging
|
18
|
+
prev_size = !@asset.tags.nil? ? @asset.tags.split(' ').length : 0
|
19
|
+
@asset.tag(@fluxiom.tags.first)
|
20
|
+
assert_equal prev_size+1, @asset.tags.split(' ').length
|
21
|
+
end
|
22
|
+
|
17
23
|
def teardown
|
18
24
|
FileUtils.rm_r @tmp_dir
|
19
25
|
end
|
data/test/test_helper.rb
CHANGED
@@ -17,7 +17,7 @@ def fixture(filename)
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def stub_get(url, file)
|
20
|
-
FakeWeb.register_uri(:get, "https://user:password@account.fluxiom.com:443#{url}", :
|
20
|
+
FakeWeb.register_uri(:get, "https://user:password@account.fluxiom.com:443#{url}", :body => fixture(file))
|
21
21
|
end
|
22
22
|
|
23
23
|
def register_requests
|
@@ -25,7 +25,8 @@ def register_requests
|
|
25
25
|
next if file == '.' || file == '..' || !file.include?('.xml')
|
26
26
|
stub_get('/api/' + file, file)
|
27
27
|
end
|
28
|
-
FakeWeb.register_uri(:get, "https://user:password@account.fluxiom.com:443/api/assets/download
|
28
|
+
FakeWeb.register_uri(:get, "https://user:password@account.fluxiom.com:443/api/assets/182535/download", :response => File.expand_path(File.dirname(__FILE__) + '/fixtures/download_response'))
|
29
|
+
FakeWeb.register_uri(:post, "https://user:password@account.fluxiom.com:443/api/assets/182535/tag", :body => "", :status => [201, "Created"])
|
29
30
|
end
|
30
31
|
|
31
32
|
def set_account
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluxapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.6"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Sebastian Gr\xC3\xA4\xC3\x9Fl"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-14 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
- - "="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
version:
|
28
28
|
description: A fluxiom api wrapper for ruby
|
29
29
|
email: sebastian.graessl@gmail.com
|
@@ -32,6 +32,8 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
|
34
34
|
extra_rdoc_files:
|
35
|
+
- README.txt
|
36
|
+
- lib/fluxapi.rb
|
35
37
|
- lib/fluxapi/account.rb
|
36
38
|
- lib/fluxapi/asset.rb
|
37
39
|
- lib/fluxapi/assets.rb
|
@@ -40,10 +42,12 @@ extra_rdoc_files:
|
|
40
42
|
- lib/fluxapi/tags.rb
|
41
43
|
- lib/fluxapi/user.rb
|
42
44
|
- lib/fluxapi/users.rb
|
43
|
-
- lib/fluxapi.rb
|
44
|
-
- README.txt
|
45
45
|
files:
|
46
46
|
- History.txt
|
47
|
+
- Manifest
|
48
|
+
- README.txt
|
49
|
+
- Rakefile
|
50
|
+
- lib/fluxapi.rb
|
47
51
|
- lib/fluxapi/account.rb
|
48
52
|
- lib/fluxapi/asset.rb
|
49
53
|
- lib/fluxapi/assets.rb
|
@@ -52,10 +56,6 @@ files:
|
|
52
56
|
- lib/fluxapi/tags.rb
|
53
57
|
- lib/fluxapi/user.rb
|
54
58
|
- lib/fluxapi/users.rb
|
55
|
-
- lib/fluxapi.rb
|
56
|
-
- Manifest
|
57
|
-
- Rakefile
|
58
|
-
- README.txt
|
59
59
|
- test/fixtures/account.xml
|
60
60
|
- test/fixtures/assets.xml
|
61
61
|
- test/fixtures/download_response
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
requirements: []
|
97
97
|
|
98
98
|
rubyforge_project: fluxapi
|
99
|
-
rubygems_version: 1.3.
|
99
|
+
rubygems_version: 1.3.5
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: A fluxiom api wrapper for ruby
|