springnote_resources 0.2

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/History.txt ADDED
@@ -0,0 +1,7 @@
1
+ == 0.2 / 2007-7-30
2
+
3
+ * Public Release
4
+
5
+ == 0.1 / 2007-07-01
6
+
7
+ * Openmaru Devday Release
data/Manifest.txt ADDED
@@ -0,0 +1,13 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ Todo.txt
6
+ lib/springnote.rb
7
+ lib/springnote/base.rb
8
+ lib/springnote/configuration.rb
9
+ lib/springnote/lock.rb
10
+ lib/springnote/page.rb
11
+ lib/springnote/revision.rb
12
+ spec/base_spec.rb
13
+ spec/configuration_spec.rb
data/README.txt ADDED
@@ -0,0 +1,42 @@
1
+ = Springnote Resources
2
+
3
+ * Homepage: http://deepblue.springnote.com/pages/391111
4
+ * Author: Bryan Kang (http://myruby.net)
5
+
6
+ == DESCRIPTIONS:
7
+
8
+ ActiveResource wrapper library for Springnote.com's REST API
9
+
10
+ == REQUIREMENTS:
11
+
12
+ * activesupport
13
+ * activeresource
14
+
15
+ == INSTALL:
16
+
17
+ * sudo gem install springnote_resources
18
+
19
+ == LICENSE:
20
+
21
+ (The MIT License)
22
+
23
+ Copyright (c) 2007 Bryan Kang
24
+
25
+ Permission is hereby granted, free of charge, to any person obtaining
26
+ a copy of this software and associated documentation files (the
27
+ "Software"), to deal in the Software without restriction, including
28
+ without limitation the rights to use, copy, modify, merge, publish,
29
+ distribute, sublicense, and/or sell copies of the Software, and to
30
+ permit persons to whom the Software is furnished to do so, subject to
31
+ the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be
34
+ included in all copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
40
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
41
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
42
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+ require File.dirname(__FILE__) + '/lib/springnote'
4
+
5
+ Hoe.new("springnote_resources", Springnote::VERSION) do |p|
6
+ p.rubyforge_name = "springnote"
7
+ p.summary = "ActiveResource wrapper library for Springnote.com's REST API"
8
+ p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
9
+ p.url = p.paragraphs_of('README.txt', 1).first.gsub(/^\* Homepage: /, '').split(/\n/)
10
+ p.author = 'Bryan Kang'
11
+ p.email = 'byblue@gmail.com'
12
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
+ p.need_zip = true
14
+ end
15
+
16
+ task :update_manifest do
17
+ dirs = Dir['*txt'] + ['Rakefile', 'vendor']
18
+ %w(lib spec).each {|dir| dirs += Dir["#{dir}/**/*"] }
19
+ File.open('Manifest.txt', 'w') {|f| f.write(dirs.join("\n")) }
20
+ end
data/Todo.txt ADDED
@@ -0,0 +1,2 @@
1
+ - Make specifications
2
+ - Make example applications
data/lib/springnote.rb ADDED
@@ -0,0 +1,18 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ unless defined?(ActiveResource)
5
+ begin
6
+ $:.unshift(File.dirname(__FILE__) + "/../vendor/activeresource/lib")
7
+ require 'active_resource'
8
+ rescue LoadError
9
+ require 'rubygems'
10
+ gem 'activeresource'
11
+ end
12
+ end
13
+
14
+ require 'springnote/configuration'
15
+ require 'springnote/base'
16
+ require 'springnote/page'
17
+ require 'springnote/lock'
18
+ require 'springnote/revision'
@@ -0,0 +1,23 @@
1
+ module Springnote
2
+ VERSION = "0.2"
3
+
4
+ class Base < ActiveResource::Base
5
+ set_primary_key 'identifier'
6
+
7
+ def id
8
+ attributes["identifier"]
9
+ end
10
+
11
+ def id=(id)
12
+ attributes["identifier"] = id
13
+ end
14
+
15
+ def to_param
16
+ identifier.to_s
17
+ end
18
+
19
+ class <<self
20
+ attr_accessor_with_default :configuration, Springnote::Configuration.new
21
+ end
22
+ end # Base
23
+ end # module Springnote
@@ -0,0 +1,36 @@
1
+ require 'cgi'
2
+
3
+ module Springnote
4
+ class MissingConfiguration < RuntimeError; end
5
+
6
+ class Configuration
7
+ attr_writer :app_key, :user_key, :user_openid
8
+ SERVER_URL = "api.springnote.com"
9
+
10
+ def site
11
+ "https://#{username}:#{password}@#{SERVER_URL}/"
12
+ end
13
+
14
+ def load(file)
15
+ set YAML.load(File.read(file))
16
+ end
17
+
18
+ def set(options)
19
+ options.each{|k,v| self.send("#{k}=", v)}
20
+ Springnote::Base.site = self.site
21
+ self
22
+ end
23
+
24
+ def username
25
+ CGI.escape(@user_openid || 'anonymous')
26
+ end
27
+
28
+ def password
29
+ @user_key ? [@user_key, app_key].join('.') : app_key
30
+ end
31
+
32
+ def app_key
33
+ @app_key or raise MissingConfiguration
34
+ end
35
+ end
36
+ end # module Springnote
@@ -0,0 +1,5 @@
1
+ module Springnote
2
+ class Lock < Base
3
+ set_prefix '/pages/:page_id/'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Springnote
2
+ class Page < Base
3
+ def lock
4
+ Lock.find(:page_id => self.id)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Springnote
2
+ class Revision < Base
3
+ set_prefix '/pages/:page_id/'
4
+ end
5
+ end
data/spec/base_spec.rb ADDED
@@ -0,0 +1,4 @@
1
+ require File.dirname(__FILE__) + '/../lib/springnote'
2
+
3
+ describe Springnote::Base do
4
+ end
@@ -0,0 +1,45 @@
1
+ require File.dirname(__FILE__) + '/../lib/springnote'
2
+
3
+ describe Springnote::Configuration do
4
+ before(:each) do
5
+ @configuration = Springnote::Configuration.new
6
+ end
7
+
8
+ it "app_id를 설정하지 않으면 에러" do
9
+ lambda { @configuration.app_id }.should raise_error(Springnote::MissingConfiguration)
10
+ @configuration.app_id = 'app_id'
11
+ @configuration.app_id.should == 'app_id'
12
+ end
13
+
14
+ it "app_key를 설정하지 않으면 에러" do
15
+ lambda { @configuration.app_key }.should raise_error(Springnote::MissingConfiguration)
16
+ @configuration.app_key = 'app_key'
17
+ @configuration.app_key.should == 'app_key'
18
+ end
19
+
20
+ it "password를 얻을 수 있다" do
21
+ set_test_auth
22
+
23
+ password = @configuration.password
24
+ password.should_not be_empty
25
+ parsed = CGI.unescape(password).split(',')
26
+ parsed.length.should == 4
27
+ end
28
+
29
+ it "passwd는 매번 바뀐다" do
30
+ set_test_auth
31
+ @configuration.password.should_not == @configuration.password
32
+ end
33
+
34
+ it "site를 반환한다" do
35
+ set_test_auth
36
+ @configuration.site.should match(/http:\/\/(.*?):(.*?)@api.springnote.com\//)
37
+ end
38
+
39
+ def set_test_auth
40
+ @configuration.app_id = 'app_id'
41
+ @configuration.app_key = 'app_key'
42
+ @configuration.user_key = 'user_key'
43
+ @configuration.user_open_id = 'http://user.myid.net/'
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: springnote_resources
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.2"
7
+ date: 2007-08-02 00:00:00 +09:00
8
+ summary: ActiveResource wrapper library for Springnote.com's REST API
9
+ require_paths:
10
+ - lib
11
+ email: byblue@gmail.com
12
+ homepage: http://deepblue.springnote.com/pages/391111
13
+ rubyforge_project: springnote
14
+ description: "== DESCRIPTIONS: ActiveResource wrapper library for Springnote.com's REST API == REQUIREMENTS: * activesupport * activeresource"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Bryan Kang
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - Todo.txt
37
+ - lib/springnote.rb
38
+ - lib/springnote/base.rb
39
+ - lib/springnote/configuration.rb
40
+ - lib/springnote/lock.rb
41
+ - lib/springnote/page.rb
42
+ - lib/springnote/revision.rb
43
+ - spec/base_spec.rb
44
+ - spec/configuration_spec.rb
45
+ test_files: []
46
+
47
+ rdoc_options:
48
+ - --main
49
+ - README.txt
50
+ extra_rdoc_files:
51
+ - History.txt
52
+ - Manifest.txt
53
+ - README.txt
54
+ - Todo.txt
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ requirements: []
60
+
61
+ dependencies:
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe
64
+ version_requirement:
65
+ version_requirements: !ruby/object:Gem::Version::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.2
70
+ version: