lj 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/License ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Dieinzige
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'jeweler'
4
+
5
+ Jeweler::Tasks.new do |gem|
6
+ gem.name = "lj"
7
+ gem.summary = %Q{wrapper for the livejournal api}
8
+ gem.email = "dieinzige@gmail.com"
9
+ gem.homepage = "http://github.com/dieinzige/lj"
10
+ gem.authors = ["Dieinzige"]
11
+ gem.rubyforge_project = "lj"
12
+ gem.files = FileList["[A-Z]*", "{lib}/**/*"]
13
+ end
14
+
15
+
@@ -0,0 +1,5 @@
1
+ ---
2
+ :minor: 1
3
+ :patch: 0
4
+ :build:
5
+ :major: 0
@@ -0,0 +1,30 @@
1
+ require 'forwardable'
2
+ require 'rubygems'
3
+
4
+ module LJ
5
+ class LiveJournalError < StandardError
6
+ attr_reader :data
7
+
8
+ def initialize(data)
9
+ @data = data
10
+ super
11
+ end
12
+ end
13
+
14
+ class TimeOut < LiveJournalError; end
15
+ class Unauthorized < LiveJournalError; end
16
+ class General < LiveJournalError; end
17
+
18
+ class Unavailable < StandardError; end
19
+ class NotFound < StandardError; end
20
+
21
+
22
+ end
23
+
24
+ directory = File.expand_path(File.dirname(__FILE__))
25
+
26
+ require File.join(directory, 'lj', 'httpauth')
27
+ require File.join(directory, 'lj', 'request')
28
+ require File.join(directory, 'lj', 'base')
29
+ require File.join(directory, 'lj', 'search')
30
+
@@ -0,0 +1,48 @@
1
+ module LJ
2
+ class Base
3
+
4
+ def initialize(auth)
5
+ @client = auth
6
+ end
7
+
8
+ def event(title,body,keywords)
9
+ options = base_event
10
+ perform('postevent',options)
11
+ end
12
+
13
+ def comunity(comynity_name,title,body,keywords)
14
+ options = base_event
15
+ options["usejournal"]=comynity_name
16
+ perform('perform',options)
17
+ end
18
+
19
+
20
+
21
+ private
22
+ def perform(function, options={})
23
+ LJ::Request.perform(function, options)
24
+ end
25
+
26
+ def common_options
27
+ t=Time.now
28
+ options = {}
29
+ options["year"]=t.year
30
+ options["mon"]=t.mon
31
+ options["day"]=t.day
32
+ options["hour"]=t.hour
33
+ options["min"]=t.min
34
+ options['username'] = @client.username
35
+ options['password'] = @client.password
36
+ options
37
+ end
38
+
39
+ def base_event
40
+ options = common_options()
41
+ options["mode"]="postevent"
42
+ options["lineendings"]=keywords
43
+ options["subject"]=title
44
+ options["event"]=body
45
+ options
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,12 @@
1
+ module LJ
2
+ class Client
3
+
4
+
5
+ attr_reader :username, :password
6
+
7
+ def initialize(username, password, options={})
8
+ @username, @password = usernames
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'xmlrpc/client'
2
+
3
+ module LJ
4
+ class Request
5
+
6
+ def initialize(context, function , options)
7
+ @@server ||= XMLRPC::Client.new( "www.livejournal.com", "/interface/xmlrpc")
8
+ end
9
+
10
+ def self.perform(function,options = {})
11
+ new(function,options).send
12
+ end
13
+
14
+
15
+ def send(function,options)
16
+ @@server.call("LJ.XMLRPC.#{function}", options)
17
+ end
18
+
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dieinzige
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-23 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: dieinzige@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - License
26
+ - Rakefile
27
+ - VERSION.yml
28
+ - lib/lj.rb
29
+ - lib/lj/base.rb
30
+ - lib/lj/client.rb
31
+ - lib/lj/request.rb
32
+ has_rdoc: true
33
+ homepage: http://github.com/dieinzige/lj
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --charset=UTF-8
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project: lj
56
+ rubygems_version: 1.3.5
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: wrapper for the livejournal api
60
+ test_files: []
61
+