llremote 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +165 -0
- data/README +76 -0
- data/Rakefile +91 -0
- data/install.rb +30 -0
- data/lib/l_l_remote/logi.rb +125 -0
- data/lib/l_l_remote/version.rb +9 -0
- data/lib/l_l_remote.rb +71 -0
- data/lib/llremote.rb +1 -0
- data/test/l_l_remote_test.rb +23 -0
- data/test/logi_test.rb +24 -0
- data/test/test_helper.rb +3 -0
- metadata +66 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/README
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
= LogiLogi Remote Gem documentation
|
2
|
+
"Your remote control for LogiLogi"
|
3
|
+
|
4
|
+
Allows you to update and create Logis on http://www.LogiLogi.org from
|
5
|
+
any application.
|
6
|
+
|
7
|
+
LLRemote is a library by the LogiLogi Foundation
|
8
|
+
(http://foundation.logilogi.org).
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
First require it.
|
13
|
+
|
14
|
+
$ irb
|
15
|
+
|
16
|
+
> require 'rubygems'
|
17
|
+
> require 'llremote'
|
18
|
+
|
19
|
+
First set it up for connecting
|
20
|
+
|
21
|
+
> LLRemote.setup(:access_token => <your API access token>)
|
22
|
+
|
23
|
+
Then initialize the remote logi
|
24
|
+
|
25
|
+
> logi = LLRemote::Logi.new(
|
26
|
+
> :link => "Interesting/New",
|
27
|
+
> :title => "My shiny new Logi",
|
28
|
+
> :body => "New things come about...")
|
29
|
+
|
30
|
+
And save it.
|
31
|
+
|
32
|
+
> logi.save
|
33
|
+
|
34
|
+
It's that easy.
|
35
|
+
|
36
|
+
== Installation
|
37
|
+
|
38
|
+
You can install LogiLogi Remote with the following command:
|
39
|
+
|
40
|
+
% [sudo] gem install llremote
|
41
|
+
|
42
|
+
The latest version of LogiLogi Remote can also be downloaded at:
|
43
|
+
|
44
|
+
* http://rubyforge.org/frs/?group_id=8494
|
45
|
+
|
46
|
+
And then from its distribution directory installed with:
|
47
|
+
|
48
|
+
% [sudo] ruby install.rb
|
49
|
+
|
50
|
+
== Support
|
51
|
+
|
52
|
+
The LogiLogi Remote homepage is http://textweaver.rubyforge.org.
|
53
|
+
|
54
|
+
For the latest news on LogiLogi Remote:
|
55
|
+
|
56
|
+
* http://foundation.logilogi.org/tags/LLRemote
|
57
|
+
|
58
|
+
Feel free to submit commits or feature requests. If you send a patch,
|
59
|
+
remember to update the corresponding unit tests.
|
60
|
+
|
61
|
+
== This Documentation
|
62
|
+
|
63
|
+
This documentation can be browsed online at:
|
64
|
+
|
65
|
+
* http://llremote.rubyforge.org
|
66
|
+
|
67
|
+
== Copyrights
|
68
|
+
|
69
|
+
LogiLogi Remote and these docs are Copyright (c) 2006-2009 The LogiLogi
|
70
|
+
Foundation. LLRemote is licensed under the {GNU Lesser General Public
|
71
|
+
License}[http://www.gnu.org/licenses/lgpl-3.0-standalone.html].
|
72
|
+
These docs are available under the {Creative Commons Attribution-Share
|
73
|
+
Alike License}[http://creativecommons.org/licenses/by-sa/3.0/].
|
74
|
+
|
75
|
+
You can use LLRemote in an application that is not Free Software
|
76
|
+
but LLRemote itself remains Free Software.
|
data/Rakefile
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/contrib/sshpublisher'
|
8
|
+
require File.join(File.dirname(__FILE__), 'lib', 'l_l_remote', 'version')
|
9
|
+
|
10
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
|
+
PKG_NAME = 'llremote'
|
12
|
+
PKG_VERSION = LLRemote::VERSION::STRING + PKG_BUILD
|
13
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
|
+
|
15
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
16
|
+
|
17
|
+
RUBY_FORGE_PROJECT = "llremote"
|
18
|
+
RUBY_FORGE_USER = "wybow"
|
19
|
+
|
20
|
+
desc "Default Task"
|
21
|
+
task :default => [ :test ]
|
22
|
+
|
23
|
+
# Run the unit tests
|
24
|
+
Rake::TestTask.new { |t|
|
25
|
+
t.libs << "test"
|
26
|
+
t.pattern = 'test/*_test.rb'
|
27
|
+
t.verbose = true
|
28
|
+
t.warning = false
|
29
|
+
}
|
30
|
+
|
31
|
+
# Generate the RDoc documentation
|
32
|
+
Rake::RDocTask.new { |rdoc|
|
33
|
+
rdoc.rdoc_dir = 'doc'
|
34
|
+
rdoc.title = "LLRemote -- Your remote control for LogiLogi"
|
35
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
36
|
+
rdoc.options << '--charset' << 'utf-8'
|
37
|
+
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
38
|
+
rdoc.rdoc_files.include('lib/l_l_remote.rb')
|
39
|
+
rdoc.rdoc_files.include('lib/l_l_remote/*.rb')
|
40
|
+
}
|
41
|
+
|
42
|
+
# Create compressed packages
|
43
|
+
spec = Gem::Specification.new do |s|
|
44
|
+
s.platform = Gem::Platform::RUBY
|
45
|
+
s.name = PKG_NAME
|
46
|
+
s.summary = "Your remote control for LogiLogi."
|
47
|
+
s.description = %q{Allows you to post and update logis remotely.}
|
48
|
+
s.version = PKG_VERSION
|
49
|
+
|
50
|
+
s.author = "Wybo Wiersma"
|
51
|
+
s.email = "wybo@logilogi.org"
|
52
|
+
s.rubyforge_project = "llremote"
|
53
|
+
s.homepage = "http://llremote.rubyforge.org"
|
54
|
+
|
55
|
+
s.has_rdoc = true
|
56
|
+
s.requirements << 'none'
|
57
|
+
s.require_path = 'lib'
|
58
|
+
|
59
|
+
s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG", "LICENSE" ]
|
60
|
+
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
61
|
+
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
62
|
+
end
|
63
|
+
|
64
|
+
Rake::GemPackageTask.new(spec) do |p|
|
65
|
+
p.gem_spec = spec
|
66
|
+
p.need_tar = true
|
67
|
+
p.need_zip = true
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Publish the docs, gem, and release files"
|
71
|
+
task :deploy => [:release, :pdoc] do
|
72
|
+
puts 'Published gem'
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Publish the API documentation"
|
76
|
+
task :pdoc => [:rdoc] do
|
77
|
+
sh "rsync -azv --no-perms --no-times doc/*" +
|
78
|
+
" rubyforge.org:/var/www/gforge-projects/llremote"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Publish the release files to RubyForge."
|
82
|
+
task :release => [ :package ] do
|
83
|
+
require 'rubyforge'
|
84
|
+
require 'rake/contrib/rubyforgepublisher'
|
85
|
+
|
86
|
+
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
87
|
+
|
88
|
+
rubyforge = RubyForge.new.configure
|
89
|
+
rubyforge.login
|
90
|
+
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
91
|
+
end
|
data/install.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'find'
|
3
|
+
require 'ftools'
|
4
|
+
|
5
|
+
include Config
|
6
|
+
|
7
|
+
# this was adapted from rdoc's install.rb by way of Log4r
|
8
|
+
|
9
|
+
$sitedir = CONFIG["sitelibdir"]
|
10
|
+
unless $sitedir
|
11
|
+
version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
|
12
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", version)
|
13
|
+
$sitedir = $:.find {|x| x =~ /site_ruby/ }
|
14
|
+
if !$sitedir
|
15
|
+
$sitedir = File.join($libdir, "site_ruby")
|
16
|
+
elsif $sitedir !~ Regexp.quote(version)
|
17
|
+
$sitedir = File.join($sitedir, version)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# the actual gruntwork
|
22
|
+
Dir.chdir("lib")
|
23
|
+
|
24
|
+
Find.find("l_l_remote", "l_l_remote.rb") { |f|
|
25
|
+
if f[-3..-1] == ".rb"
|
26
|
+
File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
|
27
|
+
else
|
28
|
+
File::makedirs(File.join($sitedir, *f.split(/\//)))
|
29
|
+
end
|
30
|
+
}
|
@@ -0,0 +1,125 @@
|
|
1
|
+
#--#
|
2
|
+
# Copyright: (c) 2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
+
#
|
4
|
+
# License:
|
5
|
+
# This file is part of the LLRemote Library. LLRemote is Free
|
6
|
+
# Software. You can run/distribute/modify LLRemote under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use LLRemote in applications that are not Free
|
9
|
+
# Software but LLRemote itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
11
|
+
#++#
|
12
|
+
#
|
13
|
+
# LLRemote::Logi is a logi that can be read and saved remotely
|
14
|
+
|
15
|
+
class LLRemote::Logi
|
16
|
+
attr_accessor :link, :title, :body
|
17
|
+
|
18
|
+
# Initializes a logi.
|
19
|
+
#
|
20
|
+
# Options:
|
21
|
+
# * <tt>link</tt> = link of the logi (can have different tags
|
22
|
+
# for existing logis to update it's tags)
|
23
|
+
# * <tt>title</tt> = the title (optional for existing logi)
|
24
|
+
# * <tt>body</tt> = the body (optional for existing logi)
|
25
|
+
#
|
26
|
+
def initialize(options)
|
27
|
+
self.link = options[:link]
|
28
|
+
self.title = options[:title]
|
29
|
+
self.body = options[:body]
|
30
|
+
end
|
31
|
+
|
32
|
+
# Loads the logi with it's remote data
|
33
|
+
#
|
34
|
+
def reload
|
35
|
+
entry = LLRemote.load_entry(self.link)
|
36
|
+
self.set_from_entry(entry)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Saves the logi. It creates it if it doesn't exist, and updates
|
40
|
+
# it if it does.
|
41
|
+
#
|
42
|
+
def save
|
43
|
+
if self.link =~ /=/
|
44
|
+
return self.update
|
45
|
+
else
|
46
|
+
return self.create
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def create
|
53
|
+
if self.link.nil? or self.link.empty? or
|
54
|
+
self.title.nil? or self.title.empty? or
|
55
|
+
self.body.nil? or self.body.empty?
|
56
|
+
raise 'Logi needs link, body and title to be created'
|
57
|
+
end
|
58
|
+
collection = Atom::Pub::Collection.new(
|
59
|
+
:href => LLRemote.server_url + "/do/logis/" + self.link + "/do.xml?user_credentials=" + LLRemote.access_token)
|
60
|
+
entry = Atom::Entry.new do |e|
|
61
|
+
e.title = self.title
|
62
|
+
e.content = self.parse_body(self.body)
|
63
|
+
e.categories = self.parse_tags(self.link)
|
64
|
+
end
|
65
|
+
begin
|
66
|
+
entry = collection.publish(entry)
|
67
|
+
rescue
|
68
|
+
raise 'Error: Could not create logi: ' + self.link
|
69
|
+
end
|
70
|
+
|
71
|
+
self.set_from_entry(entry)
|
72
|
+
return self
|
73
|
+
end
|
74
|
+
|
75
|
+
def update
|
76
|
+
if self.link.nil? or self.link.empty?
|
77
|
+
raise 'Logi needs link to be updated'
|
78
|
+
end
|
79
|
+
|
80
|
+
entry = LLRemote.load_entry(self.link)
|
81
|
+
entry.title = self.title if self.title
|
82
|
+
entry.content = self.parse_body(self.body) if self.body
|
83
|
+
entry.categories = self.parse_tags(self.link)
|
84
|
+
|
85
|
+
begin
|
86
|
+
entry.edit_link.href = entry.edit_link.href + "?user_credentials=" + LLRemote.access_token
|
87
|
+
entry.save!
|
88
|
+
rescue
|
89
|
+
raise 'Error: Could not update logi: ' + self.link
|
90
|
+
end
|
91
|
+
|
92
|
+
self.set_from_entry(entry)
|
93
|
+
return self
|
94
|
+
end
|
95
|
+
|
96
|
+
def set_from_entry(entry)
|
97
|
+
self.title = entry.title,
|
98
|
+
self.body = entry.content.to_s,
|
99
|
+
self.link = unparse_link(entry.links.alternate.to_s)
|
100
|
+
end
|
101
|
+
|
102
|
+
def parse_tags(link)
|
103
|
+
tags_string = link.split('=')[0]
|
104
|
+
tag_strings = tags_string.split('/')
|
105
|
+
categories = []
|
106
|
+
tag_strings.each do |tag_string|
|
107
|
+
categories << Atom::Category.new(:term => tag_string)
|
108
|
+
end
|
109
|
+
return categories
|
110
|
+
end
|
111
|
+
|
112
|
+
def unparse_link(raw_link)
|
113
|
+
link = raw_link.gsub(LLRemote.server_url + "/","")
|
114
|
+
link.strip!
|
115
|
+
return link
|
116
|
+
end
|
117
|
+
|
118
|
+
def parse_body(raw_body)
|
119
|
+
raw_body = raw_body.dup
|
120
|
+
raw_body.gsub!(/^(\n|\s)*/,"")
|
121
|
+
raw_body.gsub!(/(\n|\s)*$/,"")
|
122
|
+
return Atom::Content::Html.new(
|
123
|
+
"<p>" + raw_body.split("\n").join("</p> <p>") + "</p>")
|
124
|
+
end
|
125
|
+
end
|
data/lib/l_l_remote.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#--#
|
2
|
+
# Copyright: (c) 2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
+
#
|
4
|
+
# License:
|
5
|
+
# This file is part of the LLRemote Library. LLRemote is Free
|
6
|
+
# Software. You can run/distribute/modify LLRemote under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use LLRemote in applications that are not Free
|
9
|
+
# Software but LLRemote itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
11
|
+
#++#
|
12
|
+
#
|
13
|
+
# LLRemote allows you to save logis remotely.
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'ratom'
|
17
|
+
require 'atom'
|
18
|
+
require 'atom/pub'
|
19
|
+
|
20
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
21
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
22
|
+
|
23
|
+
class LLRemote
|
24
|
+
### Class-attributes
|
25
|
+
|
26
|
+
[:access_token,:server_url].each do |cattribute|
|
27
|
+
eval <<FUN
|
28
|
+
def self.#{cattribute}
|
29
|
+
@@#{cattribute}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.#{cattribute}=(attr)
|
33
|
+
@@#{cattribute} = attr
|
34
|
+
end
|
35
|
+
FUN
|
36
|
+
end
|
37
|
+
|
38
|
+
### Class-methods
|
39
|
+
|
40
|
+
# Sets the api-key and other options.
|
41
|
+
#
|
42
|
+
# Options:
|
43
|
+
# * <tt>access_token</tt> = the API key, required
|
44
|
+
# * <tt>server_url</tt> = the logilogi server, defaults to
|
45
|
+
# http://en.logilogi.org
|
46
|
+
#
|
47
|
+
def self.setup(options = {})
|
48
|
+
raise 'Needs :access_token' if options[:access_token].nil?
|
49
|
+
|
50
|
+
LLRemote.access_token = options[:access_token]
|
51
|
+
if options[:server_url]
|
52
|
+
LLRemote.server_url = options[:server_url].gsub(/\/$/,"")
|
53
|
+
else
|
54
|
+
LLRemote.server_url = "http://en.logilogi.org"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Loads a ratom Atom::Entry for the given link.
|
59
|
+
#
|
60
|
+
# For internal use.
|
61
|
+
#
|
62
|
+
def self.load_entry(link)
|
63
|
+
begin
|
64
|
+
return Atom::Entry.load_entry(URI.parse(LLRemote.server_url + "/" + link + "/do.xml"))
|
65
|
+
rescue
|
66
|
+
raise 'Error: Perhaps wrong credentials ?'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
require 'l_l_remote/logi'
|
data/lib/llremote.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'l_l_remote'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#--#
|
2
|
+
# Copyright: (c) 2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
+
#
|
4
|
+
# License:
|
5
|
+
# This file is part of the LLRemote Library. LLRemote is Free
|
6
|
+
# Software. You can run/distribute/modify LLRemote under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use LLRemote in applications that are not Free
|
9
|
+
# Software but LLRemote itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
11
|
+
#++#
|
12
|
+
|
13
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
14
|
+
|
15
|
+
class LLRemoteTest < Test::Unit::TestCase
|
16
|
+
### Initialization
|
17
|
+
|
18
|
+
def test_initialize
|
19
|
+
LLRemote.setup(:access_token => "Moo", :server_url => "http://bod.com")
|
20
|
+
assert_equal "Moo", LLRemote.access_token
|
21
|
+
assert_equal "http://bod.com", LLRemote.server_url
|
22
|
+
end
|
23
|
+
end
|
data/test/logi_test.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#--#
|
2
|
+
# Copyright: (c) 2009 The LogiLogi Foundation <foundation@logilogi.org>
|
3
|
+
#
|
4
|
+
# License:
|
5
|
+
# This file is part of the LLRemote Library. LLRemote is Free
|
6
|
+
# Software. You can run/distribute/modify LLRemote under the terms
|
7
|
+
# of the GNU Lesser General Public License version 3. This license
|
8
|
+
# states that you can use LLRemote in applications that are not Free
|
9
|
+
# Software but LLRemote itself remains Free Software. (LICENSE contains
|
10
|
+
# the full text of the legally binding license).
|
11
|
+
#++#
|
12
|
+
|
13
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
14
|
+
|
15
|
+
class LogiTest < Test::Unit::TestCase
|
16
|
+
### Initialization
|
17
|
+
|
18
|
+
def test_initialize
|
19
|
+
l = LLRemote::Logi.new(:link => "a", :title => "b", :body => "c")
|
20
|
+
assert_equal "a", l.link
|
21
|
+
assert_equal "b", l.title
|
22
|
+
assert_equal "c", l.body
|
23
|
+
end
|
24
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: llremote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wybo Wiersma
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-09 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Allows you to post and update logis remotely.
|
17
|
+
email: wybo@logilogi.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- Rakefile
|
26
|
+
- install.rb
|
27
|
+
- README
|
28
|
+
- CHANGELOG
|
29
|
+
- LICENSE
|
30
|
+
- lib/l_l_remote/version.rb
|
31
|
+
- lib/l_l_remote/logi.rb
|
32
|
+
- lib/l_l_remote.rb
|
33
|
+
- lib/llremote.rb
|
34
|
+
- test/logi_test.rb
|
35
|
+
- test/l_l_remote_test.rb
|
36
|
+
- test/test_helper.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://llremote.rubyforge.org
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements:
|
59
|
+
- none
|
60
|
+
rubyforge_project: llremote
|
61
|
+
rubygems_version: 1.3.4
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Your remote control for LogiLogi.
|
65
|
+
test_files: []
|
66
|
+
|