limesurvey-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +85 -0
- data/LICENSE.txt +20 -0
- data/README.md +0 -0
- data/README.rdoc +19 -0
- data/Rakefile +57 -0
- data/lib/limesurvey-rails/configuration.rb +25 -0
- data/lib/limesurvey-rails/limesurvey_rails.rb +65 -0
- data/lib/limesurvey-rails/no_peristence_active_model.rb +25 -0
- data/lib/limesurvey-rails/survey.rb +52 -0
- data/lib/limesurvey-rails/version.rb +10 -0
- data/lib/limesurvey-rails.rb +4 -0
- data/limesurvey-rails.gemspec +81 -0
- data/spec/limesurvey_rails_spec.rb +84 -0
- data/spec/spec_helper.rb +43 -0
- data/spec/support/test_limesurvey_constants.rb +3 -0
- data/spec/survey_spec.rb +28 -0
- metadata +199 -0
data/.document
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3-p448
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
gem "activemodel", "~> 3.2.16"
|
4
|
+
gem "limesurvey"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
# gem "shoulda", ">= 0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.0"
|
13
|
+
gem "rspec", "~> 2.8"
|
14
|
+
gem "debugger"
|
15
|
+
gem "awesome_print"
|
16
|
+
# gem "rcov", ">= 0"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.2.16)
|
5
|
+
activesupport (= 3.2.16)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activesupport (3.2.16)
|
8
|
+
i18n (~> 0.6, >= 0.6.4)
|
9
|
+
multi_json (~> 1.0)
|
10
|
+
addressable (2.3.5)
|
11
|
+
awesome_print (1.2.0)
|
12
|
+
builder (3.0.4)
|
13
|
+
columnize (0.3.6)
|
14
|
+
debugger (1.6.4)
|
15
|
+
columnize (>= 0.3.1)
|
16
|
+
debugger-linecache (~> 1.2.0)
|
17
|
+
debugger-ruby_core_source (~> 1.3.0)
|
18
|
+
debugger-linecache (1.2.0)
|
19
|
+
debugger-ruby_core_source (1.3.0)
|
20
|
+
descendants_tracker (0.0.3)
|
21
|
+
diff-lcs (1.2.5)
|
22
|
+
faraday (0.9.0)
|
23
|
+
multipart-post (>= 1.2, < 3)
|
24
|
+
git (1.2.6)
|
25
|
+
github_api (0.11.1)
|
26
|
+
addressable (~> 2.3)
|
27
|
+
descendants_tracker (~> 0.0.1)
|
28
|
+
faraday (~> 0.8, < 0.10)
|
29
|
+
hashie (>= 1.2)
|
30
|
+
multi_json (>= 1.7.5, < 2.0)
|
31
|
+
nokogiri (~> 1.6.0)
|
32
|
+
oauth2
|
33
|
+
hashie (2.0.5)
|
34
|
+
highline (1.6.20)
|
35
|
+
i18n (0.6.9)
|
36
|
+
jeweler (2.0.0)
|
37
|
+
builder
|
38
|
+
bundler (>= 1.0)
|
39
|
+
git (>= 1.2.5)
|
40
|
+
github_api
|
41
|
+
highline (>= 1.6.15)
|
42
|
+
nokogiri (>= 1.5.10)
|
43
|
+
rake
|
44
|
+
rdoc
|
45
|
+
json (1.8.1)
|
46
|
+
jwt (0.1.10)
|
47
|
+
multi_json (>= 1.5)
|
48
|
+
limesurvey (1.0.0)
|
49
|
+
mini_portile (0.5.2)
|
50
|
+
multi_json (1.8.4)
|
51
|
+
multi_xml (0.5.5)
|
52
|
+
multipart-post (2.0.0)
|
53
|
+
nokogiri (1.6.1)
|
54
|
+
mini_portile (~> 0.5.0)
|
55
|
+
oauth2 (0.9.3)
|
56
|
+
faraday (>= 0.8, < 0.10)
|
57
|
+
jwt (~> 0.1.8)
|
58
|
+
multi_json (~> 1.3)
|
59
|
+
multi_xml (~> 0.5)
|
60
|
+
rack (~> 1.2)
|
61
|
+
rack (1.5.2)
|
62
|
+
rake (10.1.1)
|
63
|
+
rdoc (3.12.2)
|
64
|
+
json (~> 1.4)
|
65
|
+
rspec (2.14.1)
|
66
|
+
rspec-core (~> 2.14.0)
|
67
|
+
rspec-expectations (~> 2.14.0)
|
68
|
+
rspec-mocks (~> 2.14.0)
|
69
|
+
rspec-core (2.14.7)
|
70
|
+
rspec-expectations (2.14.4)
|
71
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
72
|
+
rspec-mocks (2.14.4)
|
73
|
+
|
74
|
+
PLATFORMS
|
75
|
+
ruby
|
76
|
+
|
77
|
+
DEPENDENCIES
|
78
|
+
activemodel (~> 3.2.16)
|
79
|
+
awesome_print
|
80
|
+
bundler (~> 1.0)
|
81
|
+
debugger
|
82
|
+
jeweler (~> 2.0.0)
|
83
|
+
limesurvey
|
84
|
+
rdoc (~> 3.12)
|
85
|
+
rspec (~> 2.8)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 masciugo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
File without changes
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= limesurvey-rails
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to limesurvey-rails
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2014 masciugo. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
require './lib/limesurvey-rails/version.rb'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "limesurvey-rails"
|
19
|
+
gem.version = LimesurveyRails::Version::STRING
|
20
|
+
gem.homepage = "http://github.com/masciugo/limesurvey-rails"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{An ORM-like layer to Limesurvey}
|
23
|
+
gem.description = %Q{An ORM-like layer to Limesurvey}
|
24
|
+
gem.email = "masciugo@gmail.com"
|
25
|
+
gem.authors = ["masciugo"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rspec/core'
|
31
|
+
require 'rspec/core/rake_task'
|
32
|
+
|
33
|
+
RSpec::Core::RakeTask.new(:spec, :tag) do |t, task_args|
|
34
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
35
|
+
t.rspec_opts = "--format documentation --color --debug"
|
36
|
+
t.rspec_opts += " --tag #{task_args[:tag]}" unless task_args[:tag].nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
# require 'rcov/rcovtask'
|
40
|
+
# Rcov::RcovTask.new do |test|
|
41
|
+
# test.libs << 'test'
|
42
|
+
# test.pattern = 'test/**/test_*.rb'
|
43
|
+
# test.verbose = true
|
44
|
+
# test.rcov_opts << '--exclude "gems/*"'
|
45
|
+
# end
|
46
|
+
|
47
|
+
task :default => :test
|
48
|
+
|
49
|
+
require 'rdoc/task'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "limesurvey-rails #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LimesurveyRails
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_accessor :configuration
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.configure
|
8
|
+
self.configuration ||= Configuration.new
|
9
|
+
yield(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configured?
|
13
|
+
!(configuration and configuration.api_base_url and configuration.username and configuration.password).blank?
|
14
|
+
end
|
15
|
+
|
16
|
+
class Configuration
|
17
|
+
attr_accessor :api_base_url, :username, :password
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@api_base_url = nil
|
21
|
+
@username = nil
|
22
|
+
@password = nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module LimesurveyRails
|
2
|
+
API_METHODS = %w{get_session_key release_session_key get_site_settings add_survey delete_survey import_survey get_survey_properties set_survey_properties list_surveys activate_survey export_statistics get_summary add_language delete_survey_language get_language_properties set_language_properties add_group delete_group import_group get_group_properties set_group_properties list_groups list_users delete_question import_question get_question_properties set_question_properties list_questions activate_tokens add_participants delete_participants get_participant_properties set_participant_properties list_participants activate_tokens invite_participants remind_participants add_response export_responses export_responses_by_token}
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_accessor :api, :session_key
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.api_admin_url
|
9
|
+
configuration.api_base_url && configuration.api_base_url + "/admin/remotecontrol"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.connect
|
13
|
+
if connected?
|
14
|
+
false
|
15
|
+
else
|
16
|
+
if configured?
|
17
|
+
self.api = Limesurvey::API.new(api_admin_url)
|
18
|
+
self.session_key = api.get_session_key(configuration.username,configuration.password) if api
|
19
|
+
end
|
20
|
+
session_key.present? and session_key.is_a? String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.disconnect
|
25
|
+
if connected?
|
26
|
+
api.release_session_key if api
|
27
|
+
self.api = nil
|
28
|
+
self.session_key = nil
|
29
|
+
api.nil? and session_key.nil?
|
30
|
+
else
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.connected?
|
36
|
+
session_key and api.list_surveys(session_key).is_a? Array
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.reset
|
40
|
+
disconnect
|
41
|
+
self.configuration = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.method_missing(method_name, *arguments, &block)
|
45
|
+
if API_METHODS.include? method_name.to_s
|
46
|
+
if connected?
|
47
|
+
result = api.send(method_name, *arguments.unshift(session_key))
|
48
|
+
if result.is_a? Hash and result["status"] and result["status"] != 'OK'
|
49
|
+
raise "Limesurvey RPC (#{method_name}) failure response: #{result["status"]}"
|
50
|
+
else
|
51
|
+
result
|
52
|
+
end
|
53
|
+
else
|
54
|
+
raise 'you are disconnected from Limesurvey'
|
55
|
+
end
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def respond_to_missing?(method_name, include_private = false)
|
62
|
+
API_METHODS.include? method_name.to_s || super
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LimesurveyRails
|
2
|
+
class NoPersistenceActiveModel
|
3
|
+
include ActiveModel::MassAssignmentSecurity
|
4
|
+
include ActiveModel::Validations
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
extend ActiveModel::Naming
|
7
|
+
|
8
|
+
# http://stackoverflow.com/questions/8835215/how-to-handle-translations-for-an-activemodel
|
9
|
+
class << self
|
10
|
+
def i18n_scope
|
11
|
+
:activerecord
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(attributes = {})
|
16
|
+
attributes.each do |name, value|
|
17
|
+
send("#{name}=", value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def persisted?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module LimesurveyRails
|
2
|
+
|
3
|
+
class Survey < NoPersistenceActiveModel
|
4
|
+
|
5
|
+
ATTRIBUTES = %w{ sid savetimings allowprev tokenanswerspersistence showgroupinfo showwelcome owner_id template printanswers assessments shownoanswer showprogress admin language ipaddr usecaptcha showqnumcode allowjumps active additional_languages refurl usetokens bouncetime navigationdelay expires datestamp datecreated bounce_email bounceprocessing nokeyboard startdate usecookie publicstatistics attributedescriptions bounceaccounttype alloweditaftercompletion adminemail allowregister publicgraphs emailresponseto bounceaccounthost googleanalyticsstyle anonymized allowsave listpublic emailnotificationto bounceaccountpass googleanalyticsapikey faxto autonumber_start htmlemail tokenlength bounceaccountencryption format autoredirect sendconfirmation showxquestions bounceaccountuser}
|
6
|
+
|
7
|
+
attr_accessible *ATTRIBUTES
|
8
|
+
attr_accessor *ATTRIBUTES
|
9
|
+
|
10
|
+
alias_attribute :id, :sid
|
11
|
+
|
12
|
+
validates_presence_of :surveyls_title, :surveyls_language
|
13
|
+
validate :surveyls_title_must_be_unique
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
LimesurveyRails.list_surveys.map do |s|
|
17
|
+
attributes = LimesurveyRails.get_survey_properties(s['sid'],ATTRIBUTES)
|
18
|
+
new(attributes)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find(sid)
|
23
|
+
LimesurveyRails.get_survey_properties(sid,ATTRIBUTES)
|
24
|
+
end
|
25
|
+
|
26
|
+
# def self.new_url
|
27
|
+
# LIMESURVEY_API_BASE_URL + '/admin/survey/sa/newsurvey'
|
28
|
+
# end
|
29
|
+
|
30
|
+
# def url
|
31
|
+
# LIMESURVEY_API_BASE_URL + "/admin/survey/sa/view/surveyid/#{surveyls_survey_id}"
|
32
|
+
# end
|
33
|
+
|
34
|
+
# def lang
|
35
|
+
# surveyls_language
|
36
|
+
# end
|
37
|
+
|
38
|
+
# def self.destroy(id)
|
39
|
+
# res = LIMESURVEY_API.delete_survey(LS_SESSION_KEY,id)
|
40
|
+
# res['status'] == 'OK'
|
41
|
+
# end
|
42
|
+
|
43
|
+
# private
|
44
|
+
|
45
|
+
# def surveyls_title_must_be_unique
|
46
|
+
# if LIMESURVEY_API.list_surveys(LS_SESSION_KEY).map{|s| s['surveyls_title']}.include?(surveyls_title)
|
47
|
+
# errors.add(:surveyls_title, "already present on Limesurvey")
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'limesurvey-rails/no_peristence_active_model')
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'limesurvey-rails/configuration')
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'limesurvey-rails/survey')
|
4
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'limesurvey-rails/limesurvey_rails')
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "limesurvey-rails"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["masciugo"]
|
12
|
+
s.date = "2014-01-20"
|
13
|
+
s.description = "An ORM-like layer to Limesurvey"
|
14
|
+
s.email = "masciugo@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".rspec",
|
23
|
+
".ruby-version",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"lib/limesurvey-rails.rb",
|
31
|
+
"lib/limesurvey-rails/configuration.rb",
|
32
|
+
"lib/limesurvey-rails/limesurvey_rails.rb",
|
33
|
+
"lib/limesurvey-rails/no_peristence_active_model.rb",
|
34
|
+
"lib/limesurvey-rails/survey.rb",
|
35
|
+
"lib/limesurvey-rails/version.rb",
|
36
|
+
"limesurvey-rails.gemspec",
|
37
|
+
"spec/limesurvey_rails_spec.rb",
|
38
|
+
"spec/spec_helper.rb",
|
39
|
+
"spec/support/test_limesurvey_constants.rb",
|
40
|
+
"spec/survey_spec.rb"
|
41
|
+
]
|
42
|
+
s.homepage = "http://github.com/masciugo/limesurvey-rails"
|
43
|
+
s.licenses = ["MIT"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = "1.8.23"
|
46
|
+
s.summary = "An ORM-like layer to Limesurvey"
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
s.specification_version = 3
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<activemodel>, ["~> 3.2.16"])
|
53
|
+
s.add_runtime_dependency(%q<limesurvey>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
|
57
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8"])
|
58
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
59
|
+
s.add_development_dependency(%q<awesome_print>, [">= 0"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<activemodel>, ["~> 3.2.16"])
|
62
|
+
s.add_dependency(%q<limesurvey>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
66
|
+
s.add_dependency(%q<rspec>, ["~> 2.8"])
|
67
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
68
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<activemodel>, ["~> 3.2.16"])
|
72
|
+
s.add_dependency(%q<limesurvey>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
74
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
75
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 2.8"])
|
77
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
78
|
+
s.add_dependency(%q<awesome_print>, [">= 0"])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe LimesurveyRails do
|
4
|
+
after(:each) do
|
5
|
+
LimesurveyRails.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when it's not fully configured" do
|
9
|
+
its(:configured?) { should be_false }
|
10
|
+
its(:connected?) { should be_false }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when it's configured with a wrong password" do
|
14
|
+
before(:each) do
|
15
|
+
LimesurveyRails.configure do |config|
|
16
|
+
config.api_base_url = LIMESURVEY_API_BASE_URL
|
17
|
+
config.username = LIMESURVEY_USERNAME
|
18
|
+
config.password = 'wrong_password'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe ".connect" do
|
22
|
+
it "return false" do
|
23
|
+
LimesurveyRails.connect.should be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when it's fully configured" do
|
29
|
+
before(:each) do
|
30
|
+
LimesurveyRails.configure do |config|
|
31
|
+
config.api_base_url = LIMESURVEY_API_BASE_URL
|
32
|
+
config.username = LIMESURVEY_USERNAME
|
33
|
+
config.password = LIMESURVEY_PASSWORD
|
34
|
+
end
|
35
|
+
end
|
36
|
+
its(:configured?) {should be_true }
|
37
|
+
describe 'LimesurveyRails.configuration' do
|
38
|
+
subject { LimesurveyRails.configuration }
|
39
|
+
its(:username) {should eq('rails_user') }
|
40
|
+
its(:password) {should eq('limoncello') }
|
41
|
+
its(:api_base_url) {should eq('http://172.21.42.5/~cinzia/limesurvey/index.php') }
|
42
|
+
end
|
43
|
+
its(:api_admin_url) {should eq('http://172.21.42.5/~cinzia/limesurvey/index.php/admin/remotecontrol') }
|
44
|
+
its(:connected?) { should be_false }
|
45
|
+
describe ".connect" do
|
46
|
+
it "return true" do
|
47
|
+
LimesurveyRails.connect.should be_true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
describe ".disconnect" do
|
51
|
+
it "return true" do
|
52
|
+
LimesurveyRails.disconnect.should be_false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
context "when it's connected" do
|
56
|
+
before(:each) do
|
57
|
+
LimesurveyRails.connect
|
58
|
+
end
|
59
|
+
describe ".connect" do
|
60
|
+
it "return false" do
|
61
|
+
LimesurveyRails.connect.should be_false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
its(:connected?) { should be_true }
|
65
|
+
describe ".disconnect" do
|
66
|
+
it "return true" do
|
67
|
+
LimesurveyRails.disconnect.should be_true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
describe ".list_surveys" do
|
71
|
+
it "return an array" do
|
72
|
+
LimesurveyRails.list_surveys.should be_an_instance_of Array
|
73
|
+
end
|
74
|
+
end
|
75
|
+
describe ".wrong_name_method" do
|
76
|
+
specify { expect { LimesurveyRails.wrong_name_method }.to raise_error }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
# config.order = 'random'
|
17
|
+
|
18
|
+
config.expect_with :rspec do |c|
|
19
|
+
# # Disable the `expect` sytax...
|
20
|
+
c.syntax = :should
|
21
|
+
|
22
|
+
# ...or disable the `should` syntax...
|
23
|
+
c.syntax = :expect
|
24
|
+
|
25
|
+
# # ...or explicitly enable both
|
26
|
+
c.syntax = [:should, :expect]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require "active_model"
|
31
|
+
require "limesurvey"
|
32
|
+
require "logger"
|
33
|
+
require "debugger"
|
34
|
+
require 'awesome_print'
|
35
|
+
|
36
|
+
# this is to make absolutely sure we test this one, not the one
|
37
|
+
# installed on the system.
|
38
|
+
require File.expand_path('../../lib/limesurvey-rails', __FILE__)
|
39
|
+
|
40
|
+
# requiring supporting files like shared examples
|
41
|
+
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
42
|
+
|
43
|
+
|
data/spec/survey_spec.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe LimesurveyRails::Survey, :wip => true do
|
4
|
+
before(:each) do
|
5
|
+
LimesurveyRails.configure do |config|
|
6
|
+
config.api_base_url = LIMESURVEY_API_BASE_URL
|
7
|
+
config.username = LIMESURVEY_USERNAME
|
8
|
+
config.password = LIMESURVEY_PASSWORD
|
9
|
+
end
|
10
|
+
LimesurveyRails.connect
|
11
|
+
end
|
12
|
+
after(:each) do
|
13
|
+
LimesurveyRails.reset
|
14
|
+
end
|
15
|
+
|
16
|
+
describe ".all" do
|
17
|
+
it "return an Array" do
|
18
|
+
LimesurveyRails::Survey.all.should be_an_instance_of(Array)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".find(642564)" do
|
23
|
+
it "return a Hash" do
|
24
|
+
LimesurveyRails::Survey.find(642564).should be_an_instance_of(Hash)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: limesurvey-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- masciugo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.16
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.16
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: limesurvey
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.12'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.12'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: jeweler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.0.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.0.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.8'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.8'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: debugger
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: awesome_print
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: An ORM-like layer to Limesurvey
|
143
|
+
email: masciugo@gmail.com
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files:
|
147
|
+
- LICENSE.txt
|
148
|
+
- README.md
|
149
|
+
- README.rdoc
|
150
|
+
files:
|
151
|
+
- .document
|
152
|
+
- .rspec
|
153
|
+
- .ruby-version
|
154
|
+
- Gemfile
|
155
|
+
- Gemfile.lock
|
156
|
+
- LICENSE.txt
|
157
|
+
- README.md
|
158
|
+
- README.rdoc
|
159
|
+
- Rakefile
|
160
|
+
- lib/limesurvey-rails.rb
|
161
|
+
- lib/limesurvey-rails/configuration.rb
|
162
|
+
- lib/limesurvey-rails/limesurvey_rails.rb
|
163
|
+
- lib/limesurvey-rails/no_peristence_active_model.rb
|
164
|
+
- lib/limesurvey-rails/survey.rb
|
165
|
+
- lib/limesurvey-rails/version.rb
|
166
|
+
- limesurvey-rails.gemspec
|
167
|
+
- spec/limesurvey_rails_spec.rb
|
168
|
+
- spec/spec_helper.rb
|
169
|
+
- spec/support/test_limesurvey_constants.rb
|
170
|
+
- spec/survey_spec.rb
|
171
|
+
homepage: http://github.com/masciugo/limesurvey-rails
|
172
|
+
licenses:
|
173
|
+
- MIT
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
none: false
|
180
|
+
requirements:
|
181
|
+
- - ! '>='
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
segments:
|
185
|
+
- 0
|
186
|
+
hash: -2411240419226384970
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
none: false
|
189
|
+
requirements:
|
190
|
+
- - ! '>='
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 1.8.23
|
196
|
+
signing_key:
|
197
|
+
specification_version: 3
|
198
|
+
summary: An ORM-like layer to Limesurvey
|
199
|
+
test_files: []
|