midna 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,10 +2,54 @@
2
2
 
3
3
  Ruby interface to the Midna API.
4
4
 
5
- This gem chats with the Midna API so you don't have to bother with GETs and POSTs and such. It will give you objects in the Midna namespace, so they don't even clash with your existing ones.
5
+ This gem chats with the Midna API so you don't have to. It will give you objects in the Midna namespace, which you can query like Active Record:
6
+
7
+ Midna::Channel.all
6
8
 
7
9
  Also, Midna is Zelda's goth sister.
8
10
 
11
+ == Installation in Rails
12
+
13
+ Install this plugin as a gem.
14
+
15
+ For Rails 2, in config/environment.rb
16
+
17
+ config.gem 'midna'
18
+
19
+ For Rails 3, in Gemfile
20
+
21
+ gem 'midna'
22
+
23
+ Then run <tt>rake gems:install</tt>.
24
+
25
+ == Installation as a Ruby gem
26
+
27
+ First install the gem on your machine like usual:
28
+
29
+ $ gem install midna
30
+
31
+ Use <tt>sudo</tt> if your setup requires it. After this you can require it in your code and work with Midna from there.
32
+
33
+ require 'rubygems'
34
+ require 'midna'
35
+
36
+ puts Midna::Channel.all
37
+ # => {"channels" => [ an array of hashes ]}
38
+
39
+ == Configuration
40
+
41
+ If you are using rails, create a file called <tt>config/initializers/midna.rb</tt> with the following configuration. If you are using the gem, execute these lines before you first call any Midna objects.
42
+
43
+ The gem connects to <tt>midna.omroep.nl</tt> by default. You can override this by setting the +base_uri+:
44
+
45
+ Midna.base_uri = 'http://some.other.host'
46
+
47
+ == Prerequisites
48
+
49
+ The HTTparty[http://github.com/jnunemaker/httparty] gem.
50
+
51
+ gem install httparty
52
+
9
53
  == Copyright
10
54
 
11
55
  Copyright (c) 2010 Joost Baaij. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.0
@@ -0,0 +1,20 @@
1
+ begin
2
+ require 'httparty'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'httparty', '>= 0.4.4'
6
+ require 'httparty'
7
+ end
8
+
9
+ require 'midna/channel'
10
+
11
+ class Midna
12
+ include HTTParty
13
+ base_uri 'http://midna.omroep.nl'
14
+ format :xml
15
+
16
+ # allow override of the base uri
17
+ def self.base_uri=(uri)
18
+ base_uri(uri)
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ class Midna
2
+ class Channel
3
+ def self.all
4
+ Midna.get("/channels.xml").to_hash
5
+ end
6
+ end
7
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{midna}
8
- s.version = "0.0.0"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joost Baaij"]
12
- s.date = %q{2010-08-03}
12
+ s.date = %q{2010-08-04}
13
13
  s.description = %q{This gem chats with the Midna API so you don't have to bother with GETs and POSTs and such. It will give you objects in the Midna namespace, so they don't even clash with your existing ones. Also, Midna is Zelda's goth sister.}
14
14
  s.email = %q{joost@spacebabies.nl}
15
15
  s.extra_rdoc_files = [
@@ -24,10 +24,13 @@ Gem::Specification.new do |s|
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "lib/midna.rb",
27
+ "lib/midna/channel.rb",
27
28
  "midna.gemspec",
29
+ "spec/midna/channel_spec.rb",
28
30
  "spec/midna_spec.rb",
29
31
  "spec/spec.opts",
30
- "spec/spec_helper.rb"
32
+ "spec/spec_helper.rb",
33
+ "spec/support/midna.rb"
31
34
  ]
32
35
  s.homepage = %q{http://github.com/tilsammans/midna}
33
36
  s.rdoc_options = ["--charset=UTF-8"]
@@ -35,8 +38,10 @@ Gem::Specification.new do |s|
35
38
  s.rubygems_version = %q{1.3.7}
36
39
  s.summary = %q{Ruby interface to the Midna API}
37
40
  s.test_files = [
38
- "spec/midna_spec.rb",
39
- "spec/spec_helper.rb"
41
+ "spec/midna/channel_spec.rb",
42
+ "spec/midna_spec.rb",
43
+ "spec/spec_helper.rb",
44
+ "spec/support/midna.rb"
40
45
  ]
41
46
 
42
47
  if s.respond_to? :specification_version then
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Midna::Channel do
4
+ its(:class) { should respond_to(:all) }
5
+
6
+ describe 'all' do
7
+ it "should get /channels.xml" do
8
+ Midna.should_receive(:get).with("/channels.xml").and_return(all = stub)
9
+ all.stub!(:to_hash).and_return(hash = stub)
10
+ Midna::Channel.all.should equal(hash)
11
+ end
12
+ end
13
+ end
@@ -1,7 +1,12 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Midna" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
4
+ it "defines Midna::Channel" do
5
+ defined?(Midna::Channel).should be_true
6
+ end
7
+
8
+ it "allows base_uri override" do
9
+ Midna.base_uri = 'bloep'
10
+ Midna.base_uri.should == 'http://bloep'
6
11
  end
7
12
  end
@@ -4,6 +4,10 @@ require 'midna'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
6
 
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
7
11
  Spec::Runner.configure do |config|
8
12
 
9
13
  end
@@ -0,0 +1 @@
1
+ Midna::BASE_URI = 'midna.local'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: midna
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 0.0.0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joost Baaij
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-03 00:00:00 +02:00
18
+ date: 2010-08-04 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,10 +51,13 @@ files:
51
51
  - Rakefile
52
52
  - VERSION
53
53
  - lib/midna.rb
54
+ - lib/midna/channel.rb
54
55
  - midna.gemspec
56
+ - spec/midna/channel_spec.rb
55
57
  - spec/midna_spec.rb
56
58
  - spec/spec.opts
57
59
  - spec/spec_helper.rb
60
+ - spec/support/midna.rb
58
61
  has_rdoc: true
59
62
  homepage: http://github.com/tilsammans/midna
60
63
  licenses: []
@@ -90,5 +93,7 @@ signing_key:
90
93
  specification_version: 3
91
94
  summary: Ruby interface to the Midna API
92
95
  test_files:
96
+ - spec/midna/channel_spec.rb
93
97
  - spec/midna_spec.rb
94
98
  - spec/spec_helper.rb
99
+ - spec/support/midna.rb