drupal_fu 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in drupal_fu.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,24 @@
1
+ == drupal_fu
2
+
3
+ Simple Ruby gem for reading content nodes from a Drupal CMS with the Services and REST Server modules enabled
4
+
5
+ == Installation
6
+
7
+ Rails app:
8
+
9
+ gem 'drupal_fu'
10
+
11
+ Configuration:
12
+
13
+ rails g drupal_fu:config
14
+
15
+ This adds a drupal_fu.rb initializer:
16
+
17
+ DRUPAL_BASE_URI = "http://yoursite/rest"
18
+ DrupalFu::Client.options[:base_uri] = DRUPAL_BASE_URI
19
+
20
+ == Usage
21
+
22
+ Retrieving a node:
23
+
24
+ @node = DrupalFu::Client.new.node(params[:id].to_i)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/drupal_fu.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "drupal_fu/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "drupal_fu"
7
+ s.version = DrupalFu::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Armand du Plessis"]
10
+ s.email = ["adp@bank.io"]
11
+ s.homepage = ""
12
+ s.summary = %q{Simple gem interface for pulling content from Drupal CMS}
13
+ s.description = %q{Simple gem interface for pulling content from Drupal CMS}
14
+
15
+ s.rubyforge_project = "drupal_fu"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
data/lib/drupal_fu.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'drupal_fu/client'
2
+ require 'drupal_fu/drupal_object'
3
+ require 'drupal_fu/version'
4
+
@@ -0,0 +1,19 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+
4
+ module DrupalFu
5
+ class Client
6
+
7
+ class << self
8
+ def options
9
+ @options ||= {
10
+ :base_uri => DRUPAL_BASE_URI # Class reloading in Rails Development Environment
11
+ }
12
+ end
13
+ end
14
+
15
+ def method_missing(resource, args, &block)
16
+ DrupalObject.new(JSON.parse(RestClient.get("#{self.class.options[:base_uri]}/#{resource}/#{args}", {:accept => :json})))
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module DrupalFu
2
+ class DrupalObject
3
+ def initialize(hash)
4
+ @hash = hash
5
+ end
6
+
7
+ def method_missing(method, *args, &block)
8
+ if @hash.has_key?(method.to_s)
9
+ return @hash[method.to_s]
10
+ end
11
+ super
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module DrupalFu
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module DrupalFu
5
+ class ConfigGenerator < Rails::Generators::Base
6
+
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_initializer_file
10
+ copy_file 'initializer.rb', 'config/initializers/drupal_fu.rb'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ DRUPAL_BASE_URI = "http://yoursite"
2
+ DrupalFu::Client.options[:base_uri] = DRUPAL_BASE_URI
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drupal_fu
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Armand du Plessis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-15 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Simple gem interface for pulling content from Drupal CMS
18
+ email:
19
+ - adp@bank.io
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - README
30
+ - Rakefile
31
+ - drupal_fu.gemspec
32
+ - lib/drupal_fu.rb
33
+ - lib/drupal_fu/client.rb
34
+ - lib/drupal_fu/drupal_object.rb
35
+ - lib/drupal_fu/version.rb
36
+ - lib/generators/drupal_fu/config_generator.rb
37
+ - lib/generators/drupal_fu/templates/initializer.rb
38
+ has_rdoc: true
39
+ homepage: ""
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project: drupal_fu
62
+ rubygems_version: 1.6.2
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Simple gem interface for pulling content from Drupal CMS
66
+ test_files: []
67
+