nom_nom 0.0.4 → 0.0.5
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/README.md +9 -3
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/examples/bitter.rb +16 -10
- data/examples/syncd.rb +18 -6
- data/lib/nom_nom/resource.rb +8 -2
- data/lib/nom_nom/service.rb +9 -7
- data/nom_nom.gemspec +68 -0
- metadata +5 -4
data/README.md
CHANGED
@@ -21,16 +21,22 @@ Examples
|
|
21
21
|
|
22
22
|
require 'nom_nom'
|
23
23
|
|
24
|
-
class Service
|
24
|
+
class Service
|
25
|
+
include NomNom::Service
|
26
|
+
|
25
27
|
resources :posts
|
26
28
|
resources :users
|
27
29
|
|
28
|
-
class Post
|
30
|
+
class Post
|
31
|
+
include NomNom::Resource
|
32
|
+
|
29
33
|
attr_accessor :id, :body, :user_id
|
30
34
|
belongs_to :user
|
31
35
|
end
|
32
36
|
|
33
|
-
class User
|
37
|
+
class User
|
38
|
+
include NomNom::Resource
|
39
|
+
|
34
40
|
attr_accessor :id, :login, :email
|
35
41
|
has_many :posts
|
36
42
|
end
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ begin
|
|
13
13
|
gem.add_development_dependency "rspec"
|
14
14
|
gem.add_dependency('nokogiri', '= 1.4.3.1')
|
15
15
|
gem.add_dependency('httparty', '= 0.6.1')
|
16
|
-
gem.add_dependency('
|
16
|
+
gem.add_dependency('activesupport', '= 3.0.0')
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
end
|
19
19
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/examples/bitter.rb
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
require 'nom_nom'
|
2
2
|
|
3
|
-
class Bitter
|
4
|
-
|
5
|
-
attr_accessor :id, :body, :user_id, :created_on, :updated_on
|
6
|
-
belongs_to :user
|
7
|
-
end
|
8
|
-
|
9
|
-
class User < NomNom::Resource
|
10
|
-
attr_accessor :id, :login
|
11
|
-
has_many :bits
|
12
|
-
end
|
3
|
+
class Bitter
|
4
|
+
include NomNom::Service
|
13
5
|
|
14
6
|
def initialize(url, user, pass)
|
15
7
|
super(url, user, pass, Bitter)
|
@@ -17,4 +9,18 @@ class Bitter < NomNom::Service
|
|
17
9
|
|
18
10
|
resources :bits
|
19
11
|
resources :users
|
12
|
+
|
13
|
+
class Bit
|
14
|
+
include NomNom::Resource
|
15
|
+
|
16
|
+
attr_accessor :id, :body, :user_id, :created_on, :updated_on
|
17
|
+
belongs_to :user
|
18
|
+
end
|
19
|
+
|
20
|
+
class User
|
21
|
+
include NomNom::Resource
|
22
|
+
|
23
|
+
attr_accessor :id, :login
|
24
|
+
has_many :bits
|
25
|
+
end
|
20
26
|
end
|
data/examples/syncd.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'nom_nom'
|
2
2
|
|
3
3
|
module Syncd
|
4
|
-
class Account
|
4
|
+
class Account
|
5
|
+
include NomNom::Service
|
6
|
+
|
5
7
|
def initialize(subdomain, user, pass)
|
6
8
|
super("https://#{subdomain}.syncd.com", user, pass, Syncd)
|
7
9
|
end
|
@@ -17,13 +19,17 @@ module Syncd
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
class Activity
|
22
|
+
class Activity
|
23
|
+
include NomNom::Resource
|
24
|
+
|
21
25
|
attr_accessor :id, :name, :active, :code, :description, :url, :created_at, :updated_at
|
22
26
|
|
23
27
|
has_many :time_entries
|
24
28
|
end
|
25
29
|
|
26
|
-
class TimeEntry
|
30
|
+
class TimeEntry
|
31
|
+
include NomNom::Resource
|
32
|
+
|
27
33
|
attr_accessor :id, :duration, :start_time, :end_time, :note, :user_id, :job_id, :activity_id, :created_at, :updated_at
|
28
34
|
|
29
35
|
belongs_to :user
|
@@ -31,7 +37,9 @@ module Syncd
|
|
31
37
|
belongs_to :activity
|
32
38
|
end
|
33
39
|
|
34
|
-
class Job
|
40
|
+
class Job
|
41
|
+
include NomNom::Resource
|
42
|
+
|
35
43
|
attr_accessor :id, :job_type_id, :parent_id, :name, :code, :description, :url, :active, :effectively_active, :allow_time_entries, :allow_expense_entries, :assigned
|
36
44
|
|
37
45
|
belongs_to :job_type
|
@@ -43,7 +51,9 @@ module Syncd
|
|
43
51
|
end
|
44
52
|
end
|
45
53
|
|
46
|
-
class JobType
|
54
|
+
class JobType
|
55
|
+
include NomNom::Resource
|
56
|
+
|
47
57
|
attr_accessor :id, :parent_id, :name, :name_plural, :allow_time_entries, :allow_expense_entries, :show_codes, :show_links, :show_descriptions, :levels
|
48
58
|
|
49
59
|
belongs_to :parent, :class_name => self.name.demodulize
|
@@ -55,7 +65,9 @@ module Syncd
|
|
55
65
|
end
|
56
66
|
end
|
57
67
|
|
58
|
-
class User
|
68
|
+
class User
|
69
|
+
include NomNom::Resource
|
70
|
+
|
59
71
|
attr_accessor :id, :name, :first_name, :last_name, :active, :code, :email, :url, :created_at, :updated_at
|
60
72
|
|
61
73
|
has_many :time_entries
|
data/lib/nom_nom/resource.rb
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
module NomNom
|
2
|
-
|
2
|
+
module Resource
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
extend ClassMethods
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
3
9
|
attr_reader :service
|
4
10
|
|
5
11
|
def initialize(service, attrs)
|
@@ -18,7 +24,7 @@ module NomNom
|
|
18
24
|
self.id == other.id
|
19
25
|
end
|
20
26
|
|
21
|
-
|
27
|
+
module ClassMethods
|
22
28
|
def belongs_to(name, options = {})
|
23
29
|
assoc = (options[:class_name] || name).to_s.underscore.pluralize
|
24
30
|
key = options[:key] || "#{name}_id"
|
data/lib/nom_nom/service.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module NomNom
|
2
|
-
|
3
|
-
|
2
|
+
module Service
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include HTTParty
|
6
|
+
extend ClassMethods
|
7
|
+
end
|
8
|
+
end
|
4
9
|
|
5
10
|
attr_reader :auth, :module
|
6
11
|
|
@@ -11,12 +16,10 @@ module NomNom
|
|
11
16
|
end
|
12
17
|
|
13
18
|
def get(path, options = Hash.new)
|
14
|
-
|
15
|
-
$stderr.puts path.inspect, ret.inspect
|
16
|
-
ret
|
19
|
+
self.class.get(path, { :basic_auth => @auth }.merge(options))
|
17
20
|
end
|
18
21
|
|
19
|
-
|
22
|
+
module ClassMethods
|
20
23
|
def resources(name, options = Hash.new)
|
21
24
|
name = name.to_s
|
22
25
|
path = options[:path] || "/#{name}.xml"
|
@@ -42,7 +45,6 @@ module NomNom
|
|
42
45
|
|
43
46
|
protected
|
44
47
|
def get_resources(path, query, resource)
|
45
|
-
$stderr.puts(path.inspect)
|
46
48
|
klass = ("#{@module}::" + resource.to_s.singularize.camelize).constantize
|
47
49
|
|
48
50
|
self.
|
data/nom_nom.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{nom_nom}
|
8
|
+
s.version = "0.0.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Nolan Eakins"]
|
12
|
+
s.date = %q{2010-09-26}
|
13
|
+
s.description = %q{I consume web service. Nom nom nom.}
|
14
|
+
s.email = %q{sneakin+nomnom@semanticgap.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"examples/bitter.rb",
|
26
|
+
"examples/syncd.rb",
|
27
|
+
"lib/nom_nom.rb",
|
28
|
+
"lib/nom_nom/resource.rb",
|
29
|
+
"lib/nom_nom/service.rb",
|
30
|
+
"nom_nom.gemspec",
|
31
|
+
"spec/nom_nom_spec.rb",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/sneakin/nom-nom}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
38
|
+
s.summary = %q{COOKIE!!}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/nom_nom_spec.rb",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"examples/bitter.rb",
|
43
|
+
"examples/syncd.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
53
|
+
s.add_runtime_dependency(%q<httparty>, ["= 0.6.1"])
|
54
|
+
s.add_runtime_dependency(%q<activesupport>, ["= 3.0.0"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
57
|
+
s.add_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
58
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
59
|
+
s.add_dependency(%q<activesupport>, ["= 3.0.0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_dependency(%q<nokogiri>, ["= 1.4.3.1"])
|
64
|
+
s.add_dependency(%q<httparty>, ["= 0.6.1"])
|
65
|
+
s.add_dependency(%q<activesupport>, ["= 3.0.0"])
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nom_nom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nolan Eakins
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
type: :runtime
|
67
67
|
version_requirements: *id003
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
69
|
+
name: activesupport
|
70
70
|
prerelease: false
|
71
71
|
requirement: &id004 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/nom_nom.rb
|
102
102
|
- lib/nom_nom/resource.rb
|
103
103
|
- lib/nom_nom/service.rb
|
104
|
+
- nom_nom.gemspec
|
104
105
|
- spec/nom_nom_spec.rb
|
105
106
|
- spec/spec_helper.rb
|
106
107
|
has_rdoc: true
|