bcl 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccb692d80b81a714f5be282d2825f69b7120566a
4
- data.tar.gz: ed52608fbf6a8a1361383d9bf84b873de86f2c0c
3
+ metadata.gz: d33942d293d67bd8ac6595d462269ff40bf5a66e
4
+ data.tar.gz: 664e9df16a4f06cd0e5785f2596aaaafc3ab2dba
5
5
  SHA512:
6
- metadata.gz: 5e73d288bb23e28b1b9d8e5d8cb45adb9af0141cb8907dacf88c0f1fac8f5a9e0d364fa2a4f4a1ba20b5d6791f8add521bfd77f53172585e1b96a065c2349af3
7
- data.tar.gz: e53eecf1df441852fbdfb015742f8077ee8af946304e6b13c32930b5c33b5c94ad1fef87a7b6b913aeadb86449760bc953986f64f608d29a8375d386f3a3372a
6
+ metadata.gz: 1fa0f9dc57b106fbe903056e614f441f30af2f478cfd7e410e6270b05ef869ae959f3b26a4f988f1682c130e38668521f19c5868533a976b75dd6367dced02c3
7
+ data.tar.gz: 9f3bf501251c98d91674994f306d7e79b3f9c61d2785f1eb5b31f43b192d494b42977e5564f3d711a17f409edebb0307e51a43a1da7b4a3e34c92ff46afa6e76
@@ -40,23 +40,20 @@ module BCL
40
40
  attr_accessor :http
41
41
  attr_accessor :parsed_measures_path
42
42
 
43
- def initialize(group_id = nil)
43
+ def initialize()
44
44
  @parsed_measures_path = './measures/parsed/'
45
45
  @config = nil
46
46
  @session = nil
47
47
  @access_token = nil
48
48
  @http = nil
49
49
  @api_version = 2.0
50
- @group_id = group_id.nil? ? 32 : group_id #set group to NREL (32) if nil
50
+ @group_id = nil
51
51
 
52
-
53
52
  load_config
54
53
  end
55
54
 
56
-
57
-
58
55
 
59
- def login(username=nil, password=nil, url=nil)
56
+ def login(username=nil, password=nil, url=nil, group_id = nil)
60
57
  #figure out what url to use
61
58
  if url.nil?
62
59
  url = @config[:server][:url]
@@ -76,10 +73,15 @@ module BCL
76
73
  puts "logging in using credentials in .bcl/config.yml: Connecting to #{url} on port #{port} as #{username}"
77
74
  username = @config[:server][:user][:username]
78
75
  password = @config[:server][:user][:password]
76
+ @group_id = group_id || @config[:server][:user][:group]
79
77
  else
80
78
  puts "logging in using credentials in function arguments: Connecting to #{url} on port #{port} as #{username}"
81
79
  end
82
80
 
81
+ if @group_id.nil?
82
+ puts "[WARNING] You did not set a group ID in your config.yml file. You can retrieve your group ID from the node number of your group page (e.g., https://bcl.nrel.gov/node/32). Will continue, but you will not be able to upload content."
83
+ end
84
+
83
85
  @http = Net::HTTP.new(url, port)
84
86
  if port == 443
85
87
  @http.use_ssl = true
@@ -163,13 +165,13 @@ module BCL
163
165
  def measure_metadata(search_term = nil, filter_term=nil, return_all_pages = false)
164
166
 
165
167
  #setup results directory
166
- if !Dir.exists?(@parsed_measures_path)
168
+ if !File.exists?(@parsed_measures_path)
167
169
  FileUtils.mkdir_p(@parsed_measures_path)
168
170
  end
169
171
  puts "...storing parsed metadata in #{@parsed_measures_path}"
170
172
 
171
173
  #retrieve measures
172
- puts "retrieving measures that match search_term: #{search_term.nil? ? "nil":search_term} and filters: #{filter_term.nil? ? "nil":filter_term}"
174
+ puts "retrieving measures that match search_term: #{search_term.nil? ? "nil" :search_term} and filters: #{filter_term.nil? ? "nil" :filter_term}"
173
175
  retrieve_measures(search_term, filter_term, return_all_pages) do |measure|
174
176
  #parse and save
175
177
  parse_measure_metadata(measure)
@@ -229,7 +231,7 @@ module BCL
229
231
  end
230
232
 
231
233
  # move the directory to the class name
232
- FileUtils.rm_rf(measure_hash[:path]) if Dir.exists?(measure_hash[:path]) && temp_dir_name != measure_hash[:path]
234
+ FileUtils.rm_rf(measure_hash[:path]) if File.exists?(measure_hash[:path]) && temp_dir_name != measure_hash[:path]
233
235
  FileUtils.move(temp_dir_name, measure_hash[:path]) unless temp_dir_name == measure_hash[:path]
234
236
 
235
237
  measure_hash[:arguments] = []
@@ -339,10 +341,10 @@ module BCL
339
341
  "node" =>
340
342
  {
341
343
  "type" => "#{content_type}",
342
- "field_component_tags" => #TODO remove this field_component_tags once BCL is fixed
343
- {
344
- "und" => "1289"
345
- },
344
+ "field_component_tags" => #TODO remove this field_component_tags once BCL is fixed
345
+ {
346
+ "und" => "1289"
347
+ },
346
348
  "og_group_ref" =>
347
349
  {
348
350
  "und" =>
@@ -608,7 +610,7 @@ module BCL
608
610
  end
609
611
  end
610
612
 
611
- # Delete receipt files
613
+ # Delete receipt files
612
614
  def delete_receipts(array_of_components)
613
615
  array_of_components.each do |comp|
614
616
  receipt_file = File.dirname(comp) + "/" + File.basename(comp, '.tar.gz') + ".receipt"
@@ -621,7 +623,7 @@ module BCL
621
623
 
622
624
  def list_all_measures()
623
625
  json = search(nil, "fq[]=bundle%3Anrel_measure&show_rows=100")
624
-
626
+
625
627
  json
626
628
  end
627
629
 
@@ -665,9 +667,18 @@ module BCL
665
667
  puts "******** Please fill in user credentials in #{config_filename} file if you need to upload data **********"
666
668
  end
667
669
  end
668
-
670
+
669
671
  def default_yaml
670
- settings = {:server => {:url => "https://bcl.nrel.gov", :user => {:username => "ENTER_BCL_USERNAME", :password => "ENTER_BCL_PASSWORD"}}}
672
+ settings = {
673
+ :server => {
674
+ :url => "https://bcl.nrel.gov",
675
+ :user => {
676
+ :username => "ENTER_BCL_USERNAME",
677
+ :password => "ENTER_BCL_PASSWORD",
678
+ :group => "ENTER_GROUP_ID"
679
+ }
680
+ }
681
+ }
671
682
 
672
683
  settings
673
684
  end
data/lib/bcl/version.rb CHANGED
@@ -18,5 +18,5 @@
18
18
  ######################################################################
19
19
 
20
20
  module BCL
21
- VERSION = "0.4.0"
21
+ VERSION = "0.4.1"
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Macumber
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-01-30 00:00:00.000000000 Z
14
+ date: 2014-01-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: uuid
@@ -111,6 +111,90 @@ dependencies:
111
111
  - - '>='
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: yamler
116
+ requirement: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ - !ruby/object:Gem::Dependency
129
+ name: faraday
130
+ requirement: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rubyzip
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ~>
147
+ - !ruby/object:Gem::Version
148
+ version: 0.9.9
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ~>
154
+ - !ruby/object:Gem::Version
155
+ version: 0.9.9
156
+ - !ruby/object:Gem::Dependency
157
+ name: mime-types
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ~>
161
+ - !ruby/object:Gem::Version
162
+ version: 1.25.1
163
+ type: :runtime
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ~>
168
+ - !ruby/object:Gem::Version
169
+ version: 1.25.1
170
+ - !ruby/object:Gem::Dependency
171
+ name: roo
172
+ requirement: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ~>
175
+ - !ruby/object:Gem::Version
176
+ version: 1.10.3
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ~>
182
+ - !ruby/object:Gem::Version
183
+ version: 1.10.3
184
+ - !ruby/object:Gem::Dependency
185
+ name: nokogiri
186
+ requirement: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - ~>
189
+ - !ruby/object:Gem::Version
190
+ version: 1.5.10
191
+ type: :runtime
192
+ prerelease: false
193
+ version_requirements: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: 1.5.10
114
198
  description: This gem contains helper methods for generating the Component XML file
115
199
  needed to upload files to the Building Component Library. It also contains the classes
116
200
  needed for logging in via the api and uploading generating components
@@ -150,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
234
  version: '0'
151
235
  requirements: []
152
236
  rubyforge_project:
153
- rubygems_version: 2.0.3
237
+ rubygems_version: 2.0.14
154
238
  signing_key:
155
239
  specification_version: 4
156
240
  summary: Classes for creating component XML files for the BCL