ixtlan-core 0.7.4 → 0.7.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.
@@ -1 +1,160 @@
|
|
1
|
-
require '
|
1
|
+
require 'fileutils'
|
2
|
+
require 'ruby-maven'
|
3
|
+
module Maven
|
4
|
+
class CucumberSteps
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@options = {:ruby_version => RUBY_VERSION }
|
8
|
+
@options[:jruby_version] = JRUBY_VERSION if defined? JRUBY_VERSION
|
9
|
+
|
10
|
+
@options.merge!(options || {})
|
11
|
+
end
|
12
|
+
|
13
|
+
def rmvn
|
14
|
+
@rmvn ||= Maven::RubyMaven.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def copy_tests(tests)
|
18
|
+
FileUtils.mkdir_p(@app_directory)
|
19
|
+
FileUtils.cp_r(File.join('templates', "tests-#{tests}", "."),
|
20
|
+
File.join(@app_directory, 'test'),
|
21
|
+
:remove_destination => true)
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_specs(specs)
|
25
|
+
FileUtils.mkdir_p(@app_directory)
|
26
|
+
FileUtils.cp_r(File.join('templates', "specs-#{specs}", "."),
|
27
|
+
File.join(@app_directory, 'spec'),
|
28
|
+
:remove_destination => true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def copy_files(files)
|
32
|
+
FileUtils.mkdir_p(@app_directory)
|
33
|
+
FileUtils.cp_r(File.join('templates', "files-#{files}", "."),
|
34
|
+
@app_directory,
|
35
|
+
:remove_destination => true)
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_rails_application(template)
|
39
|
+
name = template.sub(/.template$/, '')
|
40
|
+
@app_directory = File.join('target', name)
|
41
|
+
|
42
|
+
# rails version from gemspec
|
43
|
+
gemspec = File.read(Dir.glob("*.gemspec")[0])
|
44
|
+
rails_version = gemspec.split("\n").detect { |l| l =~ /development_dep.*rails/ }.sub(/'$/, '').sub(/.*'/, '')
|
45
|
+
|
46
|
+
rmvn.options['-Dplugin.version'] = @options[:plugin_version] if @options[:plugin_version]
|
47
|
+
rmvn.options['-Djruby.version'] = @options[:jruby_version] if @options[:jruby_version]
|
48
|
+
if @options[:ruby_version]
|
49
|
+
rversion = @options[:ruby_version] =~ /^1.8./ ? '--1.8': '--1.9'
|
50
|
+
rmvn.options['-Djruby.switches'] = rversion
|
51
|
+
end
|
52
|
+
|
53
|
+
rmvn.options['-Drails.version'] = rails_version
|
54
|
+
rmvn.options['-Dgem.home'] = ENV['GEM_HOME']
|
55
|
+
rmvn.options['-Dgem.path'] = ENV['GEM_PATH']
|
56
|
+
rmvn.options['-o'] = nil
|
57
|
+
|
58
|
+
FileUtils.rm_rf(@app_directory)
|
59
|
+
|
60
|
+
template_file = File.expand_path("templates/#{template}")
|
61
|
+
rmvn.exec("rails", "new", @app_directory, "-f", '--', '-e', "-Dtemplate=#{template_file}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def given_template(template)
|
65
|
+
create_rails_application(template)
|
66
|
+
end
|
67
|
+
|
68
|
+
def given_template_and_tests(template, tests)
|
69
|
+
create_rails_application(template)
|
70
|
+
copy_tests(tests)
|
71
|
+
end
|
72
|
+
|
73
|
+
def given_template_and_specs(template, specs)
|
74
|
+
create_rails_application(template)
|
75
|
+
copy_specs(specs)
|
76
|
+
end
|
77
|
+
|
78
|
+
def given_template_and_files(template, files)
|
79
|
+
create_rails_application(template)
|
80
|
+
copy_files(files)
|
81
|
+
end
|
82
|
+
|
83
|
+
def given_application(name)
|
84
|
+
@app_directory = File.join('target', name)
|
85
|
+
end
|
86
|
+
|
87
|
+
def given_application_and_tests(name, tests)
|
88
|
+
@app_directory = File.join('target', name)
|
89
|
+
copy_tests(tests)
|
90
|
+
end
|
91
|
+
|
92
|
+
def given_application_and_specs(name, specs)
|
93
|
+
@app_directory = File.join('target', name)
|
94
|
+
copy_specs(specs)
|
95
|
+
end
|
96
|
+
|
97
|
+
def given_application_and_files(name, files)
|
98
|
+
@app_directory = File.join('target', name)
|
99
|
+
copy_files(files)
|
100
|
+
end
|
101
|
+
|
102
|
+
def execute(args)
|
103
|
+
rmvn.options['-l'] = "output.log"
|
104
|
+
rmvn.exec_in(@app_directory, args.split(' '))
|
105
|
+
end
|
106
|
+
|
107
|
+
def expected_output(expected)
|
108
|
+
result = File.read(File.join(@app_directory, "output.log"))
|
109
|
+
expected.split(/\"?\s+and\s+\"?/).each do |exp|
|
110
|
+
puts exp
|
111
|
+
yield(result =~ /.*#{exp}.*/)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
steps = Maven::CucumberSteps.new(:plugin_version => '0.29.0')
|
119
|
+
|
120
|
+
Given /^I create new rails application with template "(.*)"$/ do |template|
|
121
|
+
steps.given_template(template)
|
122
|
+
end
|
123
|
+
|
124
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" tests$/ do |template, tests|
|
125
|
+
steps.given_template_and_tests(template, tests)
|
126
|
+
end
|
127
|
+
|
128
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" specs$/ do |template, specs|
|
129
|
+
steps.given_template_and_specs(template, specs)
|
130
|
+
end
|
131
|
+
|
132
|
+
Given /^I create new rails application with template "(.*)" and "(.*)" files$/ do |template, files|
|
133
|
+
steps.given_template_and_files(template, files)
|
134
|
+
end
|
135
|
+
|
136
|
+
Given /^me an existing rails application "(.*)"$/ do |name|
|
137
|
+
steps.given_application(name)
|
138
|
+
end
|
139
|
+
|
140
|
+
Given /^me an existing rails application "(.*)" and "(.*)" tests$/ do |name, tests|
|
141
|
+
steps.given_application_and_tests(name, tests)
|
142
|
+
end
|
143
|
+
|
144
|
+
Given /^me an existing rails application "(.*)" and "(.*)" specs$/ do |name, specs|
|
145
|
+
steps.given_application_and_specs(name, specs)
|
146
|
+
end
|
147
|
+
|
148
|
+
Given /^me an existing rails application "(.*)" and "(.*)" files$/ do |name, files|
|
149
|
+
steps.given_application_and_files(name, files)
|
150
|
+
end
|
151
|
+
|
152
|
+
And /^I execute \"(.*)\"$/ do |args|
|
153
|
+
steps.execute(args)
|
154
|
+
end
|
155
|
+
|
156
|
+
Then /^the output should contain \"(.*)\"$/ do |expected|
|
157
|
+
steps.expected_output(expected) do |exp|
|
158
|
+
exp.should_not be_nil
|
159
|
+
end
|
160
|
+
end
|
@@ -3,14 +3,17 @@ module Ixtlan
|
|
3
3
|
module ActiveRecord
|
4
4
|
|
5
5
|
def self.included(base)
|
6
|
+
warn 'deprecated: use ixtlan-optimistic instead'
|
6
7
|
base.class_eval do
|
7
8
|
|
8
9
|
def self.optimistic_find(updated_at, *args)
|
9
|
-
if updated_at
|
10
|
-
|
10
|
+
if updated_at
|
11
|
+
dummy = self.new
|
12
|
+
dummy.updated_at = updated_at
|
13
|
+
updated_at_date = dummy.updated_at
|
11
14
|
# try different ways to use the date
|
12
15
|
# TODO maybe there is a nicer way ??
|
13
|
-
first(:conditions => ["id = ? and updated_at <= ? and updated_at >= ?", args[0],
|
16
|
+
first(:conditions => ["id = ? and updated_at <= ? and updated_at >= ?", args[0], updated_at_date + 0.0005, updated_at_date - 0.0005])
|
14
17
|
# TODO make it work with different PKs
|
15
18
|
end
|
16
19
|
end
|
@@ -2,16 +2,15 @@ module Ixtlan
|
|
2
2
|
module Core
|
3
3
|
module DataMapper
|
4
4
|
|
5
|
-
def self.included(base)
|
5
|
+
def self.included(base)
|
6
|
+
warn 'deprecated: use ixtlan-optimistic instead'
|
6
7
|
base.class_eval do
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
def optimistic_find(updated_at, *args)
|
9
|
+
def self.optimistic_get(updated_at, *args)
|
11
10
|
if updated_at
|
12
|
-
|
11
|
+
updated_at_date = new(:updated_at => updated_at).updated_at
|
13
12
|
# TODO make it work with different PKs
|
14
|
-
first(:id => args[0], :updated_at => updated_at)
|
13
|
+
first(:id => args[0], :updated_at.gte => updated_at_date - 0.0005, :updated_at.lte => updated_at_date + 0.0005)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
data/lib/ixtlan/core/railtie.rb
CHANGED
@@ -34,7 +34,9 @@ module Ixtlan
|
|
34
34
|
end
|
35
35
|
|
36
36
|
class Railtie < Rails::Railtie
|
37
|
-
|
37
|
+
|
38
|
+
gmethod = config.respond_to?(:generators)? :generators : :app_generators
|
39
|
+
config.send(gmethod) do |config|
|
38
40
|
|
39
41
|
config.templates << File.expand_path('../../../generators/rails', __FILE__)
|
40
42
|
|
@@ -63,8 +65,7 @@ module Ixtlan
|
|
63
65
|
|
64
66
|
if defined? ::DataMapper
|
65
67
|
|
66
|
-
::DataMapper::
|
67
|
-
Ixtlan::Core::DataMapper)
|
68
|
+
::DataMapper::Model.append_inclusions(Ixtlan::Core::DataMapper)
|
68
69
|
|
69
70
|
elsif defined? ::ActiveRecord
|
70
71
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ixtlan-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- mkristian
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-03 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: slf4r
|
@@ -75,7 +75,7 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - "="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 3.0.
|
78
|
+
version: 3.0.4.0.29.0
|
79
79
|
type: :development
|
80
80
|
version_requirements: *id006
|
81
81
|
description: cache header control, dynamic configuration, and optimistic find on model via updated_at timestamp
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
requirements: []
|
146
146
|
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.8.
|
148
|
+
rubygems_version: 1.8.24
|
149
149
|
signing_key:
|
150
150
|
specification_version: 3
|
151
151
|
summary: cache header control, dynamic configuration, and optimistic find on model via updated_at timestamp
|