floor_manager 0.1.1 → 0.1.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 +17 -0
- data/README +1 -2
- data/lib/floor_manager/employee/attribute_action.rb +2 -1
- data/lib/floor_manager/employee/dsl.rb +9 -2
- data/lib/floor_manager/employee.rb +11 -11
- metadata +33 -76
- data/Rakefile +0 -75
data/HISTORY.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
== 0.1.2 / 2011-09-28
|
3
|
+
|
4
|
+
* Lots of small bugfixes and small error reporting improvements. Anniversary
|
5
|
+
release.
|
6
|
+
|
7
|
+
== 0.1.1 / 2010-09-21
|
8
|
+
|
9
|
+
* Now uses rspec2 for tests.
|
10
|
+
* Correct version constraint on activesupport
|
11
|
+
|
12
|
+
== 0.1.0 / 2010-06-18
|
13
|
+
|
14
|
+
* initial version
|
15
|
+
- random string generation
|
16
|
+
- any / one object linking
|
17
|
+
- in memory build or database creation
|
data/README
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'blankslate'
|
2
|
+
|
1
3
|
module FloorManager::Employee
|
2
4
|
class DSL < BlankSlate
|
3
5
|
# A proxy that is the receiver of #set and #append in a construct like this:
|
@@ -6,7 +8,7 @@ module FloorManager::Employee
|
|
6
8
|
# relationship.set :gun
|
7
9
|
# end
|
8
10
|
#
|
9
|
-
class AssocProxy < Struct.new(:employee, :field, :dsl)
|
11
|
+
class AssocProxy < ::Struct.new(:employee, :field, :dsl)
|
10
12
|
def set(*create_args)
|
11
13
|
dsl._add_attribute AttributeAction::AssocSet.new(field, create_args)
|
12
14
|
end
|
@@ -18,6 +20,11 @@ module FloorManager::Employee
|
|
18
20
|
(0...chars).map{ ('a'..'z').to_a[rand(26)] }.join
|
19
21
|
})
|
20
22
|
end
|
23
|
+
def integer(range)
|
24
|
+
dsl._add_attribute AttributeAction::Block.new(field, proc {
|
25
|
+
range.first + rand(range.last-range.first)
|
26
|
+
})
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
23
30
|
def initialize(employee, filter=:none, &block)
|
@@ -30,7 +37,7 @@ module FloorManager::Employee
|
|
30
37
|
# Register actions to be taken if the object gets saved (floor#create)
|
31
38
|
#
|
32
39
|
def after_create(&block)
|
33
|
-
|
40
|
+
DSL.new(@employee, :after_create, &block)
|
34
41
|
end
|
35
42
|
|
36
43
|
# This method missing handles several magic incantations:
|
@@ -1,7 +1,4 @@
|
|
1
1
|
|
2
|
-
require 'active_support/core_ext/string/inflections'
|
3
|
-
require 'blankslate'
|
4
|
-
|
5
2
|
module FloorManager::Employee
|
6
3
|
|
7
4
|
# Base class for employees. No instances of this should be created.
|
@@ -18,7 +15,8 @@ module FloorManager::Employee
|
|
18
15
|
# Build this employee in memory.
|
19
16
|
#
|
20
17
|
def build(floor, overrides)
|
21
|
-
produce_instance.tap { |i|
|
18
|
+
produce_instance.tap { |i|
|
19
|
+
apply_attributes(i, :none, floor, overrides) }
|
22
20
|
end
|
23
21
|
|
24
22
|
# Create this employee in the database.
|
@@ -26,11 +24,12 @@ module FloorManager::Employee
|
|
26
24
|
def create(floor, overrides)
|
27
25
|
produce_instance.tap { |i|
|
28
26
|
apply_attributes(i, :none, floor, overrides)
|
29
|
-
|
27
|
+
|
28
|
+
i.save or fail "Could not create instance of #{@klass_name.inspect}."
|
30
29
|
|
31
30
|
unless @attributes[:after_create].empty?
|
32
31
|
apply_attributes(i, :after_create, floor)
|
33
|
-
i.save
|
32
|
+
i.save or fail "Could not save after_create."
|
34
33
|
end
|
35
34
|
}
|
36
35
|
end
|
@@ -54,12 +53,13 @@ module FloorManager::Employee
|
|
54
53
|
def add_attribute filter, action
|
55
54
|
@attributes[filter] << action
|
56
55
|
end
|
57
|
-
|
56
|
+
|
58
57
|
def produce_instance
|
59
|
-
@klass_name.to_s
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
name = camelcase(@klass_name.to_s)
|
59
|
+
Object.const_get(name).new
|
60
|
+
end
|
61
|
+
def camelcase(str)
|
62
|
+
str.gsub(%r((^|_)\w)) { |match| match[-1].upcase }
|
63
63
|
end
|
64
64
|
|
65
65
|
# Modify attribute values in +instance+, setting them to what was
|
metadata
CHANGED
@@ -1,112 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: floor_manager
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Kaspar Schiess
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
name: activesupport
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2011-09-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: blankslate
|
16
|
+
requirement: &70363139380420 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 2
|
30
|
-
- 3
|
31
|
-
- 5
|
32
|
-
version: 2.3.5
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.1.2.4
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
|
-
prerelease: false
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
version: "0"
|
46
|
-
type: :development
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: flexmock
|
50
23
|
prerelease: false
|
51
|
-
|
52
|
-
none: false
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
type: :development
|
60
|
-
version_requirements: *id003
|
24
|
+
version_requirements: *70363139380420
|
61
25
|
description:
|
62
26
|
email: kaspar.schiess@absurd.li
|
63
27
|
executables: []
|
64
|
-
|
65
28
|
extensions: []
|
66
|
-
|
67
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
68
30
|
- README
|
69
|
-
files:
|
31
|
+
files:
|
32
|
+
- HISTORY.txt
|
70
33
|
- LICENSE
|
71
|
-
- Rakefile
|
72
34
|
- README
|
73
35
|
- lib/floor_manager/employee/attribute_action.rb
|
74
36
|
- lib/floor_manager/employee/dsl.rb
|
75
37
|
- lib/floor_manager/employee.rb
|
76
38
|
- lib/floor_manager/floor.rb
|
77
39
|
- lib/floor_manager.rb
|
78
|
-
has_rdoc: true
|
79
40
|
homepage: http://github.com/kschiess/floor_manager
|
80
41
|
licenses: []
|
81
|
-
|
82
42
|
post_install_message:
|
83
|
-
rdoc_options:
|
43
|
+
rdoc_options:
|
84
44
|
- --main
|
85
45
|
- README
|
86
|
-
require_paths:
|
46
|
+
require_paths:
|
87
47
|
- lib
|
88
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
49
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
segments:
|
94
55
|
- 0
|
95
|
-
|
96
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
hash: 268557802399120653
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
58
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
- 0
|
103
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
104
63
|
requirements: []
|
105
|
-
|
106
64
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.
|
65
|
+
rubygems_version: 1.8.10
|
108
66
|
signing_key:
|
109
67
|
specification_version: 3
|
110
68
|
summary: Allows creation of a whole graph of objects on the fly during testing
|
111
69
|
test_files: []
|
112
|
-
|
data/Rakefile
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "rake/gempackagetask"
|
5
|
-
require "rake/rdoctask"
|
6
|
-
|
7
|
-
require "rspec"
|
8
|
-
require 'rspec/core/rake_task'
|
9
|
-
RSpec::Core::RakeTask.new
|
10
|
-
|
11
|
-
|
12
|
-
task :default => ["spec"]
|
13
|
-
|
14
|
-
# This builds the actual gem. For details of what all these options
|
15
|
-
# mean, and other ones you can add, check the documentation here:
|
16
|
-
#
|
17
|
-
# http://rubygems.org/read/chapter/20
|
18
|
-
#
|
19
|
-
spec = Gem::Specification.new do |s|
|
20
|
-
|
21
|
-
# Change these as appropriate
|
22
|
-
s.name = "floor_manager"
|
23
|
-
s.version = "0.1.1"
|
24
|
-
s.summary = "Allows creation of a whole graph of objects on the fly during testing"
|
25
|
-
s.author = "Kaspar Schiess"
|
26
|
-
s.email = "kaspar.schiess@absurd.li"
|
27
|
-
s.homepage = "http://github.com/kschiess/floor_manager"
|
28
|
-
|
29
|
-
s.has_rdoc = true
|
30
|
-
s.extra_rdoc_files = %w(README)
|
31
|
-
s.rdoc_options = %w(--main README)
|
32
|
-
|
33
|
-
# Add any extra files to include in the gem
|
34
|
-
s.files = %w(LICENSE Rakefile README) + Dir.glob("{spec,lib/**/*}")
|
35
|
-
s.require_paths = ["lib"]
|
36
|
-
|
37
|
-
# If you want to depend on other gems, add them here, along with any
|
38
|
-
# relevant versions
|
39
|
-
s.add_dependency("activesupport", ">= 2.3.5")
|
40
|
-
|
41
|
-
# If your tests use any gems, include them here
|
42
|
-
s.add_development_dependency("rspec")
|
43
|
-
s.add_development_dependency("flexmock")
|
44
|
-
end
|
45
|
-
|
46
|
-
# This task actually builds the gem. We also regenerate a static
|
47
|
-
# .gemspec file, which is useful if something (i.e. GitHub) will
|
48
|
-
# be automatically building a gem for this project. If you're not
|
49
|
-
# using GitHub, edit as appropriate.
|
50
|
-
#
|
51
|
-
# To publish your gem online, install the 'gemcutter' gem; Read more
|
52
|
-
# about that here: http://gemcutter.org/pages/gem_docs
|
53
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
54
|
-
pkg.gem_spec = spec
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "Build the gemspec file #{spec.name}.gemspec"
|
58
|
-
task :gemspec do
|
59
|
-
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
60
|
-
File.open(file, "w") {|f| f << spec.to_ruby }
|
61
|
-
end
|
62
|
-
|
63
|
-
task :package => :gemspec
|
64
|
-
|
65
|
-
# Generate documentation
|
66
|
-
Rake::RDocTask.new do |rd|
|
67
|
-
rd.main = "README"
|
68
|
-
rd.rdoc_files.include("README", "lib/**/*.rb")
|
69
|
-
rd.rdoc_dir = "rdoc"
|
70
|
-
end
|
71
|
-
|
72
|
-
desc 'Clear out RDoc and generated packages'
|
73
|
-
task :clean => [:clobber_rdoc, :clobber_package] do
|
74
|
-
rm "#{spec.name}.gemspec"
|
75
|
-
end
|